]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
blackbox tests: method to check specific exit codes
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 16 Aug 2017 01:52:25 +0000 (13:52 +1200)
committerStefan Metzmacher <metze@samba.org>
Tue, 14 Nov 2017 09:15:19 +0000 (10:15 +0100)
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)

python/samba/tests/__init__.py

index 1c5f678038ee74d8e5a668de4d965334f1f4269b..a629fa5942367ee825019d9fd9348e2856a23117 100644 (file)
@@ -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)