From 82e8aa33a7812e8917d8e9187e0be4d2333b43b0 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 13 Apr 2018 23:38:15 +0200 Subject: dfilter-test.py: document parallelization support Tests are independent and can be run in parallel using pytest-xdist (https://github.com/pytest-dev/pytest-xdist), document it. While at it, allow running the tests from other directories. Change-Id: I3e55c549669f7d59d35cd64eca53680cea6dec2d Reviewed-on: https://code.wireshark.org/review/26943 Reviewed-by: Peter Wu Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- .gitignore | 1 + doc/README.display_filter | 13 ++++++++++--- tools/dftestlib/dftest.py | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e3e54275d6..3137e6fe7d 100644 --- a/.gitignore +++ b/.gitignore @@ -261,3 +261,4 @@ packaging/portableapps/appinfo.ini packaging/rpm/SPECS/wireshark.spec vgcore.* Wireshark.* +.pytest_cache/ diff --git a/doc/README.display_filter b/doc/README.display_filter index 85ce9de6b3..4a1ca1cbf7 100644 --- a/doc/README.display_filter +++ b/doc/README.display_filter @@ -599,7 +599,14 @@ $ ./tools/dfilter-test.py testTVB # Run the the "test_contains_1" test from testTVB $ ./tools/dfilter-test.py testTVB.test_contains_1 -Note that dfilter-test.py should be run from the top of the -Wireshark distribution, so it knows where to find the default -tshark executable. +# For faster, parallel tests, install the "pytest-xdist" first +# (for example, using "pip install pytest-xdist"), then: +$ pytest -nauto tools/dfilter-test.py + +# Run all tests in "testTVB", in parallel: +$ pytest -nauto tools/dfilter-test.py -k testTVB + +By default dfilter-test.py assumes that the "tshark" binary is located in the +current working directory. If that is not the case, set the environment variable +WS_BIN_PATH to correct directory. diff --git a/tools/dftestlib/dftest.py b/tools/dftestlib/dftest.py index 4b54df1428..ba7ceabe3b 100644 --- a/tools/dftestlib/dftest.py +++ b/tools/dftestlib/dftest.py @@ -28,8 +28,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(os.getenv("SOURCE_DIR", "."), "tools", - "dftestfiles", 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): -- cgit v1.2.3