From Peter Wu via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9174
Support running most tests out-of-tree. Use case is to have a source tree and use a semi-unprivileged user to perform tests (to rule out interference). From me: - fix unit-test suite, it has to build the binaries it runs so it must more-or-less ignore the out-of-tree stuff - fix name-res suite, just missing a path qualifier svn path=/trunk/; revision=52397
This commit is contained in:
parent
f5cebd0ef9
commit
e0cc11c92b
|
@ -40,18 +40,24 @@ if [ $? -eq 0 ] ; then
|
|||
ENDIANNESS="big"
|
||||
fi
|
||||
|
||||
# Path to the Wireshark binaries, only used for the settings below
|
||||
WS_BIN_PATH=..
|
||||
# Absolute path to the source tree
|
||||
SOURCE_DIR="$(cd "$(dirname "$0")" && cd .. && pwd)"
|
||||
|
||||
# Absolute path to this test directory (for capture and config files)
|
||||
TESTS_DIR="$SOURCE_DIR/test"
|
||||
|
||||
# Are we allowed to open interfaces or capture on this system?
|
||||
SKIP_CAPTURE=${SKIP_CAPTURE:-1}
|
||||
|
||||
# Override the last two items if we're running Windows
|
||||
if [ "$WS_SYSTEM" = "Windows" ] ; then
|
||||
WS_BIN_PATH=../wireshark-gtk2
|
||||
WS_BIN_PATH=${WS_BIN_PATH:-$SOURCE_DIR/wireshark-gtk2}
|
||||
SKIP_CAPTURE=0
|
||||
fi
|
||||
|
||||
# Path to the Wireshark binaries, default to source dir if unset
|
||||
WS_BIN_PATH=${WS_BIN_PATH:-$SOURCE_DIR}
|
||||
|
||||
# Tweak the following to your liking.
|
||||
WIRESHARK=$WS_BIN_PATH/wireshark
|
||||
TSHARK=$WS_BIN_PATH/tshark
|
||||
|
@ -91,7 +97,7 @@ fi
|
|||
# Tell Wireshark to quit after capuring packets.
|
||||
export WIRESHARK_QUIT_AFTER_CAPTURE="True"
|
||||
|
||||
CAPTURE_DIR="captures/"
|
||||
CAPTURE_DIR="$TESTS_DIR/captures/"
|
||||
|
||||
# Configuration paths
|
||||
TEST_HOME="$PWD/fakehome"
|
||||
|
|
|
@ -49,7 +49,7 @@ UAT_FILES="
|
|||
ssl_keys
|
||||
"
|
||||
|
||||
TEST_KEYS_DIR="$PWD/keys/"
|
||||
TEST_KEYS_DIR="$TESTS_DIR/keys/"
|
||||
if [ "$WS_SYSTEM" == "Windows" ] ; then
|
||||
TEST_KEYS_DIR="`cygpath -w $TEST_KEYS_DIR`"
|
||||
fi
|
||||
|
@ -71,7 +71,7 @@ decryption_step_80211_wpa_psk() {
|
|||
env $TS_DC_ENV $TSHARK $TS_DC_ARGS \
|
||||
-o "wlan.enable_decryption: TRUE" \
|
||||
-Tfields -e http.request.uri \
|
||||
-r captures/wpa-Induction.pcap.gz \
|
||||
-r "$CAPTURE_DIR/wpa-Induction.pcap.gz" \
|
||||
-Y http \
|
||||
| grep favicon.ico > /dev/null 2>&1
|
||||
RETURNVALUE=$?
|
||||
|
@ -87,7 +87,7 @@ decryption_step_80211_wpa_psk() {
|
|||
decryption_step_dtls() {
|
||||
env $TS_DC_ENV $TSHARK $TS_DC_ARGS \
|
||||
-Tfields -e data.data \
|
||||
-r captures/snakeoil-dtls.pcap -Y http \
|
||||
-r "$CAPTURE_DIR/snakeoil-dtls.pcap" -Y http \
|
||||
| grep "69:74:20:77:6f:72:6b:20:21:0a" > /dev/null 2>&1
|
||||
RETURNVALUE=$?
|
||||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
|
@ -100,7 +100,9 @@ decryption_step_dtls() {
|
|||
# SSL
|
||||
# http://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=view&target=snakeoil2_070531.tgz
|
||||
decryption_step_ssl() {
|
||||
env $TS_DC_ENV $TSHARK $TS_DC_ARGS -Tfields -e http.request.uri -r captures/rsasnakeoil2.pcap -Y http | grep favicon.ico > /dev/null 2>&1
|
||||
env $TS_DC_ENV $TSHARK $TS_DC_ARGS -Tfields -e http.request.uri \
|
||||
-r "$CAPTURE_DIR/rsasnakeoil2.pcap" -Y http \
|
||||
| grep favicon.ico > /dev/null 2>&1
|
||||
RETURNVALUE=$?
|
||||
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
|
||||
test_step_failed "Failed to decrypt SSL"
|
||||
|
@ -113,7 +115,7 @@ decryption_step_ssl() {
|
|||
# https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7022
|
||||
decryption_step_zigbee() {
|
||||
env $TS_DC_ENV $TSHARK $TS_DC_ARGS \
|
||||
-r captures/sample_control4_2012-03-24.pcap \
|
||||
-r "$CAPTURE_DIR/sample_control4_2012-03-24.pcap" \
|
||||
-Tfields -e data.data \
|
||||
-Y zbee_aps \
|
||||
| grep "30:67:63:63:38:65:20:63:34:2e:64:6d:2e:74:76:20" > /dev/null 2>&1
|
||||
|
@ -152,7 +154,7 @@ decryption_prep_step() {
|
|||
test_remark_add "$WS_BIN_PATH/$UAT exists. One or more tests may fail."
|
||||
else
|
||||
echo "# Created by $DC_ID" > $WS_BIN_PATH/$UAT
|
||||
sed -e "s|TEST_KEYS_DIR|${TEST_KEYS_DIR//\\/\\\\x5c}|" < ./config/$UAT.tmpl >> $WS_BIN_PATH/$UAT
|
||||
sed -e "s|TEST_KEYS_DIR|${TEST_KEYS_DIR//\\/\\\\x5c}|" < "$TESTS_DIR/config/$UAT.tmpl" >> "$WS_BIN_PATH/$UAT"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ EXIT_OK=0
|
|||
EXIT_COMMAND_LINE=1
|
||||
EXIT_ERROR=2
|
||||
|
||||
IO_RAWSHARK_DHCP_PCAP_BASELINE=./baseline/io-rawshark-dhcp-pcap.txt
|
||||
IO_RAWSHARK_DHCP_PCAP_BASELINE="$TESTS_DIR/baseline/io-rawshark-dhcp-pcap.txt"
|
||||
IO_RAWSHARK_DHCP_PCAP_TESTOUT=./io-rawshark-dhcp-pcap-testout.txt
|
||||
|
||||
# input of file
|
||||
|
|
|
@ -29,13 +29,13 @@ EXIT_COMMAND_LINE=1
|
|||
EXIT_ERROR=2
|
||||
|
||||
#TS_ARGS="-Tfields -e frame.number -e frame.time_epoch -e frame.time_delta"
|
||||
TS_NR_ARGS="-r captures/dns+icmp.pcapng.gz"
|
||||
TS_NR_ARGS="-r $CAPTURE_DIR/dns+icmp.pcapng.gz"
|
||||
TS_NR_ENV="WIRESHARK_RUN_FROM_BUILD_DIRECTORY=1 ${HOME_ENV}=${TEST_HOME}"
|
||||
|
||||
if [ "$WS_SYSTEM" == "Windows" ] ; then
|
||||
CONF_PATH="fakehome/Wireshark"
|
||||
CONF_PATH="$TEST_HOME/Wireshark"
|
||||
else
|
||||
CONF_PATH="fakehome/.wireshark"
|
||||
CONF_PATH="$TEST_HOME/.wireshark"
|
||||
fi
|
||||
|
||||
CUSTOM_PROFILE_NAME="Custom-$$"
|
||||
|
@ -169,9 +169,9 @@ name_resolution_cleanup_step() {
|
|||
name_resolution_prep_step() {
|
||||
name_resolution_cleanup_step
|
||||
mkdir -p "$CUSTOM_PROFILE_PATH"
|
||||
cp hosts.global $WS_BIN_PATH/hosts
|
||||
cp hosts.personal "$CONF_PATH/hosts"
|
||||
cp hosts.custom "$CUSTOM_PROFILE_PATH/hosts"
|
||||
cp "$TESTS_DIR/hosts.global" "$WS_BIN_PATH/hosts"
|
||||
cp "$TESTS_DIR/hosts.personal" "$CONF_PATH/hosts"
|
||||
cp "$TESTS_DIR/hosts.custom" "$CUSTOM_PROFILE_PATH/hosts"
|
||||
}
|
||||
|
||||
name_resolution_suite() {
|
||||
|
|
|
@ -64,25 +64,25 @@ unittests_step_test() {
|
|||
|
||||
|
||||
unittests_step_exntest() {
|
||||
DUT=../epan/exntest
|
||||
DUT=$SOURCE_DIR/epan/exntest
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_reassemble_test() {
|
||||
DUT=../epan/reassemble_test
|
||||
DUT=$SOURCE_DIR/epan/reassemble_test
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_tvbtest() {
|
||||
DUT=../epan/tvbtest
|
||||
DUT=$SOURCE_DIR/epan/tvbtest
|
||||
ARGS=
|
||||
unittests_step_test
|
||||
}
|
||||
|
||||
unittests_step_wmem_test() {
|
||||
DUT=../epan/wmem/wmem_test
|
||||
DUT=$SOURCE_DIR/epan/wmem/wmem_test
|
||||
ARGS=--verbose
|
||||
unittests_step_test
|
||||
}
|
||||
|
|
19
test/test.sh
19
test/test.sh
|
@ -73,6 +73,25 @@ source suite-fileformats.sh
|
|||
source suite-decryption.sh
|
||||
source suite-nameres.sh
|
||||
|
||||
# needed by some tests
|
||||
TEST_OUTDIR=$(mktemp -d)
|
||||
TEST_OUTDIR_CLEAN=${TEST_OUTDIR_CLEAN:-1}
|
||||
if [ -z "$TEST_OUTDIR" ] || ! cd "$TEST_OUTDIR"; then
|
||||
# If for any reason the temporary tests output directory cannot be created...
|
||||
TEST_OUTDIR=.
|
||||
TEST_OUTDIR_CLEAN=0
|
||||
fi
|
||||
|
||||
test_cleanup() {
|
||||
if [ $TEST_OUTDIR_CLEAN = 1 ]; then
|
||||
# display contents of test outputs
|
||||
grep -r . .
|
||||
rm -rf "$TEST_OUTDIR"
|
||||
else
|
||||
echo "Test results are available in $TEST_OUTDIR"
|
||||
fi
|
||||
}
|
||||
trap test_cleanup EXIT
|
||||
|
||||
#check prerequisites
|
||||
test_step_prerequisites() {
|
||||
|
|
Loading…
Reference in New Issue