]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Check exit status in run_and_log_expect_exception()
authorSimon Glass <sjg@chromium.org>
Sun, 31 Jul 2016 23:35:03 +0000 (17:35 -0600)
committerTom Rini <trini@konsulko.com>
Sat, 6 Aug 2016 00:55:19 +0000 (20:55 -0400)
This check was missed. Add it and make the message more verbose.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
Fixes: 9e17b034 (test/py: Provide a way to check that a command fails)
test/py/multiplexed_log.py
test/py/u_boot_utils.py

index 35a32fb5c0514fdbd8e697680bac8e338b74edb9..bf926c3e7762ae37ffc026ebebf58e05641df50a 100644 (file)
@@ -102,6 +102,7 @@ class RunAndLog(object):
         self.name = name
         self.chained_file = chained_file
         self.output = None
+        self.exit_status = None
 
     def close(self):
         """Clean up any resources managed by this object."""
@@ -166,6 +167,7 @@ class RunAndLog(object):
 
         # Store the output so it can be accessed if we raise an exception.
         self.output = output
+        self.exit_status = exit_status
         if exception:
             raise exception
         return output
index e358c585bf888f71ee55d326df9126f1111d1a46..d71348f70e9aceb5e29a86b504c357ce1d2b78ca 100644 (file)
@@ -201,9 +201,11 @@ def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg):
         runner = u_boot_console.log.get_runner(cmd[0], sys.stdout)
         runner.run(cmd)
     except Exception as e:
+        assert(retcode == runner.exit_status)
         assert(msg in runner.output)
     else:
-        raise Exception('Expected exception, but not raised')
+        raise Exception("Expected an exception with retcode %d message '%s',"
+                        "but it was not raised" % (retcode, msg))
     finally:
         runner.close()