forked from osmocom/wireshark
Test: Make sure we run our display filter tests.
Change the test suite list in CMakeLists.txt to a static list. Add a CTest coverage unit test. Change-Id: I8459f320a2d0707618d6d56abdfce80274fddd2d Reviewed-on: https://code.wireshark.org/review/27377 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
b27cd62519
commit
f72481a144
|
@ -3160,26 +3160,37 @@ set_target_properties(test-programs PROPERTIES
|
||||||
|
|
||||||
# Test suites
|
# Test suites
|
||||||
enable_testing()
|
enable_testing()
|
||||||
file(GLOB _test_suite_py_list test/suite_*.py)
|
# We could try to build this list dynamically, but given that we tend to
|
||||||
|
# go years between adding suites just run
|
||||||
|
# test/test.py --list-suites | sort
|
||||||
|
# and paste the output here.
|
||||||
|
set(_test_suite_list
|
||||||
|
suite_capture
|
||||||
|
suite_clopts
|
||||||
|
suite_decryption
|
||||||
|
suite_dfilter
|
||||||
|
suite_dissection
|
||||||
|
suite_fileformats
|
||||||
|
suite_io
|
||||||
|
suite_mergecap
|
||||||
|
suite_nameres
|
||||||
|
suite_text2pcap
|
||||||
|
suite_unittests
|
||||||
|
suite_wslua
|
||||||
|
)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(_test_suite_program_path ./run/$<CONFIG>)
|
set(_test_suite_program_path ./run/$<CONFIG>)
|
||||||
else()
|
else()
|
||||||
set(_test_suite_program_path ./run)
|
set(_test_suite_program_path ./run)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# We currently don't handle spaces in arguments. On Windows this
|
# We don't currently handle spaces in arguments. On Windows this
|
||||||
# means that you will probably have to pass in an interface index
|
# means that you will probably have to pass in an interface index
|
||||||
# instead of a name.
|
# instead of a name.
|
||||||
set(TEST_EXTRA_ARGS "" CACHE STRING "Extra arguments to pass to test/test.py")
|
set(TEST_EXTRA_ARGS "" CACHE STRING "Extra arguments to pass to test/test.py")
|
||||||
separate_arguments(TEST_EXTRA_ARGS)
|
separate_arguments(TEST_EXTRA_ARGS)
|
||||||
|
|
||||||
# We can enumerate suites two ways: by probing the filesystem and by
|
foreach(_suite_name ${_test_suite_list})
|
||||||
# running `test.py --list-suites`. Probe the filesystem for now, which
|
|
||||||
# should hopefully give us enough parallelization. If we want to split
|
|
||||||
# our tests by cases or individual tests we'll have to run and parse
|
|
||||||
# `test.py --list-cases` or `test.py --list` respectively.
|
|
||||||
foreach(_suite_py ${_test_suite_py_list})
|
|
||||||
get_filename_component(_suite_name ${_suite_py} NAME_WE)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME ${_suite_name}
|
NAME ${_suite_name}
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/test/test.py
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/test/test.py
|
||||||
|
|
|
@ -63,6 +63,8 @@ key_dir = os.path.join(this_dir, 'keys')
|
||||||
lua_dir = os.path.join(this_dir, 'lua')
|
lua_dir = os.path.join(this_dir, 'lua')
|
||||||
tools_dir = os.path.join(this_dir, '..', 'tools')
|
tools_dir = os.path.join(this_dir, '..', 'tools')
|
||||||
|
|
||||||
|
all_suites = []
|
||||||
|
|
||||||
def canCapture():
|
def canCapture():
|
||||||
# XXX This appears to be evaluated at the wrong time when called
|
# XXX This appears to be evaluated at the wrong time when called
|
||||||
# from a unittest.skipXXX decorator.
|
# from a unittest.skipXXX decorator.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_bytes_ether(dfiltertest.DFTestCase):
|
class case_bytes_ether(dfiltertest.DFTestCase):
|
||||||
trace_file = "ipx_rip.pcap"
|
trace_file = "ipx_rip.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_bytes_ipv6(dfiltertest.DFTestCase):
|
class case_bytes_ipv6(dfiltertest.DFTestCase):
|
||||||
trace_file = "ipv6.pcap"
|
trace_file = "ipv6.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_bytes_type(dfiltertest.DFTestCase):
|
class case_bytes_type(dfiltertest.DFTestCase):
|
||||||
trace_file = "arp.pcap"
|
trace_file = "arp.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_double(dfiltertest.DFTestCase):
|
class case_double(dfiltertest.DFTestCase):
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_integer(dfiltertest.DFTestCase):
|
class case_integer(dfiltertest.DFTestCase):
|
||||||
trace_file = "ntp.pcap"
|
trace_file = "ntp.pcap"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_integer_1_byte(dfiltertest.DFTestCase):
|
class case_integer_1_byte(dfiltertest.DFTestCase):
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_ipv4(dfiltertest.DFTestCase):
|
class case_ipv4(dfiltertest.DFTestCase):
|
||||||
trace_file = "nfs.pcap"
|
trace_file = "nfs.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_membership(dfiltertest.DFTestCase):
|
class case_membership(dfiltertest.DFTestCase):
|
||||||
trace_file = "http.pcap"
|
trace_file = "http.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_range(dfiltertest.DFTestCase):
|
class case_range(dfiltertest.DFTestCase):
|
||||||
trace_file = "ipx_rip.pcap"
|
trace_file = "ipx_rip.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_scanner(dfiltertest.DFTestCase):
|
class case_scanner(dfiltertest.DFTestCase):
|
||||||
trace_file = "http.pcap"
|
trace_file = "http.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_string(dfiltertest.DFTestCase):
|
class case_string(dfiltertest.DFTestCase):
|
||||||
trace_file = "http.pcap"
|
trace_file = "http.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_stringz(dfiltertest.DFTestCase):
|
class case_stringz(dfiltertest.DFTestCase):
|
||||||
trace_file = "tftp.pcap"
|
trace_file = "tftp.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_time_relative(dfiltertest.DFTestCase):
|
class case_time_relative(dfiltertest.DFTestCase):
|
||||||
trace_file = "nfs.pcap"
|
trace_file = "nfs.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_time(dfiltertest.DFTestCase):
|
class case_time(dfiltertest.DFTestCase):
|
||||||
trace_file = "http.pcap"
|
trace_file = "http.pcap"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class case_tvb(dfiltertest.DFTestCase):
|
class case_tvb(dfiltertest.DFTestCase):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
import dfiltertest
|
from suite_dfilter import dfiltertest
|
||||||
|
|
||||||
class case_uint64(dfiltertest.DFTestCase):
|
class case_uint64(dfiltertest.DFTestCase):
|
||||||
trace_file = "nfs.pcap"
|
trace_file = "nfs.pcap"
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
'''EPAN unit tests'''
|
'''EPAN unit tests'''
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
import difflib
|
||||||
import os.path
|
import os.path
|
||||||
|
import pprint
|
||||||
|
import re
|
||||||
import subprocesstest
|
import subprocesstest
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
@ -49,6 +52,26 @@ class case_unittests(subprocesstest.SubprocessTestCase):
|
||||||
'''fieldcount'''
|
'''fieldcount'''
|
||||||
self.assertRun((config.cmd_tshark, '-G', 'fieldcount'))
|
self.assertRun((config.cmd_tshark, '-G', 'fieldcount'))
|
||||||
|
|
||||||
|
def test_unit_ctest_coverage(self):
|
||||||
|
'''Make sure CTest runs all of our tests.'''
|
||||||
|
with open(os.path.join(config.this_dir, '..', 'CMakeLists.txt')) as cml_fd:
|
||||||
|
suite_re = re.compile('set *\( *_test_suite_list')
|
||||||
|
in_list = False
|
||||||
|
cml_suites = []
|
||||||
|
for cml_line in cml_fd:
|
||||||
|
if suite_re.search(cml_line):
|
||||||
|
in_list = True
|
||||||
|
continue
|
||||||
|
if in_list:
|
||||||
|
if ')' in cml_line:
|
||||||
|
break
|
||||||
|
cml_suites.append(cml_line.strip())
|
||||||
|
cml_suites.sort()
|
||||||
|
if not config.all_suites == cml_suites:
|
||||||
|
diff = '\n'.join(list(difflib.unified_diff(config.all_suites, cml_suites, 'all test suites', 'CMakeLists.txt test suites')))
|
||||||
|
self.fail("CMakeLists.txt doesn't test all available suites:\n" + diff)
|
||||||
|
|
||||||
|
|
||||||
class Proto:
|
class Proto:
|
||||||
"""Data for a protocol."""
|
"""Data for a protocol."""
|
||||||
def __init__(self, line):
|
def __init__(self, line):
|
||||||
|
|
13
test/test.py
13
test/test.py
|
@ -87,12 +87,15 @@ def main():
|
||||||
print('\n'.join(run_ids))
|
print('\n'.join(run_ids))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
all_suites = set()
|
||||||
|
for aid in all_ids:
|
||||||
|
aparts = aid.split('.')
|
||||||
|
all_suites |= {aparts[0]}
|
||||||
|
config.all_suites = list(all_suites)
|
||||||
|
config.all_suites.sort()
|
||||||
|
|
||||||
if args.list_suites:
|
if args.list_suites:
|
||||||
suites = set()
|
print('\n'.join(config.all_suites))
|
||||||
for rid in run_ids:
|
|
||||||
rparts = rid.split('.')
|
|
||||||
suites |= {rparts[0]}
|
|
||||||
print('\n'.join(list(suites)))
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if args.list_cases:
|
if args.list_cases:
|
||||||
|
|
Loading…
Reference in New Issue