aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2018-05-03 12:05:12 -0700
committerGerald Combs <gerald@wireshark.org>2018-05-04 22:44:32 +0000
commit7591ed848e862d6f6f91d7398a1b98c4e5dea0fa (patch)
tree91da5400332fb46fe94246b746a59c943314142d
parent8db1616ec382ca8eca3c6059fdfa32378a7918fb (diff)
Test: Add dftest to our tests.
Move the dfilter tests and captures from tools to test. Change-Id: I2e6a6cc1d383c985ba07c76c93ae1c57d3c8f84c Reviewed-on: https://code.wireshark.org/review/27339 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--test/captures/arp.pcap (renamed from tools/dftestfiles/arp.pcap)bin70 -> 70 bytes
-rw-r--r--test/captures/http.pcap (renamed from tools/dftestfiles/http.pcap)bin247 -> 247 bytes
-rw-r--r--test/captures/ipv6.pcap (renamed from tools/dftestfiles/ipv6.pcap)bin126 -> 126 bytes
-rw-r--r--test/captures/ipx_rip.pcap (renamed from tools/dftestfiles/ipx_rip.pcap)bin100 -> 100 bytes
-rw-r--r--test/captures/nfs.pcap (renamed from tools/dftestfiles/nfs.pcap)bin418 -> 418 bytes
-rw-r--r--test/captures/ntp.pcap (renamed from tools/dftestfiles/ntp.pcap)bin130 -> 130 bytes
-rw-r--r--test/captures/tftp.pcap (renamed from tools/dftestfiles/tftp.pcap)bin117 -> 117 bytes
-rw-r--r--test/config.py1
-rw-r--r--test/subprocesstest.py19
-rw-r--r--test/suite_clopts.py1
-rw-r--r--test/suite_dfilter/__init__.py14
-rw-r--r--test/suite_dfilter/dfiltertest.py36
-rw-r--r--test/suite_dfilter/group_bytes_ether.py (renamed from tools/dftestlib/bytes_ether.py)4
-rw-r--r--test/suite_dfilter/group_bytes_ipv6.py (renamed from tools/dftestlib/bytes_ipv6.py)4
-rw-r--r--test/suite_dfilter/group_bytes_type.py (renamed from tools/dftestlib/bytes_type.py)5
-rw-r--r--test/suite_dfilter/group_double.py (renamed from tools/dftestlib/double.py)5
-rw-r--r--test/suite_dfilter/group_integer.py (renamed from tools/dftestlib/integer.py)5
-rw-r--r--test/suite_dfilter/group_integer_1byte.py (renamed from tools/dftestlib/integer_1byte.py)4
-rw-r--r--test/suite_dfilter/group_ipv4.py (renamed from tools/dftestlib/ipv4.py)4
-rw-r--r--test/suite_dfilter/group_membership.py (renamed from tools/dftestlib/membership.py)5
-rw-r--r--test/suite_dfilter/group_range_method.py (renamed from tools/dftestlib/range_method.py)5
-rw-r--r--test/suite_dfilter/group_scanner.py (renamed from tools/dftestlib/scanner.py)5
-rw-r--r--test/suite_dfilter/group_string_type.py (renamed from tools/dftestlib/string_type.py)5
-rw-r--r--test/suite_dfilter/group_stringz.py (renamed from tools/dftestlib/stringz.py)5
-rw-r--r--test/suite_dfilter/group_time_relative.py (renamed from tools/dftestlib/time_relative.py)5
-rw-r--r--test/suite_dfilter/group_time_type.py (renamed from tools/dftestlib/time_type.py)10
-rw-r--r--test/suite_dfilter/group_tvb.py (renamed from tools/dftestlib/tvb.py)5
-rw-r--r--test/suite_dfilter/group_uint64.py (renamed from tools/dftestlib/uint64.py)5
-rwxr-xr-xtest/test.py2
-rwxr-xr-xtools/dfilter-test.py35
-rw-r--r--tools/dftestlib/__init__.py4
-rw-r--r--tools/dftestlib/dftest.py79
-rw-r--r--tools/dftestlib/util.py34
33 files changed, 100 insertions, 206 deletions
diff --git a/tools/dftestfiles/arp.pcap b/test/captures/arp.pcap
index f9fca0c1f6..f9fca0c1f6 100644
--- a/tools/dftestfiles/arp.pcap
+++ b/test/captures/arp.pcap
Binary files differ
diff --git a/tools/dftestfiles/http.pcap b/test/captures/http.pcap
index 145c2b05dc..145c2b05dc 100644
--- a/tools/dftestfiles/http.pcap
+++ b/test/captures/http.pcap
Binary files differ
diff --git a/tools/dftestfiles/ipv6.pcap b/test/captures/ipv6.pcap
index bdfb72ce71..bdfb72ce71 100644
--- a/tools/dftestfiles/ipv6.pcap
+++ b/test/captures/ipv6.pcap
Binary files differ
diff --git a/tools/dftestfiles/ipx_rip.pcap b/test/captures/ipx_rip.pcap
index 89533cb14d..89533cb14d 100644
--- a/tools/dftestfiles/ipx_rip.pcap
+++ b/test/captures/ipx_rip.pcap
Binary files differ
diff --git a/tools/dftestfiles/nfs.pcap b/test/captures/nfs.pcap
index e71d80be74..e71d80be74 100644
--- a/tools/dftestfiles/nfs.pcap
+++ b/test/captures/nfs.pcap
Binary files differ
diff --git a/tools/dftestfiles/ntp.pcap b/test/captures/ntp.pcap
index 815ed719f9..815ed719f9 100644
--- a/tools/dftestfiles/ntp.pcap
+++ b/test/captures/ntp.pcap
Binary files differ
diff --git a/tools/dftestfiles/tftp.pcap b/test/captures/tftp.pcap
index f88c22a055..f88c22a055 100644
--- a/tools/dftestfiles/tftp.pcap
+++ b/test/captures/tftp.pcap
Binary files differ
diff --git a/test/config.py b/test/config.py
index 0ff2698d06..cffa59fb69 100644
--- a/test/config.py
+++ b/test/config.py
@@ -203,6 +203,7 @@ def setUpTestEnvironment():
# Set up our environment
test_env = os.environ.copy()
test_env['WIRESHARK_RUN_FROM_BUILD_DIRECTORY'] = '1'
+ test_env['TZ'] = 'UTC'
test_env[home_env] = home_path
def setUpUatFile(conf_file):
diff --git a/test/subprocesstest.py b/test/subprocesstest.py
index cfef797280..61bab5f970 100644
--- a/test/subprocesstest.py
+++ b/test/subprocesstest.py
@@ -221,21 +221,32 @@ class SubprocessTestCase(unittest.TestCase):
got_num_packets = True
self.assertTrue(got_num_packets, 'Failed to capture exactly {} packets'.format(num_packets))
- def countOutput(self, search_pat, proc=None):
+ def countOutput(self, search_pat=None, count_stdout=True, count_stderr=False, proc=None):
'''Returns the number of output lines (search_pat=None), otherwise returns a match count.'''
match_count = 0
+ self.assertTrue(count_stdout or count_stderr, 'No output to count.')
+
if proc is None:
proc = self.processes[-1]
- # We might want to let the caller decide what we're searching.
- out_data = proc.stdout_str + proc.stderr_str
+
+ out_data = u''
+ if count_stdout:
+ out_data = proc.stdout_str
+ if count_stderr:
+ out_data += proc.stderr_str
+
+ if search_pat is None:
+ return len(out_data.splitlines())
+
search_re = re.compile(search_pat)
for line in out_data.splitlines():
if search_re.search(line):
match_count += 1
+
return match_count
def grepOutput(self, search_pat, proc=None):
- return self.countOutput(search_pat, proc) > 0
+ return self.countOutput(search_pat, count_stderr=True, proc=proc) > 0
def diffOutput(self, blob_a, blob_b, *args, **kwargs):
'''Check for differences between blob_a and blob_b. Return False and log a unified diff if they differ.
diff --git a/test/suite_clopts.py b/test/suite_clopts.py
index 894a3ceef7..51fee661e7 100644
--- a/test/suite_clopts.py
+++ b/test/suite_clopts.py
@@ -166,6 +166,7 @@ class case_tshark_dump_glossaries(subprocesstest.SubprocessTestCase):
except:
pass
self.assertRun((config.cmd_tshark, '-G', glossary))
+ self.assertEqual(self.countOutput(count_stdout=False, count_stderr=True), 0, 'Found error output while printing glossary ' + glossary)
def test_tshark_glossary_valid_utf8(self):
for glossary in glossaries:
diff --git a/test/suite_dfilter/__init__.py b/test/suite_dfilter/__init__.py
new file mode 100644
index 0000000000..6fb259ec50
--- /dev/null
+++ b/test/suite_dfilter/__init__.py
@@ -0,0 +1,14 @@
+#
+# Copyright (C) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os.path
+import unittest
+
+# Run by unittest.defaultTestLoader.discover in test.py
+def load_tests(loader, standard_tests, pattern):
+ this_dir = os.path.dirname(__file__)
+ package_tests = loader.discover(start_dir=this_dir, pattern='group_*.py')
+ standard_tests.addTests(package_tests)
+ return standard_tests
diff --git a/test/suite_dfilter/dfiltertest.py b/test/suite_dfilter/dfiltertest.py
new file mode 100644
index 0000000000..8ac1786ec8
--- /dev/null
+++ b/test/suite_dfilter/dfiltertest.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import config
+import os.path
+import subprocesstest
+
+class DFTestCase(subprocesstest.SubprocessTestCase):
+ """Base class for all tests in this dfilter-test collection."""
+
+
+ def runDFilter(self, dfilter, expected_return=0):
+ # Create the tshark command
+ return self.assertRun((config.cmd_tshark,
+ "-n", # No name resolution
+ "-r", # Next arg is trace file to read
+ os.path.join(config.capture_dir, self.trace_file),
+ "-Y", # packet display filter (used to be -R)
+ dfilter
+ ), expected_return=expected_return)
+
+
+ def assertDFilterCount(self, dfilter, expected_count):
+ """Run a display filter and expect a certain number of packets."""
+
+ dfilter_proc = self.runDFilter(dfilter)
+
+ dfp_count = self.countOutput()
+ msg = "Expected %d, got: %s" % (expected_count, dfp_count)
+ self.assertEqual(dfp_count, expected_count, msg)
+
+ def assertDFilterFail(self, dfilter):
+ """Run a display filter and expect tshark to fail"""
+
+ dfilter_proc = self.runDFilter(dfilter, expected_return=self.exit_error)
diff --git a/tools/dftestlib/bytes_ether.py b/test/suite_dfilter/group_bytes_ether.py
index cf479d2dff..71f8d484e0 100644
--- a/tools/dftestlib/bytes_ether.py
+++ b/test/suite_dfilter/group_bytes_ether.py
@@ -2,9 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
-from dftestlib import dftest
+import dfiltertest
-class testBytesEther(dftest.DFTest):
+class case_bytes_ether(dfiltertest.DFTestCase):
trace_file = "ipx_rip.pcap"
### Note: Bytes test does not yet test FT_INT64.
diff --git a/tools/dftestlib/bytes_ipv6.py b/test/suite_dfilter/group_bytes_ipv6.py
index 8dd88994bd..94237aa26c 100644
--- a/tools/dftestlib/bytes_ipv6.py
+++ b/test/suite_dfilter/group_bytes_ipv6.py
@@ -2,9 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
-from dftestlib import dftest
+import dfiltertest
-class testBytesIPv6(dftest.DFTest):
+class case_bytes_ipv6(dfiltertest.DFTestCase):
trace_file = "ipv6.pcap"
def test_eq_1(self):
diff --git a/tools/dftestlib/bytes_type.py b/test/suite_dfilter/group_bytes_type.py
index 3c0b648b85..4031d27956 100644
--- a/tools/dftestlib/bytes_type.py
+++ b/test/suite_dfilter/group_bytes_type.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testBytes(dftest.DFTest):
+class case_bytes_type(dfiltertest.DFTestCase):
trace_file = "arp.pcap"
def test_bytes_1(self):
diff --git a/tools/dftestlib/double.py b/test/suite_dfilter/group_double.py
index 123e0b576f..3bf7cb6083 100644
--- a/tools/dftestlib/double.py
+++ b/test/suite_dfilter/group_double.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testDouble(dftest.DFTest):
+class case_double(dfiltertest.DFTestCase):
trace_file = "ntp.pcap"
diff --git a/tools/dftestlib/integer.py b/test/suite_dfilter/group_integer.py
index d47e837851..42901fb1ea 100644
--- a/tools/dftestlib/integer.py
+++ b/test/suite_dfilter/group_integer.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testInteger(dftest.DFTest):
+class case_integer(dfiltertest.DFTestCase):
trace_file = "ntp.pcap"
def test_eq_1(self):
diff --git a/tools/dftestlib/integer_1byte.py b/test/suite_dfilter/group_integer_1byte.py
index 0dae75698b..be8ba198e8 100644
--- a/tools/dftestlib/integer_1byte.py
+++ b/test/suite_dfilter/group_integer_1byte.py
@@ -3,9 +3,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
-from dftestlib import dftest
+import dfiltertest
-class testInteger1Byte(dftest.DFTest):
+class case_integer_1_byte(dfiltertest.DFTestCase):
trace_file = "ipx_rip.pcap"
diff --git a/tools/dftestlib/ipv4.py b/test/suite_dfilter/group_ipv4.py
index c32e7fbf94..33a996f259 100644
--- a/tools/dftestlib/ipv4.py
+++ b/test/suite_dfilter/group_ipv4.py
@@ -3,9 +3,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
-from dftestlib import dftest
+import dfiltertest
-class testIPv4(dftest.DFTest):
+class case_ipv4(dfiltertest.DFTestCase):
trace_file = "nfs.pcap"
def test_uint64_1(self):
diff --git a/tools/dftestlib/membership.py b/test/suite_dfilter/group_membership.py
index a52ac9fe03..6cfc9a207b 100644
--- a/tools/dftestlib/membership.py
+++ b/test/suite_dfilter/group_membership.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testMembership(dftest.DFTest):
+class case_membership(dfiltertest.DFTestCase):
trace_file = "http.pcap"
def test_membership_1_match(self):
diff --git a/tools/dftestlib/range_method.py b/test/suite_dfilter/group_range_method.py
index 260d6ba315..520b8f261a 100644
--- a/tools/dftestlib/range_method.py
+++ b/test/suite_dfilter/group_range_method.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testRange(dftest.DFTest):
+class case_range(dfiltertest.DFTestCase):
trace_file = "ipx_rip.pcap"
def test_slice_1_pos(self):
diff --git a/tools/dftestlib/scanner.py b/test/suite_dfilter/group_scanner.py
index 56fed6d2cf..4637f506fc 100644
--- a/tools/dftestlib/scanner.py
+++ b/test/suite_dfilter/group_scanner.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testScanner(dftest.DFTest):
+class case_scanner(dfiltertest.DFTestCase):
trace_file = "http.pcap"
def test_dquote_1(self):
diff --git a/tools/dftestlib/string_type.py b/test/suite_dfilter/group_string_type.py
index 8428469a43..9bebfc94ab 100644
--- a/tools/dftestlib/string_type.py
+++ b/test/suite_dfilter/group_string_type.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testString(dftest.DFTest):
+class case_string(dfiltertest.DFTestCase):
trace_file = "http.pcap"
def test_eq_1(self):
diff --git a/tools/dftestlib/stringz.py b/test/suite_dfilter/group_stringz.py
index 100875c234..3e21a40fae 100644
--- a/tools/dftestlib/stringz.py
+++ b/test/suite_dfilter/group_stringz.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testStringz(dftest.DFTest):
+class case_stringz(dfiltertest.DFTestCase):
trace_file = "tftp.pcap"
def test_stringz_1(self):
diff --git a/tools/dftestlib/time_relative.py b/test/suite_dfilter/group_time_relative.py
index 9d66ac6084..24cd79ecc6 100644
--- a/tools/dftestlib/time_relative.py
+++ b/test/suite_dfilter/group_time_relative.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testTimeRelative(dftest.DFTest):
+class case_time_relative(dfiltertest.DFTestCase):
trace_file = "nfs.pcap"
def test_relative_time_1(self):
diff --git a/tools/dftestlib/time_type.py b/test/suite_dfilter/group_time_type.py
index 49e9fc1d92..3c77c0cc67 100644
--- a/tools/dftestlib/time_type.py
+++ b/test/suite_dfilter/group_time_type.py
@@ -2,15 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
-import os
+import dfiltertest
-from dftestlib import dftest
-
-# Force the timezone to UTC so the checks below work regardless of what time
-# zone we're in.
-os.environ['TZ'] = "UTC"
-
-class testTime(dftest.DFTest):
+class case_time(dfiltertest.DFTestCase):
trace_file = "http.pcap"
def test_eq_1(self):
diff --git a/tools/dftestlib/tvb.py b/test/suite_dfilter/group_tvb.py
index db6e95998a..e00047b9e3 100644
--- a/tools/dftestlib/tvb.py
+++ b/test/suite_dfilter/group_tvb.py
@@ -2,11 +2,10 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
-
+import dfiltertest
import unittest
-from dftestlib import dftest
-class testTVB(dftest.DFTest):
+class case_tvb(dfiltertest.DFTestCase):
trace_file = "http.pcap"
def test_eq_1(self):
diff --git a/tools/dftestlib/uint64.py b/test/suite_dfilter/group_uint64.py
index fcb3e65dbf..a4e50d7346 100644
--- a/tools/dftestlib/uint64.py
+++ b/test/suite_dfilter/group_uint64.py
@@ -2,10 +2,9 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import dfiltertest
-from dftestlib import dftest
-
-class testUINT64(dftest.DFTest):
+class case_uint64(dfiltertest.DFTestCase):
trace_file = "nfs.pcap"
def test_uint64_1(self):
diff --git a/test/test.py b/test/test.py
index 156da53a90..78421bd911 100755
--- a/test/test.py
+++ b/test/test.py
@@ -63,7 +63,7 @@ def main():
if args.capture_interface:
config.setCaptureInterface(args.capture_interface[0])
- all_tests = unittest.defaultTestLoader.discover(os.path.dirname(__file__), pattern='suite_*.py')
+ all_tests = unittest.defaultTestLoader.discover(os.path.dirname(__file__), pattern='suite_*')
all_ids = []
find_test_ids(all_tests, all_ids)
diff --git a/tools/dfilter-test.py b/tools/dfilter-test.py
deleted file mode 100755
index 61cae97b58..0000000000
--- a/tools/dfilter-test.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-"""
-Test-suite to test wireshark's dfilter mechanism.
-"""
-
-#
-# Copyright (C) 2003-2013 by Gilbert Ramirez <gram@alumni.rice.edu>
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-import os
-import sys
-import types
-import unittest
-
-# Import each test class so unittest.main() can find them
-from dftestlib.bytes_type import testBytes
-from dftestlib.bytes_ether import testBytesEther
-from dftestlib.bytes_ipv6 import testBytesIPv6
-from dftestlib.double import testDouble
-from dftestlib.integer import testInteger
-from dftestlib.integer_1byte import testInteger1Byte
-from dftestlib.ipv4 import testIPv4
-from dftestlib.membership import testMembership
-from dftestlib.range_method import testRange
-from dftestlib.scanner import testScanner
-from dftestlib.string_type import testString
-from dftestlib.stringz import testStringz
-from dftestlib.time_type import testTime
-from dftestlib.time_relative import testTimeRelative
-from dftestlib.tvb import testTVB
-from dftestlib.uint64 import testUINT64
-
-if __name__ == "__main__":
- unittest.main(verbosity=2)
diff --git a/tools/dftestlib/__init__.py b/tools/dftestlib/__init__.py
deleted file mode 100644
index 500d94c1b7..0000000000
--- a/tools/dftestlib/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-#
-# Copyright (C) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
diff --git a/tools/dftestlib/dftest.py b/tools/dftestlib/dftest.py
deleted file mode 100644
index ba7ceabe3b..0000000000
--- a/tools/dftestlib/dftest.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-
-import os
-import tempfile
-import unittest
-
-from dftestlib import util
-
-# The binaries to use. We assume we are running
-# from the top of the wireshark distro
-TSHARK = os.path.join(os.getenv("WS_BIN_PATH", "."), "tshark")
-
-class DFTest(unittest.TestCase):
- """Base class for all tests in this dfilter-test collection."""
-
- # Remove these file when finished (in tearDownClass)
- files_to_remove = []
-
- @classmethod
- def setUpClass(cls):
- """Create the trace file to be used in the tests."""
- assert cls.trace_file
-
- # if the class sets the 'trace_file' field, then it
- # names the trace file to use for the tests. It *should*
- # reside in dftestfiles
- assert not os.path.isabs(cls.trace_file)
- toolsdir = os.path.dirname(os.path.dirname(__file__))
- cls.trace_file = os.path.join(toolsdir, "dftestfiles", cls.trace_file)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the trace file used in the tests."""
- for filename in cls.files_to_remove:
- if os.path.exists(filename):
- try:
- os.remove(filename)
- except OSError:
- pass
-
-
- def runDFilter(self, dfilter):
- # Create the tshark command
- cmdv = [TSHARK,
- "-n", # No name resolution
- "-r", # Next arg is trace file to read
- self.trace_file,
- "-Y", # packet display filter (used to be -R)
- dfilter]
-
- (status, output) = util.exec_cmdv(cmdv)
- return status, output
-
-
- def assertDFilterCount(self, dfilter, expected_count):
- """Run a display filter and expect a certain number of packets."""
-
- (status, output) = self.runDFilter(dfilter)
-
- # tshark must succeed
- self.assertEqual(status, util.SUCCESS, output)
-
- # Split the output (one big string) into lines, removing
- # empty lines (extra newline at end of output)
- lines = [L for L in output.split("\n") if L != ""]
-
- msg = "Expected %d, got: %s" % (expected_count, output)
- self.assertEqual(len(lines), expected_count, msg)
-
- def assertDFilterFail(self, dfilter):
- """Run a display filter and expect tshark to fail"""
-
- (status, output) = self.runDFilter(dfilter)
-
- # tshark must succeed
- self.assertNotEqual(status, util.SUCCESS, output)
diff --git a/tools/dftestlib/util.py b/tools/dftestlib/util.py
deleted file mode 100644
index fef4ec3a36..0000000000
--- a/tools/dftestlib/util.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-
-import subprocess, sys
-
-SUCCESS = 0
-def exec_cmdv(cmdv, cwd=None, stdin=None):
- """Run the commands in cmdv, returning (retval, output),
- where output is stdout and stderr combined.
- If cwd is given, the child process runs in that directory.
- If a filehandle is passed as stdin, it is used as stdin.
- If there is an OS-level error, None is the retval."""
-
- try:
- output = subprocess.check_output(cmdv, stderr=subprocess.STDOUT,
- cwd=cwd, stdin=stdin)
- retval = SUCCESS
-
- # If file isn't executable
- except OSError as e:
- return (None, str(e))
-
- # If process returns non-zero
- except subprocess.CalledProcessError as e:
- output = e.output
- retval = e.returncode
-
- if sys.version_info[0] >= 3:
- output = output.decode('utf-8')
-
- return (retval, output)
-