X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=blobdiff_plain;f=cli_driver.py;fp=cli_driver.py;h=a7f4b3d5212a67821e636715140c8bc5e5d0c5f9;hp=6906b738e11c271629951b715a546d169ef23179;hb=21e5859e0292d7adc067f98a87be1bb0fe5d11d4;hpb=283dea13d9305a10cc309eb7b524b514012f4be7 diff --git a/cli_driver.py b/cli_driver.py index 6906b73..a7f4b3d 100644 --- a/cli_driver.py +++ b/cli_driver.py @@ -33,7 +33,17 @@ class CliDriver(Driver): def do_apitrace(self, args): cmd = [self.options.apitrace] + args[1:] - self.output = subprocess.check_output(cmd) + proc = subprocess.Popen(cmd, stdout = subprocess.PIPE) + self.output = proc.communicate()[0] + + proc.wait() + + if (self.expect_failure): + if (proc.returncode == 0): + fail("Command unexpectedly passed when expecting failure:\n " + " ".join(cmd)) + else: + if (proc.returncode != 0): + fail("Command failed (returned non-zero):\n " + " ".join(cmd)) def do_expect(self, args): expected = json.loads(" ".join(args[1:])) @@ -68,6 +78,9 @@ class CliDriver(Driver): script = open(cli_script, 'rt') while True: + + self.expect_failure = False + line = script.readline() if (line == ''): @@ -78,6 +91,10 @@ class CliDriver(Driver): if (len(cmd) == 0): continue + if (cmd[0] == 'EXPECT_FAILURE:'): + self.expect_failure = True + cmd.pop(0) + commands.get(cmd[0], self.unknown_command)(cmd) def run(self):