mirror of
https://git.proxmox.com/git/systemd
synced 2026-01-07 03:53:53 +00:00
debian/tests/storage: improve cleanups.
On fast ppc64el machines, cryptsetup start job may not complete by the time tearDown is executed. In that case stop, causes to simply cancel the start job without actually cleaning up the dmsetup node. This leads to failing subsequent test as it no longer starts with a clean device. Thus ensure the systemd-cryptsetup unit is started, before stopping it. Also rmmod scsi_debug module at the end, to allow re-running the test in a loop.
This commit is contained in:
parent
045998b2a9
commit
bfafb0924a
10
debian/tests/storage
vendored
10
debian/tests/storage
vendored
@ -29,6 +29,11 @@ class FakeDriveTestBase(unittest.TestCase):
|
||||
assert len(devs) == 1
|
||||
klass.device = '/dev/' + devs[0]
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(klass):
|
||||
# create a fake SCSI hard drive
|
||||
subprocess.check_call(['rmmod', 'scsi_debug'])
|
||||
|
||||
def tearDown(self):
|
||||
# clear drive
|
||||
with open(self.device, 'wb') as f:
|
||||
@ -62,12 +67,17 @@ class CryptsetupTest(FakeDriveTestBase):
|
||||
os.waitpid(self.password_agent, 0)
|
||||
self.password_agent = None
|
||||
subprocess.call(['umount', self.plaintext_dev], stderr=subprocess.DEVNULL)
|
||||
subprocess.call(['systemctl', 'start', 'systemd-cryptsetup@%s.service' % self.plaintext_name],
|
||||
stderr=subprocess.STDOUT)
|
||||
subprocess.call(['systemctl', 'stop', 'systemd-cryptsetup@%s.service' % self.plaintext_name],
|
||||
stderr=subprocess.STDOUT)
|
||||
if os.path.exists('/etc/crypttab'):
|
||||
os.unlink('/etc/crypttab')
|
||||
if os.path.exists('/etc/crypttab.systemdtest'):
|
||||
os.rename('/etc/crypttab.systemdtest', '/etc/crypttab')
|
||||
if os.path.exists(self.plaintext_dev):
|
||||
subprocess.call(['dmsetup', 'remove', self.plaintext_dev],
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
super().tearDown()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user