2007-04-03 01:54:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Run the epan unit tests
|
|
|
|
#
|
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-05-16 17:57:12 +00:00
|
|
|
#
|
2007-04-03 01:54:30 +00:00
|
|
|
|
|
|
|
unittests_step_test() {
|
2013-03-27 02:35:32 +00:00
|
|
|
$DUT $ARGS > testout.txt 2>&1
|
2007-04-03 01:54:30 +00:00
|
|
|
RETURNVALUE=$?
|
|
|
|
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
|
|
|
echo
|
2007-04-07 04:35:39 +00:00
|
|
|
cat ./testout.txt
|
2007-04-03 01:54:30 +00:00
|
|
|
test_step_failed "exit status of $DUT: $RETURNVALUE"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
test_step_ok
|
|
|
|
}
|
|
|
|
|
2015-03-25 01:33:08 +00:00
|
|
|
TOOL_SEARCH_PATHS="
|
|
|
|
$WS_BIN_PATH
|
2016-08-13 16:45:34 +00:00
|
|
|
$WS_BIN_PATH/epan
|
2015-03-25 01:33:08 +00:00
|
|
|
$SOURCE_DIR/epan
|
2016-08-13 16:45:34 +00:00
|
|
|
$WS_BIN_PATH/epan/wmem
|
2015-03-25 01:33:08 +00:00
|
|
|
$SOURCE_DIR/epan/wmem
|
2016-08-13 16:45:34 +00:00
|
|
|
$WS_BIN_PATH/tools
|
2015-03-25 01:33:08 +00:00
|
|
|
$SOURCE_DIR/tools
|
|
|
|
"
|
|
|
|
|
2015-03-13 16:21:01 +00:00
|
|
|
check_dut() {
|
|
|
|
TEST_EXE=""
|
2016-06-08 13:57:00 +00:00
|
|
|
# WS_BIN_PATH must be checked first, otherwise
|
2015-03-13 16:21:01 +00:00
|
|
|
# we'll find a non-functional program in epan or epan/wmem.
|
2015-03-25 01:33:08 +00:00
|
|
|
for TEST_PATH in $TOOL_SEARCH_PATHS ; do
|
2015-03-13 16:21:01 +00:00
|
|
|
if [ -x "$TEST_PATH/$1" ]; then
|
|
|
|
TEST_EXE=$TEST_PATH/$1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$TEST_EXE" ]; then
|
2015-03-25 01:33:08 +00:00
|
|
|
if [[ "$WS_SYSTEM" == "Windows" && "$TEST_EXE" == *.py ]] ; then
|
|
|
|
SCRIPT_PATH=$( cygpath -w "$TEST_EXE" )
|
|
|
|
TSHARK_PATH=$( cygpath -w "$TSHARK" )
|
|
|
|
DUT="python $SCRIPT_PATH"
|
|
|
|
else
|
|
|
|
TSHARK_PATH="$TSHARK"
|
|
|
|
DUT=$TEST_EXE
|
|
|
|
fi
|
2014-07-06 16:22:03 +00:00
|
|
|
else
|
2015-03-13 16:21:01 +00:00
|
|
|
test_step_failed "$1 not found. Have you built test-programs?"
|
2016-10-20 21:46:16 +00:00
|
|
|
return 1
|
2014-07-06 16:22:03 +00:00
|
|
|
fi
|
|
|
|
}
|
2007-04-03 01:54:30 +00:00
|
|
|
|
|
|
|
unittests_step_exntest() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut exntest || return
|
2013-03-27 02:35:32 +00:00
|
|
|
ARGS=
|
2007-04-03 01:54:30 +00:00
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
2013-10-19 18:52:13 +00:00
|
|
|
unittests_step_oids_test() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut oids_test || return
|
2013-10-19 18:52:13 +00:00
|
|
|
ARGS=
|
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
2007-04-03 01:54:30 +00:00
|
|
|
unittests_step_reassemble_test() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut reassemble_test || return
|
2013-03-27 02:35:32 +00:00
|
|
|
ARGS=
|
2007-04-03 01:54:30 +00:00
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
|
|
|
unittests_step_tvbtest() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut tvbtest || return
|
2013-03-27 02:35:32 +00:00
|
|
|
ARGS=
|
2007-04-03 01:54:30 +00:00
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
2013-03-23 23:51:07 +00:00
|
|
|
unittests_step_wmem_test() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut wmem_test || return
|
2013-03-27 02:35:32 +00:00
|
|
|
ARGS=--verbose
|
2013-03-23 23:51:07 +00:00
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
2015-03-25 01:33:08 +00:00
|
|
|
unittests_step_ftsanity() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut ftsanity.py || return
|
2015-03-25 01:33:08 +00:00
|
|
|
ARGS=$TSHARK_PATH
|
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
2015-09-23 14:14:31 +00:00
|
|
|
unittests_step_fieldcount() {
|
2016-10-20 21:46:16 +00:00
|
|
|
check_dut tshark || return
|
2015-09-23 14:14:31 +00:00
|
|
|
ARGS="-G fieldcount"
|
|
|
|
unittests_step_test
|
|
|
|
}
|
|
|
|
|
2007-04-03 01:54:30 +00:00
|
|
|
unittests_cleanup_step() {
|
|
|
|
rm -f ./testout.txt
|
|
|
|
}
|
|
|
|
|
|
|
|
unittests_suite() {
|
|
|
|
test_step_set_pre unittests_cleanup_step
|
|
|
|
test_step_set_post unittests_cleanup_step
|
2007-08-27 18:09:38 +00:00
|
|
|
test_step_add "exntest" unittests_step_exntest
|
2013-10-19 18:52:13 +00:00
|
|
|
test_step_add "oids_test" unittests_step_oids_test
|
2007-08-27 18:09:38 +00:00
|
|
|
test_step_add "reassemble_test" unittests_step_reassemble_test
|
|
|
|
test_step_add "tvbtest" unittests_step_tvbtest
|
2013-03-23 23:51:07 +00:00
|
|
|
test_step_add "wmem_test" unittests_step_wmem_test
|
2015-03-25 01:33:08 +00:00
|
|
|
test_step_add "ftsanity.py" unittests_step_ftsanity
|
2015-09-23 14:14:31 +00:00
|
|
|
test_step_add "field count" unittests_step_fieldcount
|
2007-04-03 01:54:30 +00:00
|
|
|
}
|
2013-03-01 16:13:44 +00:00
|
|
|
#
|
|
|
|
# Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
#
|
|
|
|
# Local variables:
|
2016-02-03 09:27:09 +00:00
|
|
|
# sh-basic-offset: 8
|
2013-03-01 16:13:44 +00:00
|
|
|
# tab-width: 8
|
|
|
|
# indent-tabs-mode: t
|
|
|
|
# End:
|
|
|
|
#
|
|
|
|
# vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
# :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
#
|