blackbox tests: method to check specific exit codes
[samba.git] / python / samba / tests / __init__.py
index 2ddfd9d2273f398c72d9e5ef24f32e40d7ef61f3..d012113cda682e73f17cb74f29edd6f86a0743c7 100644 (file)
@@ -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)