diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-04-27 12:56:08 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2018-04-27 22:42:05 +0000 |
commit | 50061856ddc6644657cbdc5f2b5923be9753cb5f (patch) | |
tree | 39918f7775cc5390584568698ea56096d58ca9e6 /test/subprocesstest.py | |
parent | e6d129bf2382b9f0261c813c5b501db8911b254b (diff) |
Test: Add mergecap.
Change-Id: Ib21f4866cff27e22a4dc13300c3c38fa962a860f
Reviewed-on: https://code.wireshark.org/review/27184
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'test/subprocesstest.py')
-rw-r--r-- | test/subprocesstest.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/subprocesstest.py b/test/subprocesstest.py index 357104b461..1587ee41ce 100644 --- a/test/subprocesstest.py +++ b/test/subprocesstest.py @@ -190,13 +190,26 @@ class SubprocessTestCase(unittest.TestCase): pass self.cleanup_files = [] - def checkPacketCount(self, num_packets, cap_file=None): - got_num_packets = False + def getCaptureInfo(self, capinfos_args=None, cap_file=None): + '''Run capinfos on a capture file and log its output. + + capinfos_args must be a sequence. + Default cap_file is <test id>.testout.pcap.''' if not cap_file: cap_file = self.filename_from_id('testout.pcap') self.log_fd.write(u'\nOutput of {0} {1}:\n'.format(config.cmd_capinfos, cap_file)) - capinfos_testout = str(subprocess.check_output((config.cmd_capinfos, cap_file))) - self.log_fd_write_bytes(capinfos_testout) + capinfos_cmd = [config.cmd_capinfos] + if capinfos_args is not None: + capinfos_cmd += capinfos_args + capinfos_cmd.append(cap_file) + capinfos_stdout = str(subprocess.check_output(capinfos_cmd)) + self.log_fd_write_bytes(capinfos_stdout) + return capinfos_stdout + + def checkPacketCount(self, num_packets, cap_file=None): + '''Make sure a capture file contains a specific number of packets.''' + got_num_packets = False + capinfos_testout = self.getCaptureInfo(cap_file=cap_file) count_pat = 'Number of packets:\s+{}'.format(num_packets) if re.search(count_pat, capinfos_testout): got_num_packets = True |