From ee61bc739e133ca2b07bc51d1baa3249265193dd Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 30 Nov 2018 01:31:32 +0100 Subject: test: use assertRun instead of runProcess where possible The case_decrypt_tls.test_tls_rsa_pq test is unexpectedly passing when GnuTLS is disabled. It checks for '/' in the output, but that also matches an error message. Use assertRun here and pretty much everywhere else to catch such issues. Remove a few redundant returncode checks. Change-Id: I0f9d1dadc0ca73eef9cffb3e2f452aa7c8395c95 Reviewed-on: https://code.wireshark.org/review/30838 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- test/suite_io.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'test/suite_io.py') diff --git a/test/suite_io.py b/test/suite_io.py index 9b0fa9cf42..be8fed715a 100644 --- a/test/suite_io.py +++ b/test/suite_io.py @@ -40,22 +40,19 @@ def check_io_4_packets(self, capture_file, cmd=None, from_stdin=False, to_stdout # cat -B "${CAPTURE_DIR}dhcp.pcap" | $DUT -r - -w ./testout.pcap 2>./testout.txt cat_dhcp_cmd = subprocesstest.cat_dhcp_command('cat') stdin_cmd = '{0} | "{1}" -r - -w "{2}"'.format(cat_dhcp_cmd, cmd, testout_file) - io_proc = self.runProcess(stdin_cmd, shell=True) + io_proc = self.assertRun(stdin_cmd, shell=True) elif to_stdout: # $DUT -r "${CAPTURE_DIR}dhcp.pcap" -w - > ./testout.pcap 2>./testout.txt stdout_cmd = '"{0}" -r "{1}" -w - > "{2}"'.format(cmd, capture_file('dhcp.pcap'), testout_file) - io_proc = self.runProcess(stdout_cmd, shell=True) + io_proc = self.assertRun(stdout_cmd, shell=True) else: # direct->direct # $DUT -r "${CAPTURE_DIR}dhcp.pcap" -w ./testout.pcap > ./testout.txt 2>&1 - io_proc = self.runProcess((cmd, + io_proc = self.assertRun((cmd, '-r', capture_file('dhcp.pcap'), '-w', testout_file, )) - io_returncode = io_proc.returncode - self.assertEqual(io_returncode, 0) self.assertTrue(os.path.isfile(testout_file)) - if (io_returncode == 0): - self.checkPacketCount(4) + self.checkPacketCount(4) @fixtures.mark_usefixtures('test_env') @@ -86,8 +83,5 @@ class case_rawshark_io(subprocesstest.SubprocessTestCase): testout_file = self.filename_from_id(testout_pcap) raw_dhcp_cmd = subprocesstest.cat_dhcp_command('raw') rawshark_cmd = '{0} | "{1}" -r - -n -dencap:1 -R "udp.port==68"'.format(raw_dhcp_cmd, cmd_rawshark) - rawshark_proc = self.runProcess(rawshark_cmd, shell=True) - rawshark_returncode = rawshark_proc.returncode - self.assertEqual(rawshark_returncode, 0) - if (rawshark_returncode == 0): - self.assertTrue(self.diffOutput(rawshark_proc.stdout_str, io_baseline_str, 'rawshark', baseline_file)) + rawshark_proc = self.assertRun(rawshark_cmd, shell=True) + self.assertTrue(self.diffOutput(rawshark_proc.stdout_str, io_baseline_str, 'rawshark', baseline_file)) -- cgit v1.2.3