tests: fix some FD leaks
There are still much more of them...
This commit is contained in:
parent
58f4369a7e
commit
7aa8d74ad4
@ -692,7 +692,7 @@ class SystemTestsMixin(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
vm.remove_from_disk()
|
vm.remove_from_disk()
|
||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
pass
|
pass
|
||||||
|
|
||||||
del app.domains[vm.qid]
|
del app.domains[vm.qid]
|
||||||
@ -706,10 +706,11 @@ class SystemTestsMixin(object):
|
|||||||
try:
|
try:
|
||||||
conn = libvirt.open(qubes.config.defaults['libvirt_uri'])
|
conn = libvirt.open(qubes.config.defaults['libvirt_uri'])
|
||||||
dom = conn.lookupByName(vmname)
|
dom = conn.lookupByName(vmname)
|
||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
cls._remove_vm_libvirt(dom)
|
cls._remove_vm_libvirt(dom)
|
||||||
|
conn.close()
|
||||||
|
|
||||||
cls._remove_vm_disk(vmname)
|
cls._remove_vm_disk(vmname)
|
||||||
|
|
||||||
@ -753,7 +754,7 @@ class SystemTestsMixin(object):
|
|||||||
subprocess.check_call(['sudo', 'lvremove', '-f'] +
|
subprocess.check_call(['sudo', 'lvremove', '-f'] +
|
||||||
[vol.strip() for vol in volumes.splitlines()
|
[vol.strip() for vol in volumes.splitlines()
|
||||||
if ('/' + prefix) in vol],
|
if ('/' + prefix) in vol],
|
||||||
stdout=open(os.devnull, 'w'))
|
stdout=subprocess.DEVNULL)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -827,7 +828,7 @@ class SystemTestsMixin(object):
|
|||||||
|
|
||||||
wait_count = 0
|
wait_count = 0
|
||||||
while subprocess.call(['xdotool', 'search', '--name', title],
|
while subprocess.call(['xdotool', 'search', '--name', title],
|
||||||
stdout=open(os.path.devnull, 'w'), stderr=subprocess.STDOUT) \
|
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) \
|
||||||
== int(show):
|
== int(show):
|
||||||
wait_count += 1
|
wait_count += 1
|
||||||
if wait_count > timeout*10:
|
if wait_count > timeout*10:
|
||||||
@ -873,7 +874,7 @@ class SystemTestsMixin(object):
|
|||||||
# create a single partition
|
# create a single partition
|
||||||
p = subprocess.Popen(['sfdisk', '-q', '-L', vm.storage.root_img],
|
p = subprocess.Popen(['sfdisk', '-q', '-L', vm.storage.root_img],
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
stdout=open(os.devnull, 'w'),
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
p.communicate('2048,\n')
|
p.communicate('2048,\n')
|
||||||
assert p.returncode == 0, 'sfdisk failed'
|
assert p.returncode == 0, 'sfdisk failed'
|
||||||
@ -892,7 +893,7 @@ class SystemTestsMixin(object):
|
|||||||
'--target', 'i386-pc',
|
'--target', 'i386-pc',
|
||||||
'--modules', 'part_msdos ext2',
|
'--modules', 'part_msdos ext2',
|
||||||
'--boot-directory', mountpoint, loopdev],
|
'--boot-directory', mountpoint, loopdev],
|
||||||
stderr=open(os.devnull, 'w')
|
stderr=subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
grub_cfg = '{}/grub2/grub.cfg'.format(mountpoint)
|
grub_cfg = '{}/grub2/grub.cfg'.format(mountpoint)
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
@ -927,7 +928,7 @@ class SystemTestsMixin(object):
|
|||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
['dracut'] + dracut_args + [os.path.join(mountpoint,
|
['dracut'] + dracut_args + [os.path.join(mountpoint,
|
||||||
'initrd')],
|
'initrd')],
|
||||||
stderr=open(os.devnull, 'w')
|
stderr=subprocess.DEVNULL
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
subprocess.check_call(['sudo', 'umount', mountpoint])
|
subprocess.check_call(['sudo', 'umount', mountpoint])
|
||||||
|
Loading…
Reference in New Issue
Block a user