summaryrefslogtreecommitdiffstats
path: root/test/suite_clopts.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/suite_clopts.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/test/suite_clopts.py b/test/suite_clopts.py
index 55686b2c..c63982f8 100644
--- a/test/suite_clopts.py
+++ b/test/suite_clopts.py
@@ -27,7 +27,7 @@ class TestDumpcapOptions:
# XXX Should we generate individual test functions instead of looping?
def test_dumpcap_invalid_chars(self, cmd_dumpcap, base_env):
'''Invalid dumpcap parameters'''
- for char_arg in 'CEFGHJKNOQRTUVWXYejloxz':
+ for char_arg in 'CEFGHJKNORTUVWXYejloxz':
process = subprocesstest.run((cmd_dumpcap, '-' + char_arg), env=base_env)
assert process.returncode == ExitCodes.COMMAND_LINE
@@ -79,6 +79,12 @@ class TestBasicClopts:
process = subprocesstest.run((cmd_tshark, '-r', capture_file('dhcp.pcap')), env=test_env)
assert process.returncode == ExitCodes.OK
+ def test_existing_file_longopt(self, cmd_tshark, capture_file, test_env):
+ # $TSHARK -r "${CAPTURE_DIR}dhcp.pcap" > ./testout.txt 2>&1
+ process = subprocesstest.run((cmd_tshark, '--read-file', capture_file('dhcp.pcap'),
+ '--display-filter', 'dhcp'), env=test_env)
+ assert process.returncode == ExitCodes.OK
+
def test_nonexistent_file(self, cmd_tshark, capture_file, test_env):
# $TSHARK - r ThisFileDontExist.pcap > ./testout.txt 2 > &1
process = subprocesstest.run((cmd_tshark, '-r', capture_file('__ceci_nest_pas_une.pcap')), env=test_env)
@@ -104,7 +110,7 @@ class TestTsharkOptions:
'''Valid tshark parameters requiring capture permissions'''
# These options require dumpcap, but may fail with a pacp error
# if WinPcap or Npcap are not present
- valid_returns = [ExitCodes.OK, ExitCodes.PCAP_ERROR, ExitCodes.INVALID_CAPABILITY]
+ valid_returns = [ExitCodes.OK, ExitCodes.PCAP_ERROR, ExitCodes.INVALID_CAPABILITY, ExitCodes.INVALID_INTERFACE]
for char_arg in 'DL':
process = subprocesstest.run((cmd_tshark, '-' + char_arg), env=test_env)
assert process.returncode in valid_returns
@@ -320,7 +326,19 @@ class TestTsharkExtcap:
os.makedirs(extcap_dir_path)
test_env['WIRESHARK_EXTCAP_DIR'] = extcap_dir_path
source_file = os.path.join(os.path.dirname(__file__), 'sampleif.py')
- shutil.copy2(source_file, extcap_dir_path)
+ # We run our tests in a bare, reproducible home environment. This can result in an
+ # invalid or missing Python interpreter if our main environment has a wonky Python
+ # path, as is the case in the GitLab SaaS macOS runners which use `asdf`. Force
+ # sampleif.py to use our current Python executable.
+ with open(source_file, 'r') as sf:
+ sampleif_py = sf.read()
+ sampleif_py = sampleif_py.replace('/usr/bin/env python3', sys.executable)
+ sys.stderr.write(sampleif_py)
+ extcap_file = os.path.join(extcap_dir_path, 'sampleif.py')
+ with open(extcap_file, 'w') as ef:
+ ef.write(sampleif_py)
+ os.fchmod(ef.fileno(), os.fstat(sf.fileno()).st_mode)
+
# Ensure the test extcap_tool is properly loaded
proc = subprocesstest.run((cmd_tshark, '-D'), capture_output=True, env=test_env)
assert count_output(proc.stdout, 'sampleif') == 1