diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2017-08-16 13:52:25 +1200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2017-11-14 10:15:19 +0100 |
commit | d433c7f455e9ccb03c96bad2984c7cab3ef28628 (patch) | |
tree | f048c4497388f5cacbf2366136d2eb14cb7bead5 | |
parent | aba4994bd071bdef8c623632ee248cb99d68ed05 (diff) | |
download | samba-d433c7f455e9ccb03c96bad2984c7cab3ef28628.tar.gz |
blackbox tests: method to check specific exit codes
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
(cherry picked from commit 74ebcf6dfc84b6aab6838fa99e12808eb6b913d9)
-rw-r--r-- | python/samba/tests/__init__.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 1c5f678038e..a629fa59423 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -790,11 +790,20 @@ class BlackboxTestCase(TestCaseInTempDir): return line def check_run(self, line): + self.check_exit_code(line, 0) + + def check_exit_code(self, line, expected): line = self._make_cmdline(line) - p = subprocess.Popen(line, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + p = subprocess.Popen(line, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=True) retcode = p.wait() - if retcode: - raise BlackboxProcessError(retcode, line, p.stdout.read(), p.stderr.read()) + if retcode != expected: + raise BlackboxProcessError(retcode, + line, + p.stdout.read(), + p.stderr.read()) def check_output(self, line): line = self._make_cmdline(line) |