From 03783de150dc782cb0fc7326a87406dec72bc2eb Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 18 Jun 2026 14:47:52 +0200 Subject: [PATCH] support/testing: infra: add assertRunNotOk() There are a number of runtime tests that checks that a command fails as expected, so add an assertRunNotOk() similar to the existing assertRunOk() to handle that instead of open coding it everywhere. Signed-off-by: Peter Korsgaard Reviewed-by: Fiona Klute Signed-off-by: Peter Korsgaard --- support/testing/infra/basetest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/support/testing/infra/basetest.py b/support/testing/infra/basetest.py index 5fa902a77f..9b3eef6fa8 100644 --- a/support/testing/infra/basetest.py +++ b/support/testing/infra/basetest.py @@ -150,3 +150,14 @@ class BRTest(BRConfigTest): 0, "\nFailed to run: {}\noutput was:\n{}".format(cmd, ' '+'\n '.join(out)) ) + + # Run the given 'cmd' with a 'timeout' on the target and + # assert that the command fails; on success, print the + # faulty command and its output + def assertRunNotOk(self, cmd, timeout=-1): + out, exit_code = self.emulator.run(cmd, timeout) + self.assertNotEqual( + exit_code, + 0, + "\nUnexpected success: {}\noutput was:\n{}".format(cmd, ' '+'\n '.join(out)) + )