[U-Boot] [PATCH 3/9] test: Check exit status in run_and_log_expect_exception()

Simon Glass sjg at chromium.org
Mon Aug 1 01:35:03 CEST 2016


This check was missed. Add it and make the message more verbose.

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

 test/py/multiplexed_log.py | 2 ++
 test/py/u_boot_utils.py    | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
index 35a32fb..bf926c3 100644
--- a/test/py/multiplexed_log.py
+++ b/test/py/multiplexed_log.py
@@ -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
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index e358c58..d71348f 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -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()
 
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list