aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2018-04-27 09:35:37 -0700
committerGerald Combs <gerald@wireshark.org>2018-04-27 17:15:19 +0000
commit9b3be1711f2a92ed4c59e32961d4d19b8f593d94 (patch)
tree8e5b5d878c367df09261a17282ddc6c453ba3aa6 /test
parent662210f3d5c631f30b476ed2fcd9ab81d0dfd080 (diff)
test: Miscellaneous fixups.
In util_slow_dhcp.py, open stdout as O_BINARY on Windows. Have ctest pass --verbose to test.py. Call config.canCapture at test time so that we don't inadvertently skip some tests. Stringify our dumpcap config check. Fix our Gcrypt variable. Change-Id: I884ec23ddfc7c28b79d4a860c6c43c308598e6db Reviewed-on: https://code.wireshark.org/review/27182 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'test')
-rw-r--r--test/config.py9
-rw-r--r--test/suite_capture.py2
-rw-r--r--test/suite_clopts.py21
-rw-r--r--test/util_slow_dhcp_pcap.py4
4 files changed, 25 insertions, 11 deletions
diff --git a/test/config.py b/test/config.py
index 78c2bffd4e..e767a4aa10 100644
--- a/test/config.py
+++ b/test/config.py
@@ -50,6 +50,8 @@ key_dir = os.path.join(this_dir, 'keys')
lua_dir = os.path.join(this_dir, 'lua')
def canCapture():
+ # XXX This appears to be evaluated at the wrong time when called
+ # from a unittest.skipXXX decorator.
return can_capture and capture_interface is not None
def setCanCapture(new_cc):
@@ -57,6 +59,7 @@ def setCanCapture(new_cc):
def setCaptureInterface(iface):
global capture_interface
+ setCanCapture(True)
capture_interface = iface
def canMkfifo():
@@ -87,7 +90,7 @@ def getTsharkInfo():
if re.search('(with +MIT +Kerberos|with +Heimdal +Kerberos)', tshark_v):
have_kerberos = True
gcry_m = re.search('with +Gcrypt +([0-9]+\.[0-9]+)', tshark_v)
- have_libgcrypt = gcry_m and float(gcry_m.group(1)) >= 1.7
+ have_libgcrypt17 = gcry_m and float(gcry_m.group(1)) >= 1.7
except:
pass
@@ -101,8 +104,8 @@ def getDefaultCaptureInterface():
if not sys.platform.startswith('win32'):
return
try:
- dumpcap_d = subprocess.check_output((cmd_dumpcap, '-D'), stderr=subprocess.PIPE)
- for d_line in dumpcap_d.splitlines():
+ dumpcap_d_blob = str(subprocess.check_output((cmd_dumpcap, '-D'), stderr=subprocess.PIPE))
+ for d_line in dumpcap_d_blob.splitlines():
iface_m = re.search('(\d+)\..*(Ethernet|Network Connection|VMware|Intel)', d_line)
if iface_m:
capture_interface = iface_m.group(1)
diff --git a/test/suite_capture.py b/test/suite_capture.py
index a6f7e17163..ff6804f5df 100644
--- a/test/suite_capture.py
+++ b/test/suite_capture.py
@@ -42,7 +42,7 @@ def slow_dhcp_command():
# XXX Do this in Python in a thread?
sd_cmd = ''
if sys.executable:
- sd_cmd = sys.executable + ' '
+ sd_cmd = '"{}" '.format(sys.executable)
sd_cmd += os.path.join(config.this_dir, 'util_slow_dhcp_pcap.py')
return sd_cmd
diff --git a/test/suite_clopts.py b/test/suite_clopts.py
index 37165852d5..3516d5fa36 100644
--- a/test/suite_clopts.py
+++ b/test/suite_clopts.py
@@ -45,25 +45,28 @@ class case_dumpcap_invalid_interface_chars(subprocesstest.SubprocessTestCase):
class case_dumpcap_capture_clopts(subprocesstest.SubprocessTestCase):
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_dumpcap_invalid_capfilter(self):
'''Invalid capture filter'''
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
invalid_filter = '__invalid_protocol'
# $DUMPCAP -f 'jkghg' -w './testout.pcap' > ./testout.txt 2>&1
self.runProcess((config.cmd_dumpcap, '-f', invalid_filter, '-w', 'testout.pcap' ))
self.assertTrue(self.grepOutput('Invalid capture filter "' + invalid_filter + '" for interface'))
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_dumpcap_invalid_interface_name(self):
'''Invalid capture interface name'''
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
invalid_interface = '__invalid_interface'
# $DUMPCAP -i invalid_interface -w './testout.pcap' > ./testout.txt 2>&1
self.runProcess((config.cmd_dumpcap, '-i', invalid_interface, '-w', 'testout.pcap'))
self.assertTrue(self.grepOutput('The capture session could not be initiated'))
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_dumpcap_invalid_interface_index(self):
'''Invalid capture interface index'''
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
invalid_index = '0'
# $DUMPCAP -i 0 -w './testout.pcap' > ./testout.txt 2>&1
self.runProcess((config.cmd_dumpcap, '-i', invalid_index, '-w', 'testout.pcap'))
@@ -110,25 +113,28 @@ class case_tshark_invalid_interface_chars(subprocesstest.SubprocessTestCase):
class case_tshark_capture_clopts(subprocesstest.SubprocessTestCase):
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_tshark_invalid_capfilter(self):
'''Invalid capture filter'''
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
invalid_filter = '__invalid_protocol'
# $TSHARK -f 'jkghg' -w './testout.pcap' > ./testout.txt 2>&1
self.runProcess((config.cmd_tshark, '-f', invalid_filter, '-w', 'testout.pcap' ))
self.assertTrue(self.grepOutput('Invalid capture filter "' + invalid_filter + '" for interface'))
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_tshark_invalid_interface_name(self):
'''Invalid capture interface name'''
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
invalid_interface = '__invalid_interface'
# $TSHARK -i invalid_interface -w './testout.pcap' > ./testout.txt 2>&1
self.runProcess((config.cmd_tshark, '-i', invalid_interface, '-w', 'testout.pcap'))
self.assertTrue(self.grepOutput('The capture session could not be initiated'))
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_tshark_invalid_interface_index(self):
'''Invalid capture interface index'''
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
invalid_index = '0'
# $TSHARK -i 0 -w './testout.pcap' > ./testout.txt 2>&1
self.runProcess((config.cmd_tshark, '-i', invalid_index, '-w', 'testout.pcap'))
@@ -136,8 +142,9 @@ class case_tshark_capture_clopts(subprocesstest.SubprocessTestCase):
class case_tshark_name_resolution_clopts(subprocesstest.SubprocessTestCase):
- @unittest.skipUnless(config.canCapture(), 'Test requires capture privileges')
def test_tshark_valid_name_resolution(self):
+ if not config.canCapture():
+ self.skipTest('Test requires capture privileges and an interface.')
# $TSHARK -N mntC -a duration:1 > ./testout.txt 2>&1
self.assertRun((config.cmd_tshark, '-N', 'mntC', '-a', 'duration: 1'))
diff --git a/test/util_slow_dhcp_pcap.py b/test/util_slow_dhcp_pcap.py
index 0adff51aff..c0a34e6d54 100644
--- a/test/util_slow_dhcp_pcap.py
+++ b/test/util_slow_dhcp_pcap.py
@@ -14,6 +14,10 @@ import os.path
import time
import sys
+if sys.version_info[0] < 3 and sys.platform == "win32":
+ import msvcrt
+ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
+
dhcp_pcap = os.path.join(os.path.dirname(__file__), 'captures', 'dhcp.pcap')
dhcp_fd = open(dhcp_pcap, 'rb')