mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
support/tests: print failed command and output on assertRunOK error
Currently, when asserting that a command succeeded, we just capture the
return code of the command. If that is not zero, the assertion fails,
but the error message is not very splicit:
AssertionError: 1 != 0
Replace the error message with an explicit message that dumps the failed
command, the error code, and the resulting output.
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 44161560dd)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
committed by
Peter Korsgaard
parent
35fa0316c9
commit
d475cb6056
@@ -88,7 +88,12 @@ class BRTest(BRConfigTest):
|
|||||||
super(BRTest, self).tearDown()
|
super(BRTest, self).tearDown()
|
||||||
|
|
||||||
# Run the given 'cmd' with a 'timeout' on the target and
|
# Run the given 'cmd' with a 'timeout' on the target and
|
||||||
# assert that the command succeeded
|
# assert that the command succeeded; on error, print the
|
||||||
|
# faulty command and its output
|
||||||
def assertRunOk(self, cmd, timeout=-1):
|
def assertRunOk(self, cmd, timeout=-1):
|
||||||
_, exit_code = self.emulator.run(cmd, timeout)
|
out, exit_code = self.emulator.run(cmd, timeout)
|
||||||
self.assertEqual(exit_code, 0)
|
self.assertEqual(
|
||||||
|
exit_code,
|
||||||
|
0,
|
||||||
|
"\nFailed to run: {}\noutput was:\n{}".format(cmd, ' '+'\n '.join(out))
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user