summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2016-10-07 14:55:36 -0500
committerTony Asleson <tasleson@redhat.com>2016-10-10 16:31:00 -0500
commitcb4e26dcb3aa49128d76eb61495c2ee165974ad9 (patch)
tree693f4e13b2169c85b04aa900f80db5575c6bb592
parent9f0195ec1ec1113695abdb1ada82dc138bc7488b (diff)
downloadlvm2-cb4e26dcb3aa49128d76eb61495c2ee165974ad9.tar.gz
lvmdbustest.py: Ensure we exit non-zero on fail
If you run multiple runs of unittest.main, unless you don't pass exit=true the test case always ends with a 0 exit code. Add ability to store the result of each invocation of the test and exit with a non-zero exit code if anyone of them fail.
-rwxr-xr-xtest/dbus/lvmdbustest.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 819d09660..e9b27a0a0 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1294,8 +1294,25 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(tag in vg_proxy.Vg.Tags, "%s not in %s" %
(tag, str(vg_proxy.Vg.Tags)))
+class AggregateResults(object):
+
+ def __init__(self):
+ self.no_errors = True
+
+ def register_result(self, result):
+ if not result.result.wasSuccessful():
+ self.no_errors = False
+
+ def exit_run(self):
+ if self.no_errors:
+ sys.exit(0)
+ sys.exit(1)
+
if __name__ == '__main__':
+
+ r = AggregateResults()
+
# Test forking & exec new each time
test_shell = os.getenv('LVM_DBUS_TEST_SHELL', 1)
@@ -1304,19 +1321,21 @@ if __name__ == '__main__':
if int(test_shell) == 0:
print('\n Shortened fork & exec test ***\n')
- unittest.main(exit=True)
+ r.register_result(unittest.main(exit=False))
else:
print('\n *** Testing fork & exec *** \n')
- unittest.main(exit=False)
+ r.register_result(unittest.main(exit=False))
g_tmo = 15
- unittest.main(exit=False)
+ r.register_result(unittest.main(exit=False))
# Test lvm shell
print('\n *** Testing lvm shell *** \n')
if set_execution(True):
g_tmo = 0
- unittest.main(exit=False)
+ r.register_result(unittest.main(exit=False))
g_tmo = 15
- unittest.main()
+ r.register_result(unittest.main(exit=False))
else:
print("WARNING: Unable to dynamically configure "
"service to use lvm shell!")
+
+ r.exit_run()