aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite_dfilter/dfiltertest.py
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 /test/suite_dfilter/dfiltertest.py
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>
Diffstat (limited to 'test/suite_dfilter/dfiltertest.py')
-rw-r--r--test/suite_dfilter/dfiltertest.py36
1 files changed, 36 insertions, 0 deletions
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)