diff --git a/support/testing/infra/basetest.py b/support/testing/infra/basetest.py index 12d96415da..5c3231d2b9 100644 --- a/support/testing/infra/basetest.py +++ b/support/testing/infra/basetest.py @@ -91,3 +91,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)) + )