From: Gary Lockyer Date: Wed, 16 Aug 2017 01:52:25 +0000 (+1200) Subject: blackbox tests: method to check specific exit codes X-Git-Tag: tdb-1.3.15~74 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=74ebcf6dfc84b6aab6838fa99e12808eb6b913d9;hp=e12dbc7307802667d401be28f7bdc0086da3b147 blackbox tests: method to check specific exit codes Signed-off-by: Gary Lockyer Reviewed-by: Douglas Bagnall Reviewed-by: Garming Sam --- diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py index 2ddfd9d2273..d012113cda6 100644 --- a/python/samba/tests/__init__.py +++ b/python/samba/tests/__init__.py @@ -318,11 +318,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)