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 <peter@korsgaard.com>
Reviewed-by: Fiona Klute <fiona.klute@gmx.de>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
Peter Korsgaard
2026-06-18 14:47:52 +02:00
parent 32bdc4710a
commit 03783de150

View File

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