From 8540bfd703821e4931de8e397eab9407dbb2957b Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 18 Jun 2026 14:47:58 +0200 Subject: [PATCH] support/testing: test_cryptsetup.py: use assertRunNotOk() Use the helper to simplify the test. Signed-off-by: Peter Korsgaard (cherry picked from commit 69948ba028f9da153b44d6004ee8ef94193a75bc) Signed-off-by: Thomas Perale --- support/testing/tests/package/test_cryptsetup.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/support/testing/tests/package/test_cryptsetup.py b/support/testing/tests/package/test_cryptsetup.py index e409ea93e6..32a65210b5 100644 --- a/support/testing/tests/package/test_cryptsetup.py +++ b/support/testing/tests/package/test_cryptsetup.py @@ -65,8 +65,7 @@ class TestCryptSetup(infra.basetest.BRTest): # Check the device is NOT detected as a LUKS volume, because # it is not formatted yet. is_luks_cmd = f"cryptsetup isLuks {dev}" - _, ret = self.emulator.run(is_luks_cmd) - self.assertNotEqual(ret, 0) + self.assertRunNotOk(is_luks_cmd) # Format the LUKS volume. cmd = f"echo {passkey} | cryptsetup luksFormat {dev}" @@ -110,15 +109,13 @@ class TestCryptSetup(infra.basetest.BRTest): # We are NOT supposed to find our plain text message on the # encrypted storage device. - _, ret = self.emulator.run(f"grep -Fq '{msg}' {dev}", timeout=10) - self.assertNotEqual(ret, 0) + self.assertRunNotOk(f"grep -Fq '{msg}' {dev}", timeout=10) # Try to open LUKS volume with a wrong password. This is # expected to fail. cmd = f"echo 'Wrong{passkey}' | " cmd += f"cryptsetup open --type luks {dev} {dm_name}" - _, ret = self.emulator.run(cmd, timeout=10) - self.assertNotEqual(ret, 0) + self.assertRunNotOk(cmd, timeout=10) # Check the device-mapper device was NOT created (since we # tried to open it with a wrong password).