support/testing: add assertRunOk method to BRTest class
authorPatrick Havelange <patrick.havelange@essensium.com>
Wed, 20 Nov 2019 13:39:51 +0000 (14:39 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 20 Nov 2019 21:34:53 +0000 (22:34 +0100)
This method asserts that the given command ran successfully.
The goal is for it to be used by the different tests when needed.

Signed-off-by: Patrick Havelange <patrick.havelange@essensium.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
support/testing/infra/basetest.py

index a176bc328a21c3064b1078566dc01150628f9e4f..023039f6afa148d5d79a336589e309ea519e7df9 100644 (file)
@@ -84,3 +84,9 @@ class BRTest(BRConfigTest):
         if self.emulator:
             self.emulator.stop()
         super(BRTest, self).tearDown()
+
+    # Run the given 'cmd' with a 'timeout' on the target and 
+    # assert that the command succeeded
+    def assertRunOk(self, cmd, timeout=-1):
+        _, exit_code = self.emulator.run(cmd, timeout)
+        self.assertEqual(exit_code, 0)