tests/vm: avoid image presence check and removal

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>
This commit is contained in:
Cleber Rosa 2019-06-13 09:07:16 -04:00 committed by Alex Bennée
parent 676d1f3e2f
commit fcd2060e8e
5 changed files with 0 additions and 10 deletions

View File

@ -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

View File

@ -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__":

View File

@ -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__":

View File

@ -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__":

View File

@ -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