Test: Add unittests.
authorGerald Combs <gerald@wireshark.org>
Mon, 30 Apr 2018 21:42:29 +0000 (14:42 -0700)
committerGerald Combs <gerald@wireshark.org>
Mon, 30 Apr 2018 22:38:37 +0000 (22:38 +0000)
Note that these require the "test-programs" target.

Change-Id: I1bea381eaa48504fcd76f88e1c6f2edece0a78a2
Reviewed-on: https://code.wireshark.org/review/27231
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
debian/rules
docbook/wsdg_src/WSDG_chapter_tests.asciidoc
test/config.py
test/suite_unittests.py [new file with mode: 0644]

index ced9cb3..9add94d 100755 (executable)
@@ -35,6 +35,10 @@ override_dh_auto_build:
        $(MAKE) -C $(CURDIR)/obj-* user_guide_html developer_guide_html
        # fix links in documentation
        sed -i "s|$(CURDIR)/docbook|..|" obj-*/docbook/ws*g_html_chunked/*.html
+ifneq ($(filter $(DEB_BUILD_OPTIONS),nocheck),)
+       # Required for the "unittests" suite.
+       $(MAKE) -C $(CURDIR)/obj-* test-programs
+endif
 
 override_dh_strip:
        dh_strip --dbg-package=wireshark-dbg
index 092ebe8..4e90809 100644 (file)
@@ -13,6 +13,9 @@ bugs as Wireshark grows and evolves.
 
 === Quick Start
 
+Before running any tests you should build the “test-programs” target. It
+is required for the “utittests” suite.
+
 The main testing script is `test.py`. It will attempt to test as much as
 possible by default, including packet capture. This means that you will
 probably either have to supply a capture interface (`--capture-interface
index 1dc3827..51531b8 100644 (file)
@@ -31,6 +31,7 @@ can_capture = False
 capture_interface = None
 
 # Our executables
+program_path = None
 # Strings
 cmd_capinfos = None
 cmd_dumpcap = None
@@ -60,6 +61,7 @@ capture_dir = os.path.join(this_dir, 'captures')
 config_dir = os.path.join(this_dir, 'config')
 key_dir = os.path.join(this_dir, 'keys')
 lua_dir = os.path.join(this_dir, 'lua')
+tools_dir = os.path.join(this_dir, '..', 'tools')
 
 def canCapture():
     # XXX This appears to be evaluated at the wrong time when called
diff --git a/test/suite_unittests.py b/test/suite_unittests.py
new file mode 100644 (file)
index 0000000..0c4c3fc
--- /dev/null
@@ -0,0 +1,59 @@
+#
+# -*- coding: utf-8 -*-
+# Wireshark tests
+# By Gerald Combs <gerald@wireshark.org>
+#
+# Ported from a set of Bash scripts which were copyright 2005 Ulf Lamping
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+'''EPAN unit tests'''
+
+import config
+import os.path
+import subprocesstest
+import sys
+import unittest
+
+class case_unittests(subprocesstest.SubprocessTestCase):
+    def test_unit_exntest(self):
+        '''exntest'''
+        self.assertRun(os.path.join(config.program_path, 'exntest'))
+
+    def test_unit_oids_test(self):
+        '''oids_test'''
+        self.assertRun(os.path.join(config.program_path, 'oids_test'))
+
+    def test_unit_reassemble_test(self):
+        '''reassemble_test'''
+        self.assertRun(os.path.join(config.program_path, 'reassemble_test'))
+
+    def test_unit_tvbtest(self):
+        '''tvbtest'''
+        self.assertRun(os.path.join(config.program_path, 'tvbtest'))
+
+    def test_unit_wmem_test(self):
+        '''wmem_test'''
+        self.assertRun((os.path.join(config.program_path, 'wmem_test'),
+            '--verbose'
+        ))
+
+    def test_unit_wmem_test(self):
+        '''wmem_test'''
+        self.assertRun((os.path.join(config.program_path, 'wmem_test'),
+            '--verbose'
+        ))
+
+    def test_unit_ftsanity(self):
+        '''ftsanity.py'''
+        fts_cmd = [
+            os.path.join(config.tools_dir, 'ftsanity.py'),
+            config.cmd_tshark
+        ]
+        if sys.executable:
+            fts_cmd.insert(0, sys.executable)
+        self.assertRun(fts_cmd)
+
+    def test_unit_fieldcount(self):
+        '''fieldcount'''
+        self.assertRun((config.cmd_tshark, '-G', 'fieldcount'))