Skip to content

Commit

Permalink
Test: Change the capture used for expert info testing
Browse files Browse the repository at this point in the history
The http2-data-reassembly.pcap has Errors, Warnings, Notes,
and Chats when TCP checksum verification is turned on, which
allows for somewhat greater test coverage here.

In the future, we might want to make fragment_add set the
overlap flags instead of throwing a ReassemblyError for
retransmissions after a ressembly is complete, which would
make the current test fail.
  • Loading branch information
johnthacker authored and AndersBroman committed Sep 10, 2023
1 parent d186a42 commit 48edbe1
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions test/suite_clopts.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,37 +219,49 @@ def test_tshark_unicode_folders(self, cmd_tshark, unicode_env, features):
class TestTsharkZExpert:
def test_tshark_z_expert_all(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert',
'-r', capture_file('http-ooo.pcap')), capture_output=True, env=test_env)
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
# http2-data-reassembly.pcap has Errors, Warnings, Notes, and Chats
# when TCP checksum are verified.
assert grep_output(proc.stdout, 'Errors')
assert grep_output(proc.stdout, 'Warns')
assert grep_output(proc.stdout, 'Notes')
assert grep_output(proc.stdout, 'Chats')

def test_tshark_z_expert_error(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,error',
'-r', capture_file('http-ooo.pcap')), capture_output=True, env=test_env)
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
assert grep_output(proc.stdout, 'Errors')
assert not grep_output(proc.stdout, 'Warns')
assert not grep_output(proc.stdout, 'Notes')
assert not grep_output(proc.stdout, 'Chats')

def test_tshark_z_expert_warn(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,warn',
'-r', capture_file('http-ooo.pcap')), capture_output=True, env=test_env)
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
assert grep_output(proc.stdout, 'Errors')
assert grep_output(proc.stdout, 'Warns')
assert not grep_output(proc.stdout, 'Notes')
assert not grep_output(proc.stdout, 'Chats')

def test_tshark_z_expert_note(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,note',
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
assert grep_output(proc.stdout, 'Errors')
assert grep_output(proc.stdout, 'Warns')
assert grep_output(proc.stdout, 'Notes')
assert not grep_output(proc.stdout, 'Chats')

def test_tshark_z_expert_chat(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,chat',
'-r', capture_file('http-ooo.pcap')), capture_output=True, env=test_env)
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
assert grep_output(proc.stdout, 'Errors')
assert grep_output(proc.stdout, 'Warns')
assert grep_output(proc.stdout, 'Notes')
assert grep_output(proc.stdout, 'Chats')

def test_tshark_z_expert_comment(self, cmd_tshark, capture_file, test_env):
Expand All @@ -273,17 +285,25 @@ def test_tshark_z_expert_error_invalid_filter(self, cmd_tshark, capture_file, te
assert grep_output(proc.stdout, 'Filter "' + invalid_filter + '" is invalid')

def test_tshark_z_expert_filter(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,udp', # udp is a filter
'-r', capture_file('http-ooo.pcap')), capture_output=True, env=test_env)
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,udp',
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
# Filtering for UDP should produce no expert infos.
assert not grep_output(proc.stdout, 'Errors')
assert not grep_output(proc.stdout, 'Warns')
assert not grep_output(proc.stdout, 'Notes')
assert not grep_output(proc.stdout, 'Chats')

def test_tshark_z_expert_error_filter(self, cmd_tshark, capture_file, test_env):
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,error,udp', # udp is a filter
'-r', capture_file('http-ooo.pcap')), capture_output=True, env=test_env)
assert not grep_output(proc.stdout, 'Errors')
proc = subprocesstest.run((cmd_tshark, '-q', '-z', 'expert,warn,tls', # tls is a filter
'-o', 'tcp.check_checksum:TRUE',
'-r', capture_file('http2-data-reassembly.pcap')), capture_output=True, env=test_env)
# Filtering for TLS should produce only Error level expert infos
# with checksumming turned on, because the lower level expert infos
# are on the packets with TCP but not TLS.
assert grep_output(proc.stdout, 'Errors')
assert not grep_output(proc.stdout, 'Warns')
assert not grep_output(proc.stdout, 'Notes')
assert not grep_output(proc.stdout, 'Chats')


Expand Down

0 comments on commit 48edbe1

Please sign in to comment.