aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/README.display_filter2
-rwxr-xr-xtools/dftestlib/dftest.py10
-rwxr-xr-xtools/dftestlib/util.py12
3 files changed, 13 insertions, 11 deletions
diff --git a/doc/README.display_filter b/doc/README.display_filter
index db3ee6eb51..459e3fb512 100644
--- a/doc/README.display_filter
+++ b/doc/README.display_filter
@@ -554,7 +554,7 @@ expression generator.
How to add a new test to dfilter-test.py
========================================
-Note: dfilter-test.py requires Python 2.7
+Note: dfilter-test.py requires Python 2.7 or newer (including Python 3)
"tools/dfilter-test.py" is the main test script. It includes
the test from files in tools/dftestlib. You can add a test
diff --git a/tools/dftestlib/dftest.py b/tools/dftestlib/dftest.py
index d6d32c497c..31086c3412 100755
--- a/tools/dftestlib/dftest.py
+++ b/tools/dftestlib/dftest.py
@@ -23,7 +23,7 @@ from dftestlib import util
# The binaries to use. We assume we are running
# from the top of the wireshark distro
-TSHARK = os.path.join(".", "tshark")
+TSHARK = os.path.join(os.getenv("WS_BIN_PATH", "."), "tshark")
class DFTest(unittest.TestCase):
"""Base class for all tests in this dfilter-test collection."""
@@ -40,8 +40,8 @@ class DFTest(unittest.TestCase):
# names the trace file to use for the tests. It *should*
# reside in dftestfiles
assert not os.path.isabs(cls.trace_file)
- cls.trace_file = os.path.join(".", "tools", "dftestfiles",
- cls.trace_file)
+ cls.trace_file = os.path.join(os.getenv("SOURCE_DIR", "."), "tools",
+ "dftestfiles", cls.trace_file)
@classmethod
def tearDownClass(cls):
@@ -69,12 +69,12 @@ class DFTest(unittest.TestCase):
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 != ""]
diff --git a/tools/dftestlib/util.py b/tools/dftestlib/util.py
index cb301eb0f6..6a0ae94581 100755
--- a/tools/dftestlib/util.py
+++ b/tools/dftestlib/util.py
@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import subprocess
+import subprocess, sys
SUCCESS = 0
def exec_cmdv(cmdv, cwd=None, stdin=None):
@@ -31,14 +31,16 @@ def exec_cmdv(cmdv, cwd=None, stdin=None):
retval = SUCCESS
# If file isn't executable
- except OSError, e:
- output = str(e)
- retval = None
+ except OSError as e:
+ return (None, str(e))
# If process returns non-zero
- except subprocess.CalledProcessError, e:
+ 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)