Add a test-programs target everywhere.
Add a "test-programs" target to each toolchain which builds each unit test executable. "test-programs" must now be built before running the unit test suite. Change-Id: I9317a1e305d987f244c4bd8b4a7f05d11fed7090 Reviewed-on: https://code.wireshark.org/review/7673 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
8f9e543d4e
commit
f074647d2b
|
@ -2301,7 +2301,7 @@ else()
|
|||
set(TEST_SH_BIN_DIR $<TARGET_FILE_DIR:epan>)
|
||||
endif()
|
||||
|
||||
add_custom_target(test-sh ALL
|
||||
add_custom_target(test-sh
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
|
||||
-DTEST_SH_BIN_DIR=${TEST_SH_BIN_DIR}
|
||||
|
@ -2310,6 +2310,17 @@ add_custom_target(test-sh ALL
|
|||
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/modules/GenerateTestSh.cmake
|
||||
)
|
||||
|
||||
add_custom_target(test-programs
|
||||
DEPENDS test-sh
|
||||
exntest
|
||||
oids_test
|
||||
reassemble_test
|
||||
tvbtest
|
||||
wmem_test
|
||||
COMMENT "Building unit test programs and wrapper"
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
#
|
||||
|
|
|
@ -1590,6 +1590,9 @@ osx-install: osx-app
|
|||
cp -pr $(srcdir)/packaging/macosx/Wireshark.app /Applications ; \
|
||||
fi
|
||||
|
||||
test-programs:
|
||||
cd epan && $(MAKE) $@
|
||||
|
||||
clean-local:
|
||||
rm -rf $(top_stagedir)
|
||||
|
||||
|
|
|
@ -553,6 +553,11 @@ text2pcap-scanner.c : text2pcap-scanner.l
|
|||
text2pcap-scanner.obj : text2pcap-scanner.c
|
||||
$(CC) $(GENERATED_CFLAGS) -Fd.\ -c $?
|
||||
|
||||
test-programs:
|
||||
cd epan
|
||||
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake test-programs
|
||||
cd ..
|
||||
|
||||
clean-local:
|
||||
rm -f $(wireshark_gtk_OBJECTS) $(tshark_OBJECTS) $(tfshark_OBJECTS) $(dumpcap_OBJECTS) $(rawshark_OBJECTS) \
|
||||
$(EXECUTABLES) *.nativecodeanalysis.xml *.pdb *.sbr *.exe.manifest \
|
||||
|
|
|
@ -1809,34 +1809,34 @@ if(NOT ${ENABLE_STATIC})
|
|||
)
|
||||
endif()
|
||||
|
||||
add_executable(wmem_test wmem/wmem_test.c ${WMEM_FILES})
|
||||
add_executable(wmem_test EXCLUDE_FROM_ALL wmem/wmem_test.c ${WMEM_FILES})
|
||||
target_link_libraries(wmem_test ${GLIB2_LIBRARIES})
|
||||
set_target_properties(wmem_test PROPERTIES
|
||||
FOLDER "Tests"
|
||||
COMPILE_DEFINITIONS "WS_BUILD_DLL"
|
||||
)
|
||||
|
||||
add_executable(exntest exntest.c except.c)
|
||||
add_executable(exntest EXCLUDE_FROM_ALL exntest.c except.c)
|
||||
target_link_libraries(exntest ${GLIB2_LIBRARIES})
|
||||
set_target_properties(exntest PROPERTIES
|
||||
FOLDER "Tests"
|
||||
COMPILE_DEFINITIONS "WS_BUILD_DLL"
|
||||
)
|
||||
|
||||
add_executable(oids_test oids_test.c)
|
||||
target_link_libraries(oids_test epan)
|
||||
add_executable(oids_test EXCLUDE_FROM_ALL oids_test.c)
|
||||
target_link_libraries(oids_test epan ${ZLIB_LIBRARIES})
|
||||
set_target_properties(oids_test PROPERTIES
|
||||
FOLDER "Tests"
|
||||
COMPILE_DEFINITIONS "WS_BUILD_DLL"
|
||||
)
|
||||
|
||||
add_executable(reassemble_test reassemble_test.c)
|
||||
add_executable(reassemble_test EXCLUDE_FROM_ALL reassemble_test.c)
|
||||
target_link_libraries(reassemble_test epan)
|
||||
set_target_properties(reassemble_test PROPERTIES
|
||||
FOLDER "Tests"
|
||||
)
|
||||
|
||||
add_executable(tvbtest tvbtest.c)
|
||||
add_executable(tvbtest EXCLUDE_FROM_ALL tvbtest.c)
|
||||
target_link_libraries(tvbtest epan)
|
||||
set_target_properties(tvbtest PROPERTIES
|
||||
FOLDER "Tests"
|
||||
|
|
|
@ -162,6 +162,9 @@ oids_test_LDADD = \
|
|||
exntest: exntest.o except.o
|
||||
$(LINK) $^ $(GLIB_LIBS)
|
||||
|
||||
test-programs: $(EXTRA_PROGRAMS) exntest
|
||||
cd wmem && $(MAKE) $@
|
||||
|
||||
RUNLEX=$(top_srcdir)/tools/runlex.sh
|
||||
|
||||
diam_dict_lex.h: diam_dict.c
|
||||
|
|
|
@ -360,22 +360,26 @@ reassemble_test.exe: $(REASSEMBLE_TEST_OBJ)
|
|||
mt.exe -nologo -manifest "$@.manifest" -outputresource:$@;1
|
||||
!ENDIF
|
||||
|
||||
exntest_install:
|
||||
exntest_install: exntest.exe
|
||||
set copycmd=/y
|
||||
if exist exntest.exe xcopy exntest.exe ..\$(INSTALL_DIR) /d
|
||||
xcopy exntest.exe ..\$(INSTALL_DIR) /d
|
||||
|
||||
tvbtest_install:
|
||||
tvbtest_install: tvbtest.exe
|
||||
set copycmd=/y
|
||||
if exist tvbtest.exe xcopy tvbtest.exe ..\$(INSTALL_DIR) /d
|
||||
xcopy tvbtest.exe ..\$(INSTALL_DIR) /d
|
||||
|
||||
oids_test_install:
|
||||
oids_test_install: oids_test.exe
|
||||
set copycmd=/y
|
||||
if exist oids_test.exe xcopy oids_test.exe ..\$(INSTALL_DIR) /d
|
||||
xcopy oids_test.exe ..\$(INSTALL_DIR) /d
|
||||
|
||||
reassemble_test_install:
|
||||
reassemble_test_install: reassemble_test.exe
|
||||
set copycmd=/y
|
||||
if exist reassemble_test.exe xcopy reassemble_test.exe ..\$(INSTALL_DIR) /d
|
||||
xcopy reassemble_test.exe ..\$(INSTALL_DIR) /d
|
||||
|
||||
test-programs: exntest_install tvbtest_install oids_test_install reassemble_test_install
|
||||
cd wmem
|
||||
$(MAKE) /$(MAKEFLAGS) -f Makefile.nmake test-programs
|
||||
cd ..
|
||||
|
||||
#
|
||||
# Compile some time critical code from assembler if NASM available
|
||||
|
|
|
@ -36,6 +36,8 @@ wmem_test_LDADD = \
|
|||
libwmem.la \
|
||||
$(GLIB_LIBS)
|
||||
|
||||
test-programs: wmem_test
|
||||
|
||||
CLEANFILES = \
|
||||
libwmem.a \
|
||||
libwmem.la \
|
||||
|
|
|
@ -37,9 +37,11 @@ wmem_test.exe: $(WMEM_TEST_OBJ) $(WMEM_TEST_LIBS)
|
|||
link /OUT:$@ $(conflags) $(conlibsdll) $(LOCAL_LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console \
|
||||
$(WMEM_TEST_LIBS) $(GLIB_LIBS) $(WMEM_TEST_OBJ)
|
||||
|
||||
wmem_test_install:
|
||||
wmem_test_install: wmem_test.exe
|
||||
set copycmd=/y
|
||||
if exist wmem_test.exe xcopy wmem_test.exe ..\..\$(INSTALL_DIR) /d
|
||||
xcopy wmem_test.exe ..\..\$(INSTALL_DIR) /d
|
||||
|
||||
test-programs: wmem_test_install
|
||||
|
||||
checkapi:
|
||||
$(PERL) ../../tools/checkAPIs.pl -g termoutput -build \
|
||||
|
|
|
@ -4,28 +4,28 @@ This is a collection of bash scripts which test the features of:
|
|||
|
||||
- Wireshark
|
||||
- TShark
|
||||
- Dumpcap
|
||||
- Dumpcap
|
||||
|
||||
Motivation
|
||||
----------
|
||||
|
||||
The command line options of Wireshark and the companion command line tools are
|
||||
numerous. This makes it hard to find newly introduced bugs doing manual testing
|
||||
The command line options of Wireshark and the companion command line tools are
|
||||
numerous. This makes it hard to find newly introduced bugs doing manual testing
|
||||
(try and error) with source code changes.
|
||||
|
||||
The current way is to do some changes, testing some scenarios by hand and
|
||||
commit the code so other users will complain about new problems. This obviously
|
||||
The current way is to do some changes, testing some scenarios by hand and
|
||||
commit the code so other users will complain about new problems. This obviously
|
||||
is far from being optimal.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
The test set currently provided will only do some basic tests, but even that
|
||||
The test set currently provided will only do some basic tests, but even that
|
||||
is far better than nothing. This may involve in time as new tests can be added
|
||||
to fix problems reported by users. This will hopefully lead to a "complete"
|
||||
to fix problems reported by users. This will hopefully lead to a "complete"
|
||||
and reliable testset in the future.
|
||||
|
||||
The tests are limited to command line tests, other things like unit tests or
|
||||
The tests are limited to command line tests, other things like unit tests or
|
||||
GUI test are not included.
|
||||
|
||||
Prerequisites
|
||||
|
@ -34,10 +34,11 @@ Prerequisites
|
|||
What you'll need (to do):
|
||||
|
||||
- edit the file config.sh to suit your configuration
|
||||
- obviously, compile the programs (wireshark, ...) to be tested
|
||||
- build the "all" target
|
||||
- build the "test-programs" target
|
||||
- have a bash (cygwin should do well)
|
||||
- have tput (e.g. in the cygwin ncurses package)
|
||||
- you'll need a network interface with some network traffic
|
||||
- you'll need a network interface with some network traffic
|
||||
(so you can run the capture tests)
|
||||
- (for non-Windows platforms) An X server for running the capture tests with
|
||||
the graphical Wireshark program.
|
||||
|
@ -69,7 +70,7 @@ it with:
|
|||
When your configuration is sane, you can start test.sh which should provide a
|
||||
basic menu. Just press Enter to start all tests.
|
||||
|
||||
It should start all the available tests. Each test will throw out a line
|
||||
It should start all the available tests. Each test will throw out a line
|
||||
which should end with a green "Ok". If one of the tests fail, the script
|
||||
will report it and stop at this test step.
|
||||
|
||||
|
|
|
@ -20,35 +20,7 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
if [ "$WS_SYSTEM" == "Windows" ] ; then
|
||||
MAKE="nmake -f Makefile.nmake"
|
||||
else
|
||||
MAKE=make
|
||||
fi
|
||||
|
||||
unittests_step_test() {
|
||||
( cd `dirname $DUT` && $MAKE `basename $DUT` ) >testout.txt 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "make $DUT failed"
|
||||
return
|
||||
fi
|
||||
|
||||
# if we're on windows, we have to copy the test exe to the wireshark-gtk2
|
||||
# dir before we can use them.
|
||||
# {Note that 'INSTALL_DIR' must be a Windows Pathname)
|
||||
if [ "$WS_SYSTEM" == "Windows" ] ; then
|
||||
(cd `dirname $DUT` && $MAKE `basename $DUT`_install INSTALL_DIR='wireshark-gtk2\') > testout.txt 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
cat ./testout.txt
|
||||
test_step_failed "install $DUT failed"
|
||||
return
|
||||
fi
|
||||
DUT=$SOURCE_DIR/wireshark-gtk2/`basename $DUT`
|
||||
fi
|
||||
|
||||
$DUT $ARGS > testout.txt 2>&1
|
||||
RETURNVALUE=$?
|
||||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
|
@ -60,43 +32,50 @@ unittests_step_test() {
|
|||
test_step_ok
|
||||
}
|
||||
|
||||
set_dut() {
|
||||
if [ "$SOURCE_DIR" = "$WS_BIN_PATH" -o "$WS_SYSTEM" = "Windows" ]; then
|
||||
DUT=$SOURCE_DIR/epan/$1
|
||||
check_dut() {
|
||||
TEST_EXE=""
|
||||
# WS_BIN_PATH must be checked first, otherwise when using Nmake
|
||||
# we'll find a non-functional program in epan or epan/wmem.
|
||||
for TEST_PATH in "$WS_BIN_PATH" "$SOURCE_DIR/epan" "$SOURCE_DIR/epan/wmem" ; do
|
||||
if [ -x "$TEST_PATH/$1" ]; then
|
||||
TEST_EXE=$TEST_PATH/$1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$TEST_EXE" ]; then
|
||||
DUT=$TEST_EXE
|
||||
else
|
||||
# In out-of-tree builds, all binaries end up in the same folder
|
||||
# regardless of their path during in-tree builds, so we strip
|
||||
# off any prefix part of the path (such as wmem/ for wmem_test)
|
||||
DUT=$WS_BIN_PATH/${1##*/}
|
||||
test_step_failed "$1 not found. Have you built test-programs?"
|
||||
fi
|
||||
}
|
||||
|
||||
unittests_step_exntest() {
|
||||
set_dut exntest
|
||||
check_dut exntest
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_oids_test() {
|
||||
set_dut oids_test
|
||||
check_dut oids_test
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_reassemble_test() {
|
||||
set_dut reassemble_test
|
||||
check_dut reassemble_test
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_tvbtest() {
|
||||
set_dut tvbtest
|
||||
check_dut tvbtest
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_wmem_test() {
|
||||
set_dut wmem/wmem_test
|
||||
check_dut wmem_test
|
||||
ARGS=--verbose
|
||||
unittests_step_test
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue