aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite-unittests.sh
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-02-06 03:14:11 -0500
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-02-09 19:55:43 +0000
commitf5a1786ea1cc96f3230c05a7f93b6242373f5ab9 (patch)
treefa8d1166c5fd3c93e7b0b54b3d8570d3b53c19a3 /test/suite-unittests.sh
parentfe0ed97e354f60ad995096cdccc45da2185f8a41 (diff)
Add test suite for Lua dissector-related functions
This isn't super-fancy, but it runs a simple protocol dissector and verifies the tshark output matches what it expects. Things like Proto, ProtoField, Field, Tvb, TvbRange, etc., are used in an example dissector script - it dissects DNS... partially. Enough to make sure things aren't fundamentally broken. This provides something to add on top of later as well. Change-Id: Icf3c8e9534944bcf4c4f6150f02a9a43f999cd75 Reviewed-on: https://code.wireshark.org/review/126 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'test/suite-unittests.sh')
-rwxr-xr-xtest/suite-unittests.sh33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/suite-unittests.sh b/test/suite-unittests.sh
index f9e0c68561..4d713678e8 100755
--- a/test/suite-unittests.sh
+++ b/test/suite-unittests.sh
@@ -69,6 +69,34 @@ unittests_step_exntest() {
unittests_step_test
}
+unittests_step_lua_dissector_test() {
+ if [ $HAVE_LUA -ne 0 ]; then
+ test_step_skipped
+ return
+ fi
+
+ # First run tshark with the dissector script.
+ $TSHARK -r $CAPTURE_DIR/dns_port.pcap -V -X lua_script:$TESTS_DIR/lua/dissector.lua > testin.txt 2>&1
+ RETURNVALUE=$?
+ if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
+ echo
+ cat ./testin_tmp.txt
+ test_step_failed "exit status of $DUT: $RETURNVALUE"
+ return
+ fi
+
+ # then run tshark again with the verification script. (it internally reads in testin.txt)
+ $TSHARK -r $CAPTURE_DIR/dns_port.pcap -X lua_script:$TESTS_DIR/lua/verify_dissector.lua > testout.txt 2>&1
+ if grep -q "All tests passed!" testout.txt; then
+ test_step_ok
+ else
+ echo
+ cat ./testin.txt
+ cat ./testout.txt
+ test_step_failed "didn't find pass marker"
+ fi
+}
+
unittests_step_lua_int64_test() {
if [ $HAVE_LUA -ne 0 ]; then
test_step_skipped
@@ -80,7 +108,8 @@ unittests_step_lua_int64_test() {
if grep -q "All tests passed!" testout.txt; then
test_step_ok
else
- cat testout.txt
+ echo
+ cat ./testout.txt
test_step_failed "didn't find pass marker"
fi
}
@@ -111,12 +140,14 @@ unittests_step_wmem_test() {
unittests_cleanup_step() {
rm -f ./testout.txt
+ rm -f ./testin.txt
}
unittests_suite() {
test_step_set_pre unittests_cleanup_step
test_step_set_post unittests_cleanup_step
test_step_add "exntest" unittests_step_exntest
+ test_step_add "lua dissector" unittests_step_lua_dissector_test
test_step_add "lua int64" unittests_step_lua_int64_test
test_step_add "oids_test" unittests_step_oids_test
test_step_add "reassemble_test" unittests_step_reassemble_test