]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
tests/vm: avoid image presence check and removal
authorCleber Rosa <crosa@redhat.com>
Thu, 13 Jun 2019 13:07:16 +0000 (09:07 -0400)
committerAlex Bennée <alex.bennee@linaro.org>
Thu, 4 Jul 2019 18:22:58 +0000 (19:22 +0100)
Python's os.rename() will silently replace an existing file,
so there's no need for the extra check and removal.

Reference: https://docs.python.org/3/library/os.html#os.rename

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190613130718.3763-3-crosa@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
tests/vm/centos
tests/vm/freebsd
tests/vm/netbsd
tests/vm/openbsd
tests/vm/ubuntu.i386

index b00b46a8dc6fade93ad34006a3b0159d16c1eddc..53976f1c4c95ec1e8664a5ebab7a5534c6ceb0e9 100755 (executable)
@@ -77,8 +77,6 @@ class CentosVM(basevm.BaseVM):
         self.ssh_root_check("systemctl enable docker")
         self.ssh_root("poweroff")
         self.wait()
-        if os.path.exists(img):
-            os.remove(img)
         os.rename(img_tmp, img)
         return 0
 
index 5575c23a6f9014a76ba97f1f9f7d58edaf2510e5..091be1a065a75f6f9287c9b13a5de4bff79f3989 100755 (executable)
@@ -36,8 +36,6 @@ class FreeBSDVM(basevm.BaseVM):
         sys.stderr.write("Extracting the image...\n")
         subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
         subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
-        if os.path.exists(img):
-            os.remove(img)
         os.rename(img_tmp, img)
 
 if __name__ == "__main__":
index d0508f44655a2d393c9ae9fa7464341b0694b7bc..ee9eaeab504f620aab790846ae297855b9984ffc 100755 (executable)
@@ -36,8 +36,6 @@ class NetBSDVM(basevm.BaseVM):
         sys.stderr.write("Extracting the image...\n")
         subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
         subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
-        if os.path.exists(img):
-            os.remove(img)
         os.rename(img_tmp, img)
 
 if __name__ == "__main__":
index 87ec9824896549043c01e70e1567925726f0f8b6..28c7d25e297ca7cf4f21a68efb60546de2fe9182 100755 (executable)
@@ -38,8 +38,6 @@ class OpenBSDVM(basevm.BaseVM):
         sys.stderr.write("Extracting the image...\n")
         subprocess.check_call(["ln", "-f", cimg, img_tmp_xz])
         subprocess.check_call(["xz", "--keep", "-dvf", img_tmp_xz])
-        if os.path.exists(img):
-            os.remove(img)
         os.rename(img_tmp, img)
 
 if __name__ == "__main__":
index a22d137e76df8b768568de59542c56e917070c4b..12867b193fb2ced46096125dd282be4d832f8482 100755 (executable)
@@ -80,8 +80,6 @@ class UbuntuX86VM(basevm.BaseVM):
         self.ssh_root_check("apt-get install -y libfdt-dev flex bison")
         self.ssh_root("poweroff")
         self.wait()
-        if os.path.exists(img):
-            os.remove(img)
         os.rename(img_tmp, img)
         return 0