Test: Add unittests.

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>
This commit is contained in:
Gerald Combs 2018-04-30 14:42:29 -07:00
parent bd5a7d0295
commit ed38488211
4 changed files with 68 additions and 0 deletions

4
debian/rules vendored
View File

@ -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

View 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

View 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

59
test/suite_unittests.py Normal file
View File

@ -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'))