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