diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-11-30 01:31:32 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-11-30 06:11:06 +0000 |
commit | ee61bc739e133ca2b07bc51d1baa3249265193dd (patch) | |
tree | 21b40ad794b1217b35d11750ec2058c7acff0067 /test | |
parent | 9c0beafe44480b352bb4af56754143c9108a54fa (diff) |
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 <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/suite_capture.py | 57 | ||||
-rw-r--r-- | test/suite_clopts.py | 4 | ||||
-rw-r--r-- | test/suite_decryption.py | 92 | ||||
-rw-r--r-- | test/suite_dissection.py | 8 | ||||
-rw-r--r-- | test/suite_fileformats.py | 26 | ||||
-rw-r--r-- | test/suite_follow.py | 2 | ||||
-rw-r--r-- | test/suite_io.py | 18 | ||||
-rw-r--r-- | test/suite_mergecap.py | 30 | ||||
-rw-r--r-- | test/suite_nameres.py | 6 |
9 files changed, 104 insertions, 139 deletions
diff --git a/test/suite_capture.py b/test/suite_capture.py index 5795dc4f12..a02aa703a5 100644 --- a/test/suite_capture.py +++ b/test/suite_capture.py @@ -118,8 +118,7 @@ def check_capture_10_packets(capture_interface, cmd_dumpcap, traffic_generator): self.log_fd.write('{} -D output:\n'.format(cmd)) self.runProcess((cmd, '-D')) self.assertEqual(capture_returncode, 0) - if (capture_returncode == 0): - self.checkPacketCount(10) + self.checkPacketCount(10) return check_capture_10_packets_real @@ -142,7 +141,7 @@ def check_capture_fifo(cmd_dumpcap): fifo_proc = self.startProcess( ('{0} > {1}'.format(slow_dhcp_cmd, fifo_file)), shell=True) - capture_proc = self.runProcess(capture_command(cmd, + capture_proc = self.assertRun(capture_command(cmd, '-i', fifo_file, '-p', '-w', testout_file, @@ -150,10 +149,7 @@ def check_capture_fifo(cmd_dumpcap): )) fifo_proc.kill() self.assertTrue(os.path.isfile(testout_file)) - capture_returncode = capture_proc.returncode - self.assertEqual(capture_returncode, 0) - if (capture_returncode == 0): - self.checkPacketCount(8) + self.checkPacketCount(8) return check_capture_fifo_real @@ -174,16 +170,13 @@ def check_capture_stdin(cmd_dumpcap): is_gui = type(cmd) != str and '-k' in cmd[0] if is_gui: capture_cmd += ' -o console.log.level:127' - pipe_proc = self.runProcess(slow_dhcp_cmd + ' | ' + capture_cmd, shell=True) - pipe_returncode = pipe_proc.returncode - self.assertEqual(pipe_returncode, 0) + pipe_proc = self.assertRun(slow_dhcp_cmd + ' | ' + capture_cmd, shell=True) if is_gui: self.assertTrue(self.grepOutput('Wireshark is up and ready to go'), 'No startup message.') self.assertTrue(self.grepOutput('Capture started'), 'No capture start message.') self.assertTrue(self.grepOutput('Capture stopped'), 'No capture stop message.') self.assertTrue(os.path.isfile(testout_file)) - if (pipe_returncode == 0): - self.checkPacketCount(8) + self.checkPacketCount(8) return check_capture_stdin_real @@ -194,7 +187,7 @@ def check_capture_read_filter(capture_interface, traffic_generator): self.assertIsNotNone(cmd) testout_file = self.filename_from_id(testout_pcap) stop_traffic = start_traffic() - capture_proc = self.runProcess(capture_command(cmd, + capture_proc = self.assertRun(capture_command(cmd, '-i', capture_interface, '-p', '-w', testout_file, @@ -205,11 +198,7 @@ def check_capture_read_filter(capture_interface, traffic_generator): '-f', cfilter, )) stop_traffic() - capture_returncode = capture_proc.returncode - self.assertEqual(capture_returncode, 0) - - if (capture_returncode == 0): - self.checkPacketCount(0) + self.checkPacketCount(0) return check_capture_read_filter_real @fixtures.fixture @@ -219,7 +208,7 @@ def check_capture_snapshot_len(capture_interface, cmd_tshark, traffic_generator) self.assertIsNotNone(cmd) stop_traffic = start_traffic() testout_file = self.filename_from_id(testout_pcap) - capture_proc = self.runProcess(capture_command(cmd, + capture_proc = self.assertRun(capture_command(cmd, '-i', capture_interface, '-p', '-w', testout_file, @@ -228,22 +217,17 @@ def check_capture_snapshot_len(capture_interface, cmd_tshark, traffic_generator) '-f', cfilter, )) stop_traffic() - capture_returncode = capture_proc.returncode - self.assertEqual(capture_returncode, 0) self.assertTrue(os.path.isfile(testout_file)) # Use tshark to filter out all packets larger than 68 bytes. testout2_file = self.filename_from_id('testout2.pcap') - filter_proc = self.runProcess((cmd_tshark, + filter_proc = self.assertRun((cmd_tshark, '-r', testout_file, '-w', testout2_file, '-Y', 'frame.cap_len>{}'.format(snapshot_len), )) - filter_returncode = filter_proc.returncode - self.assertEqual(capture_returncode, 0) - if (capture_returncode == 0): - self.checkPacketCount(0, cap_file=testout2_file) + self.checkPacketCount(0, cap_file=testout2_file) return check_capture_snapshot_len_real @@ -268,12 +252,8 @@ def check_dumpcap_autostop_stdin(cmd_dumpcap): '-w', testout_file, '-a', condition, )) - pipe_proc = self.runProcess(cat100_dhcp_cmd + ' | ' + capture_cmd, shell=True) - pipe_returncode = pipe_proc.returncode - self.assertEqual(pipe_returncode, 0) + pipe_proc = self.assertRun(cat100_dhcp_cmd + ' | ' + capture_cmd, shell=True) self.assertTrue(os.path.isfile(testout_file)) - if (pipe_returncode != 0): - return if packets is not None: self.checkPacketCount(packets) @@ -307,11 +287,7 @@ def check_dumpcap_ringbuffer_stdin(cmd_dumpcap): '-a', 'files:2', '-b', condition, )) - pipe_proc = self.runProcess(cat100_dhcp_cmd + ' | ' + capture_cmd, shell=True) - pipe_returncode = pipe_proc.returncode - self.assertEqual(pipe_returncode, 0) - if (pipe_returncode != 0): - return + pipe_proc = self.assertRun(cat100_dhcp_cmd + ' | ' + capture_cmd, shell=True) rb_files = glob.glob(testout_glob) for rbf in rb_files: @@ -430,7 +406,7 @@ def check_dumpcap_pcapng_sections(cmd_dumpcap, cmd_tshark, capture_file): capture_cmd = capture_command(cmd_dumpcap, *capture_cmd_args) - capture_proc = self.runProcess(capture_cmd) + capture_proc = self.assertRun(capture_cmd) for fifo_proc in fifo_procs: fifo_proc.kill() rb_files = [] @@ -444,11 +420,6 @@ def check_dumpcap_pcapng_sections(cmd_dumpcap, cmd_tshark, capture_file): self.cleanup_files.append(rbf) self.assertTrue(os.path.isfile(rbf)) - returncode = capture_proc.returncode - self.assertEqual(returncode, 0) - if (returncode != 0): - return - # Output tests if not multi_input and not multi_output: @@ -476,7 +447,7 @@ def check_dumpcap_pcapng_sections(cmd_dumpcap, cmd_tshark, capture_file): for check_val in check_vals: self.checkPacketCount(check_val['packet_count'], cap_file=check_val['filename']) - tshark_proc = self.runProcess(capture_command(cmd_tshark, + tshark_proc = self.assertRun(capture_command(cmd_tshark, '-r', check_val['filename'], '-V', '-X', 'read_format:MIME Files Format' diff --git a/test/suite_clopts.py b/test/suite_clopts.py index 4a0d7b10ce..b1e020c560 100644 --- a/test/suite_clopts.py +++ b/test/suite_clopts.py @@ -152,7 +152,7 @@ class case_tshark_name_resolution_clopts(subprocesstest.SubprocessTestCase): class case_tshark_unicode_clopts(subprocesstest.SubprocessTestCase): def test_tshark_unicode_display_filter(self, cmd_tshark, capture_file): '''Unicode (UTF-8) display filter''' - self.runProcess((cmd_tshark, '-r', capture_file('http.pcap'), '-Y', 'tcp.flags.str == "·······AP···"')) + self.assertRun((cmd_tshark, '-r', capture_file('http.pcap'), '-Y', 'tcp.flags.str == "·······AP···"')) self.assertTrue(self.grepOutput('HEAD.*/v4/iuident.cab')) @@ -180,7 +180,7 @@ class case_tshark_dump_glossaries(subprocesstest.SubprocessTestCase): self.assertTrue(decoded, '{} is not valid UTF-8'.format(glossary)) def test_tshark_glossary_plugin_count(self, cmd_tshark, base_env): - self.runProcess((cmd_tshark, '-G', 'plugins'), env=base_env) + self.assertRun((cmd_tshark, '-G', 'plugins'), env=base_env) self.assertGreaterEqual(self.countOutput('dissector'), 10, 'Fewer than 10 dissector plugins found') def test_tshark_elastic_mapping(self, cmd_tshark, dirs, base_env): diff --git a/test/suite_decryption.py b/test/suite_decryption.py index 6cdbd65ff7..161789a7bb 100644 --- a/test/suite_decryption.py +++ b/test/suite_decryption.py @@ -21,7 +21,7 @@ class case_decrypt_80211(subprocesstest.SubprocessTestCase): def test_80211_wpa_psk(self, cmd_tshark, capture_file): '''IEEE 802.11 WPA PSK''' # https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=view&target=wpa-Induction.pcap - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-o', 'wlan.enable_decryption: TRUE', '-Tfields', '-e', 'http.request.uri', @@ -33,7 +33,7 @@ class case_decrypt_80211(subprocesstest.SubprocessTestCase): def test_80211_wpa_eap(self, cmd_tshark, capture_file): '''IEEE 802.11 WPA EAP (EAPOL Rekey)''' # Included in git sources test/captures/wpa-eap-tls.pcap.gz - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-o', 'wlan.enable_decryption: TRUE', '-r', capture_file('wpa-eap-tls.pcap.gz'), '-Y', 'wlan.analysis.tk==7d9987daf5876249b6c773bf454a0da7', @@ -43,7 +43,7 @@ class case_decrypt_80211(subprocesstest.SubprocessTestCase): def test_80211_wpa_eapol_incomplete_rekeys(self, cmd_tshark, capture_file): '''WPA decode with message1+2 only and secure bit set on message 2''' # Included in git sources test/captures/wpa-test-decode.pcap.gz - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-o', 'wlan.enable_decryption: TRUE', '-r', capture_file('wpa-test-decode.pcap.gz'), '-Y', 'icmp.resp_to == 4263', @@ -53,7 +53,7 @@ class case_decrypt_80211(subprocesstest.SubprocessTestCase): def test_80211_wpa_psk_mfp(self, cmd_tshark, capture_file): '''WPA decode management frames with MFP enabled (802.11w)''' # Included in git sources test/captures/wpa-test-decode-mgmt.pcap.gz - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-o', 'wlan.enable_decryption: TRUE', '-r', capture_file('wpa-test-decode-mgmt.pcap.gz'), '-Y', 'wlan.fixed.reason_code == 2 || wlan.fixed.category_code == 3', @@ -66,7 +66,7 @@ class case_decrypt_80211(subprocesstest.SubprocessTestCase): if not features.have_libgcrypt16: self.skipTest('Requires GCrypt 1.6 or later.') # Included in git sources test/captures/wpa-test-decode-tdls.pcap.gz - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, #'-ouat:80211_keys:"wpa-pwd","12345678"', '-o', 'wlan.enable_decryption: TRUE', '-r', capture_file('wpa-test-decode-tdls.pcap.gz'), @@ -81,7 +81,7 @@ class case_decrypt_dtls(subprocesstest.SubprocessTestCase): def test_dtls(self, cmd_tshark, capture_file): '''DTLS''' # https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=view&target=snakeoil.tgz - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('snakeoil-dtls.pcap'), '-Tfields', '-e', 'data.data', @@ -91,7 +91,7 @@ class case_decrypt_dtls(subprocesstest.SubprocessTestCase): def test_dtls_psk_aes128ccm8(self, cmd_tshark, capture_file): '''DTLS 1.2 with PSK, AES-128-CCM-8''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dtls12-aes128ccm8.pcap'), '-o', 'dtls.psk:ca19e028a8a372ad2d325f950fcaceed', '-x' @@ -103,7 +103,7 @@ class case_decrypt_dtls(subprocesstest.SubprocessTestCase): def test_dtls_udt(self, cmd_tshark, dirs, capture_file): '''UDT over DTLS 1.2 with RSA key''' key_file = os.path.join(dirs.key_dir, 'udt-dtls.key') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('udt-dtls.pcapng.gz'), '-o', 'dtls.keys_list:0.0.0.0,0,data,{}'.format(key_file), '-Y', 'dtls && udt.type==ack', @@ -117,7 +117,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls(self, cmd_tshark, capture_file): '''TLS using the server's private key''' # https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=view&target=snakeoil2_070531.tgz - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('rsasnakeoil2.pcap'), '-Tfields', '-e', 'http.request.uri', @@ -129,7 +129,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): '''TLS using the server's private key with p < q (test whether libgcrypt is correctly called)''' key_file = os.path.join(dirs.key_dir, 'rsa-p-lt-q.key') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('rsa-p-lt-q.pcap'), '-o', 'tls.keys_list:0.0.0.0,443,http,{}'.format(key_file), '-Tfields', @@ -140,7 +140,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls_with_password(self, cmd_tshark, capture_file): '''TLS using the server's private key with password''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dmgr.pcapng'), '-Tfields', '-e', 'http.request.uri', @@ -151,7 +151,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls_master_secret(self, cmd_tshark, dirs, capture_file): '''TLS using the master secret and ssl.keylog_file preference aliasing''' key_file = os.path.join(dirs.key_dir, 'dhe1_keylog.dat') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dhe1.pcapng.gz'), '-o', 'ssl.keylog_file: {}'.format(key_file), '-o', 'tls.desegment_ssl_application_data: FALSE', @@ -167,7 +167,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls12_renegotiation(self, cmd_tshark, dirs, capture_file): '''TLS 1.2 with renegotiation''' key_file = os.path.join(dirs.key_dir, 'rsasnakeoil2.key') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('tls-renegotiation.pcap'), '-o', 'tls.keys_list:0.0.0.0,4433,http,{}'.format(key_file), '-Tfields', @@ -180,7 +180,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls12_psk_aes128ccm(self, cmd_tshark, capture_file): '''TLS 1.2 with PSK, AES-128-CCM''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('tls12-aes128ccm.pcap'), '-o', 'tls.psk:ca19e028a8a372ad2d325f950fcaceed', '-q', @@ -190,7 +190,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls12_psk_aes256gcm(self, cmd_tshark, capture_file): '''TLS 1.2 with PSK, AES-256-GCM''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('tls12-aes256gcm.pcap'), '-o', 'tls.psk:ca19e028a8a372ad2d325f950fcaceed', '-q', @@ -214,7 +214,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): ] stream = 0 for cipher in ciphers: - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('tls12-chacha20poly1305.pcap'), '-o', 'tls.keylog_file: {}'.format(key_file), '-q', @@ -228,7 +228,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): if not features.have_libgcrypt17: self.skipTest('Requires GCrypt 1.7 or later.') key_file = os.path.join(dirs.key_dir, 'tls13-20-chacha20poly1305.keys') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('tls13-20-chacha20poly1305.pcap'), '-o', 'tls.keylog_file: {}'.format(key_file), '-q', @@ -241,7 +241,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): if not features.have_libgcrypt16: self.skipTest('Requires GCrypt 1.6 or later.') key_file = os.path.join(dirs.key_dir, 'tls13-rfc8446.keys') - proc = self.runProcess((cmd_tshark, + proc = self.assertRun((cmd_tshark, '-r', capture_file('tls13-rfc8446.pcap'), '-otls.keylog_file:{}'.format(key_file), '-Y', 'http', @@ -265,7 +265,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): if not features.have_libgcrypt16: self.skipTest('Requires GCrypt 1.6 or later.') key_file = os.path.join(dirs.key_dir, 'tls13-rfc8446-noearly.keys') - proc = self.runProcess((cmd_tshark, + proc = self.assertRun((cmd_tshark, '-r', capture_file('tls13-rfc8446.pcap'), '-otls.keylog_file:{}'.format(key_file), '-Y', 'http', @@ -285,7 +285,7 @@ class case_decrypt_tls(subprocesstest.SubprocessTestCase): def test_tls12_dsb(self, cmd_tshark, capture_file): '''TLS 1.2 with master secrets in pcapng Decryption Secrets Blocks.''' - output = self.runProcess((cmd_tshark, + output = self.assertRun((cmd_tshark, '-r', capture_file('tls12-dsb.pcapng'), '-Tfields', '-e', 'http.host', @@ -301,7 +301,7 @@ class case_decrypt_zigbee(subprocesstest.SubprocessTestCase): def test_zigbee(self, cmd_tshark, capture_file): '''ZigBee''' # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7022 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('sample_control4_2012-03-24.pcap'), '-Tfields', '-e', 'data.data', @@ -316,7 +316,7 @@ class case_decrypt_ansi_c1222(subprocesstest.SubprocessTestCase): def test_ansi_c1222(self, cmd_tshark, capture_file): '''ANSI C12.22''' # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9196 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('c1222_std_example8.pcap'), '-o', 'c1222.decrypt: TRUE', '-o', 'c1222.baseoid: 2.16.124.113620.1.22.0', @@ -333,7 +333,7 @@ class case_decrypt_dvb_ci(subprocesstest.SubprocessTestCase): '''DVB-CI''' # simplified version of the sample capture in # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6700 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dvb-ci_UV1_0000.pcap'), '-o', 'dvb-ci.sek: 00000000000000000000000000000000', '-o', 'dvb-ci.siv: 00000000000000000000000000000000', @@ -349,7 +349,7 @@ class case_decrypt_ipsec(subprocesstest.SubprocessTestCase): def test_ipsec_esp(self, cmd_tshark, capture_file): '''IPsec ESP''' # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=12671 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('esp-bug-12671.pcapng.gz'), '-o', 'esp.enable_encryption_decode: TRUE', '-Tfields', @@ -364,7 +364,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev1_certs(self, cmd_tshark, capture_file): '''IKEv1 (ISAKMP) with certificates''' # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7951 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev1-certs.pcap'), '-Tfields', '-e', 'x509sat.printableString', @@ -374,7 +374,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev1_simultaneous(self, cmd_tshark, capture_file): '''IKEv1 (ISAKMP) simultaneous exchanges''' # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=12610 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev1-bug-12610.pcapng.gz'), '-Tfields', '-e', 'isakmp.hash', @@ -384,7 +384,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev1_unencrypted(self, cmd_tshark, capture_file): '''IKEv1 (ISAKMP) unencrypted phase 1''' # https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=12620 - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev1-bug-12620.pcapng.gz'), '-Tfields', '-e', 'isakmp.hash', @@ -393,7 +393,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_3des_sha160(self, cmd_tshark, capture_file): '''IKEv2 decryption test (3DES-CBC/SHA1_160)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-3des-sha1_160.pcap'), '-Tfields', '-e', 'isakmp.auth.data', @@ -402,7 +402,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes128_ccm12(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-128-CCM-12) - with CBC-MAC verification''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes128ccm12.pcap'), '-Tfields', '-e', 'isakmp.auth.data', @@ -411,7 +411,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes128_ccm12_2(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-128-CCM-12 using CTR mode, without checksum)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes128ccm12-2.pcap'), '-Tfields', '-e', 'isakmp.auth.data', @@ -420,7 +420,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes192ctr_sha512(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-192-CTR/SHA2-512)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes192ctr.pcap'), '-Tfields', '-e', 'isakmp.auth.data', @@ -429,7 +429,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes256cbc_sha256(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-256-CBC/SHA2-256)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes256cbc.pcapng'), '-Tfields', '-e', 'isakmp.auth.data', @@ -438,7 +438,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes256ccm16(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-256-CCM-16)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes256ccm16.pcapng'), '-Tfields', '-e', 'isakmp.auth.data', @@ -447,7 +447,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes256gcm16(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-256-GCM-16)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes256gcm16.pcap'), '-Tfields', '-e', 'isakmp.auth.data', @@ -456,7 +456,7 @@ class case_decrypt_ike_isakmp(subprocesstest.SubprocessTestCase): def test_ikev2_aes256gcm8(self, cmd_tshark, capture_file): '''IKEv2 decryption test (AES-256-GCM-8)''' - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('ikev2-decrypt-aes256gcm8.pcap'), '-Tfields', '-e', 'isakmp.auth.data', @@ -471,7 +471,7 @@ class case_decrypt_http2(subprocesstest.SubprocessTestCase): '''HTTP2 (HPACK)''' if not features.have_nghttp2: self.skipTest('Requires nghttp2.') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('packet-h2-14_headers.pcapng'), '-Tfields', '-e', 'http2.header.value', @@ -480,7 +480,7 @@ class case_decrypt_http2(subprocesstest.SubprocessTestCase): test_passed = self.grepOutput('nghttp2') if not test_passed: self.log_fd.write('\n\n-- Verbose output --\n\n') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('packet-h2-14_headers.pcapng'), '-V', '-d', 'tcp.port==3000,http2', @@ -497,7 +497,7 @@ class case_decrypt_kerberos(subprocesstest.SubprocessTestCase): if not features.have_kerberos: self.skipTest('Requires kerberos.') keytab_file = os.path.join(dirs.key_dir, 'krb-816.keytab') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('krb-816.pcap.gz'), '-o', 'kerberos.decrypt: TRUE', '-o', 'kerberos.file: {}'.format(keytab_file), @@ -518,7 +518,7 @@ def run_wireguard_test(cmd_tshark, capture_file, features): args += ['-owg.keylog_file:%s' % keylog_file] with open(keylog_file, 'w') as f: f.write("\n".join(keylog)) - proc = self.runProcess([cmd_tshark, '-r', capture_file(pcap_file)] + args) + proc = self.assertRun([cmd_tshark, '-r', capture_file(pcap_file)] + args) lines = proc.stdout_str.splitlines() return lines return runOne @@ -744,7 +744,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): def test_knxip_data_security_decryption_ok(self, cmd_tshark, capture_file): '''KNX/IP: Data Security decryption OK''' # capture_file('knxip_DataSec.pcap') contains KNX/IP ConfigReq DataSec PropExtValueWriteCon telegram - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('knxip_DataSec.pcap'), '-o', 'kip.key_1:00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F', )) @@ -754,7 +754,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): def test_knxip_data_security_decryption_fails(self, cmd_tshark, capture_file): '''KNX/IP: Data Security decryption fails''' # capture_file('knxip_DataSec.pcap') contains KNX/IP ConfigReq DataSec PropExtValueWriteCon telegram - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('knxip_DataSec.pcap'), '-o', 'kip.key_1:""', # "" is really necessary, otherwise test fails )) @@ -764,7 +764,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): def test_knxip_secure_wrapper_decryption_ok(self, cmd_tshark, capture_file): '''KNX/IP: SecureWrapper decryption OK''' # capture_file('knxip_SecureWrapper.pcap') contains KNX/IP SecureWrapper RoutingInd telegram - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('knxip_SecureWrapper.pcap'), '-o', 'kip.key_1:00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F', )) @@ -774,7 +774,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): def test_knxip_secure_wrapper_decryption_fails(self, cmd_tshark, capture_file): '''KNX/IP: SecureWrapper decryption fails''' # capture_file('knxip_SecureWrapper.pcap') contains KNX/IP SecureWrapper RoutingInd telegram - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('knxip_SecureWrapper.pcap'), '-o', 'kip.key_1:""', # "" is really necessary, otherwise test fails )) @@ -784,7 +784,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): def test_knxip_timer_notify_authentication_ok(self, cmd_tshark, capture_file): '''KNX/IP: TimerNotify authentication OK''' # capture_file('knxip_TimerNotify.pcap') contains KNX/IP TimerNotify telegram - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('knxip_TimerNotify.pcap'), '-o', 'kip.key_1:00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F', )) @@ -794,7 +794,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): def test_knxip_timer_notify_authentication_fails(self, cmd_tshark, capture_file): '''KNX/IP: TimerNotify authentication fails''' # capture_file('knxip_TimerNotify.pcap') contains KNX/IP TimerNotify telegram - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('knxip_TimerNotify.pcap'), '-o', 'kip.key_1:""', # "" is really necessary, otherwise test fails )) @@ -807,7 +807,7 @@ class case_decrypt_knxip(subprocesstest.SubprocessTestCase): key_file = os.path.join(dirs.key_dir, 'knx_keyring.xml') # capture_file('empty.pcap') is empty # Write extracted key info to stdout - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-o', 'kip.key_file:' + key_file, '-o', 'kip.key_info_file:-', '-r', capture_file('empty.pcap'), diff --git a/test/suite_dissection.py b/test/suite_dissection.py index dc258a0efd..0da1b17d18 100644 --- a/test/suite_dissection.py +++ b/test/suite_dissection.py @@ -22,7 +22,7 @@ class case_dissect_http2(subprocesstest.SubprocessTestCase): if not features.have_nghttp2: self.skipTest('Requires nghttp2.') key_file = os.path.join(dirs.key_dir, 'http2-data-reassembly.keys') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('http2-data-reassembly.pcap'), '-o', 'tls.keylog_file: {}'.format(key_file), '-d', 'tcp.port==8443,tls', @@ -35,7 +35,7 @@ class case_dissect_http2(subprocesstest.SubprocessTestCase): class case_dissect_tcp(subprocesstest.SubprocessTestCase): def check_tcp_out_of_order(self, cmd_tshark, dirs, extraArgs=[]): capture_file = os.path.join(dirs.capture_dir, 'http-ooo.pcap') - self.runProcess([cmd_tshark, + self.assertRun([cmd_tshark, '-r', capture_file, '-otcp.reassemble_out_of_order:TRUE', '-Y', 'http', @@ -61,7 +61,7 @@ class case_dissect_tcp(subprocesstest.SubprocessTestCase): def test_tcp_out_of_order_twopass_with_bug(self, cmd_tshark, capture_file): # TODO fix the issue below, remove this and enable # "test_tcp_out_of_order_twopass" - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('http-ooo.pcap'), '-otcp.reassemble_out_of_order:TRUE', '-Y', 'http', @@ -81,7 +81,7 @@ class case_dissect_tcp(subprocesstest.SubprocessTestCase): def test_tcp_out_of_order_data_after_syn(self, cmd_tshark, capture_file): '''Test when the first non-empty segment is OoO.''' - proc = self.runProcess((cmd_tshark, + proc = self.assertRun((cmd_tshark, '-r', capture_file('dns-ooo.pcap'), '-otcp.reassemble_out_of_order:TRUE', '-Y', 'dns', '-Tfields', '-edns.qry.name', diff --git a/test/suite_fileformats.py b/test/suite_fileformats.py index 8bf341c1cd..30eeb44d7a 100644 --- a/test/suite_fileformats.py +++ b/test/suite_fileformats.py @@ -34,7 +34,7 @@ def fileformats_baseline_str(dirs): class case_fileformat_pcap(subprocesstest.SubprocessTestCase): def test_pcap_usec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs microsecond pcap stdin''' - capture_proc = self.runProcess(' '.join((cmd_tshark, + capture_proc = self.assertRun(' '.join((cmd_tshark, '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -45,7 +45,7 @@ class case_fileformat_pcap(subprocesstest.SubprocessTestCase): def test_pcap_nsec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs nanosecond pcap stdin''' - capture_proc = self.runProcess(' '.join((cmd_tshark, + capture_proc = self.assertRun(' '.join((cmd_tshark, '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -56,7 +56,7 @@ class case_fileformat_pcap(subprocesstest.SubprocessTestCase): def test_pcap_nsec_direct(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs nanosecond pcap direct''' - capture_proc = self.runProcess((cmd_tshark, + capture_proc = self.assertRun((cmd_tshark, '-r', capture_file('dhcp-nanosecond.pcap'), '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -70,7 +70,7 @@ class case_fileformat_pcap(subprocesstest.SubprocessTestCase): class case_fileformat_pcapng(subprocesstest.SubprocessTestCase): def test_pcapng_usec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs microsecond pcapng stdin''' - capture_proc = self.runProcess(' '.join((cmd_tshark, + capture_proc = self.assertRun(' '.join((cmd_tshark, '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta' @@ -81,7 +81,7 @@ class case_fileformat_pcapng(subprocesstest.SubprocessTestCase): def test_pcapng_usec_direct(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs microsecond pcapng direct''' - capture_proc = self.runProcess((cmd_tshark, + capture_proc = self.assertRun((cmd_tshark, '-r', capture_file('dhcp.pcapng'), '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -91,7 +91,7 @@ class case_fileformat_pcapng(subprocesstest.SubprocessTestCase): def test_pcapng_nsec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs nanosecond pcapng stdin''' - capture_proc = self.runProcess(' '.join((cmd_tshark, + capture_proc = self.assertRun(' '.join((cmd_tshark, '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta' @@ -102,7 +102,7 @@ class case_fileformat_pcapng(subprocesstest.SubprocessTestCase): def test_pcapng_nsec_direct(self, cmd_tshark, capture_file, fileformats_baseline_str): '''Microsecond pcap direct vs nanosecond pcapng direct''' - capture_proc = self.runProcess((cmd_tshark, + capture_proc = self.assertRun((cmd_tshark, '-r', capture_file('dhcp-nanosecond.pcapng'), '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -115,7 +115,7 @@ def check_pcapng_dsb_fields(request, cmd_tshark): '''Factory that checks whether the DSB within the capture file matches.''' self = request.instance def check_dsb_fields_real(outfile, fields): - proc = self.runProcess((cmd_tshark, + proc = self.assertRun((cmd_tshark, '-r', outfile, '-Xread_format:MIME Files Format', '-Tfields', @@ -144,7 +144,7 @@ class case_fileformat_pcapng_dsb(subprocesstest.SubprocessTestCase): dsb_keys1 = os.path.join(dirs.key_dir, 'tls12-dsb-1.keys') dsb_keys2 = os.path.join(dirs.key_dir, 'tls12-dsb-2.keys') outfile = self.filename_from_id('tls12-dsb-same.pcapng') - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('tls12-dsb.pcapng'), '-w', outfile, )) @@ -161,7 +161,7 @@ class case_fileformat_pcapng_dsb(subprocesstest.SubprocessTestCase): '''Insert a single DSB into a pcapng file.''' key_file = os.path.join(dirs.key_dir, 'dhe1_keylog.dat') outfile = self.filename_from_id('dhe1-dsb.pcapng') - self.runProcess((cmd_editcap, + self.assertRun((cmd_editcap, '--inject-secrets', 'tls,%s' % key_file, capture_file('dhe1.pcapng.gz'), outfile )) @@ -176,7 +176,7 @@ class case_fileformat_pcapng_dsb(subprocesstest.SubprocessTestCase): key_file1 = os.path.join(dirs.key_dir, 'dhe1_keylog.dat') key_file2 = os.path.join(dirs.key_dir, 'http2-data-reassembly.keys') outfile = self.filename_from_id('dhe1-dsb.pcapng') - self.runProcess((cmd_editcap, + self.assertRun((cmd_editcap, '--inject-secrets', 'tls,%s' % key_file1, '--inject-secrets', 'tls,%s' % key_file2, capture_file('dhe1.pcapng.gz'), outfile @@ -196,7 +196,7 @@ class case_fileformat_pcapng_dsb(subprocesstest.SubprocessTestCase): dsb_keys2 = os.path.join(dirs.key_dir, 'tls12-dsb-2.keys') key_file = os.path.join(dirs.key_dir, 'dhe1_keylog.dat') outfile = self.filename_from_id('tls12-dsb-extra.pcapng') - self.runProcess((cmd_editcap, + self.assertRun((cmd_editcap, '--inject-secrets', 'tls,%s' % key_file, capture_file('tls12-dsb.pcapng'), outfile )) @@ -221,7 +221,7 @@ class case_fileformat_pcapng_dsb(subprocesstest.SubprocessTestCase): class case_fileformat_mime(subprocesstest.SubprocessTestCase): def test_mime_pcapng_gz(self, cmd_tshark, capture_file): '''Test that the full uncompressed contents is shown.''' - proc = self.runProcess((cmd_tshark, + proc = self.assertRun((cmd_tshark, '-r', capture_file('icmp.pcapng.gz'), '-Xread_format:MIME Files Format', '-Tfields', '-e', 'frame.len', '-e', 'pcapng.block.length', diff --git a/test/suite_follow.py b/test/suite_follow.py index 3144bce43b..1e3df4f808 100644 --- a/test/suite_follow.py +++ b/test/suite_follow.py @@ -27,7 +27,7 @@ class case_follow_tcp(subprocesstest.SubprocessTestCase): # 6. lost but acked segments # 7. lost 3/5 fragments, but acked # Not checked: lost and not acked (currently truncated, is that OK?) - proc = self.runProcess((cmd_tshark, + proc = self.assertRun((cmd_tshark, '-r', capture_file('tcp-badsegments.pcap'), '-qz', 'follow,tcp,hex,0', )) 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)) diff --git a/test/suite_mergecap.py b/test/suite_mergecap.py index 8e733c0976..1c031c8150 100644 --- a/test/suite_mergecap.py +++ b/test/suite_mergecap.py @@ -78,7 +78,7 @@ class case_mergecap_pcap(subprocesstest.SubprocessTestCase): '''Merge a single pcap file to pcap''' # $MERGECAP -vF pcap -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcap) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-F', 'pcap', '-w', testout_file, @@ -90,7 +90,7 @@ class case_mergecap_pcap(subprocesstest.SubprocessTestCase): '''Merge two pcap files to pcap''' # $MERGECAP -vF pcap -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcap) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-F', 'pcap', '-w', testout_file, @@ -102,7 +102,7 @@ class case_mergecap_pcap(subprocesstest.SubprocessTestCase): '''Merge three pcap files to pcap, two empty''' # $MERGECAP -vF pcap -w testout.pcap "${CAPTURE_DIR}empty.pcap" "${CAPTURE_DIR}dhcp.pcap" "${CAPTURE_DIR}empty.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcap) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-F', 'pcap', '-w', testout_file, @@ -114,7 +114,7 @@ class case_mergecap_pcap(subprocesstest.SubprocessTestCase): '''Merge two pcap files to pcap, one with nanosecond timestamps''' # $MERGECAP -vF pcap -w testout.pcap "${CAPTURE_DIR}dhcp-nanosecond.pcap" "${CAPTURE_DIR}rsasnakeoil2.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcap) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-F', 'pcap', '-w', testout_file, @@ -130,7 +130,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge a single pcap file to pcapng''' # $MERGECAP -v -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-w', testout_file, capture_file('dhcp.pcap'), @@ -141,7 +141,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge two pcap files to pcapng''' # $MERGECAP -v -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-w', testout_file, capture_file('dhcp.pcap'), capture_file('dhcp.pcap'), @@ -152,7 +152,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge two pcap files to pcapng, "none" merge mode''' # $MERGECAP -vI 'none' -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-I', 'none', '-w', testout_file, @@ -164,7 +164,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge two pcap files to pcapng, "all" merge mode''' # $MERGECAP -vI 'all' -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-I', 'all', '-w', testout_file, @@ -176,7 +176,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge two pcap files to pcapng, "any" merge mode''' # $MERGECAP -vI 'any' -w testout.pcap "${CAPTURE_DIR}dhcp.pcap" "${CAPTURE_DIR}dhcp.pcap" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-I', 'any', '-w', testout_file, @@ -188,7 +188,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge a single pcapng file to pcapng''' # $MERGECAP -v -w testout.pcap "${CAPTURE_DIR}dhcp.pcapng" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-w', testout_file, capture_file('dhcp.pcapng'), @@ -199,7 +199,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge one pcapng file with many interfaces to pcapng''' # $MERGECAP -v -w testout.pcap "${CAPTURE_DIR}many_interfaces.pcapng.1" > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-w', testout_file, capture_file('many_interfaces.pcapng.1'), @@ -210,7 +210,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge multiple pcapng files with many interfaces to pcapng''' # $MERGECAP -v -w testout.pcap "${CAPTURE_DIR}"many_interfaces.pcapng* > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-w', testout_file, capture_file('many_interfaces.pcapng.1'), @@ -223,7 +223,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): '''Merge multiple pcapng files with many interfaces to pcapng, "none" merge mode''' # $MERGECAP -vI 'none' -w testout.pcap "${CAPTURE_DIR}"many_interfaces.pcapng* > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-I', 'none', '-w', testout_file, @@ -251,7 +251,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): # and use that generated pcap for our test # $MERGECAP -vI 'all' -w testout.pcap ./testin.pcap ./testin.pcap ./testin.pcap > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-I', 'all', '-w', testout_file, @@ -278,7 +278,7 @@ class case_mergecap_pcapng(subprocesstest.SubprocessTestCase): # and use that generated pcap for our test # $MERGECAP -vI 'any' -w testout.pcap ./testin.pcap ./testin.pcap ./testin.pcap > testout.txt 2>&1 testout_file = self.filename_from_id(testout_pcapng) - mergecap_proc = self.runProcess((cmd_mergecap, + mergecap_proc = self.assertRun((cmd_mergecap, '-v', '-I', 'any', '-w', testout_file, diff --git a/test/suite_nameres.py b/test/suite_nameres.py index 3fb38d98c3..340639ae3c 100644 --- a/test/suite_nameres.py +++ b/test/suite_nameres.py @@ -107,7 +107,7 @@ class case_name_resolution(subprocesstest.SubprocessTestCase): check_name_resolution(self, True, False, True, True, 'custom-4-2-2-2') def test_hosts_any(self, cmd_tshark, capture_file): - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dns+icmp.pcapng.gz'), '-qz', 'hosts', )) @@ -115,7 +115,7 @@ class case_name_resolution(subprocesstest.SubprocessTestCase): self.assertTrue(self.grepOutput('fe80::6233:4bff:fe13:c558\tCrunch.local')) def test_hosts_ipv4(self, cmd_tshark, capture_file): - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dns+icmp.pcapng.gz'), '-qz', 'hosts,ipv4', )) @@ -123,7 +123,7 @@ class case_name_resolution(subprocesstest.SubprocessTestCase): self.assertFalse(self.grepOutput('fe80::6233:4bff:fe13:c558\tCrunch.local')) def test_hosts_ipv6(self, cmd_tshark, capture_file): - self.runProcess((cmd_tshark, + self.assertRun((cmd_tshark, '-r', capture_file('dns+icmp.pcapng.gz'), '-qz', 'hosts,ipv6', )) |