aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lua/dissector.lua12
-rw-r--r--test/lua/verify_dissector.lua13
-rwxr-xr-xtest/suite-wslua.sh40
3 files changed, 63 insertions, 2 deletions
diff --git a/test/lua/dissector.lua b/test/lua/dissector.lua
index 4685006aed..8d7b4a84e4 100644
--- a/test/lua/dissector.lua
+++ b/test/lua/dissector.lua
@@ -66,6 +66,7 @@ local default_settings =
debug_level = DEBUG,
port = 65333,
heur_enabled = true,
+ heur_regmode = 1,
}
-- for testing purposes, we want to be able to pass in changes to the defaults
@@ -584,7 +585,16 @@ local function heur_dissect_dns(tvbuf,pktinfo,root)
end
-- now register that heuristic dissector into the udp heuristic list
-dns:register_heuristic("udp",heur_dissect_dns)
+if default_settings.heur_regmode == 1 then
+ -- this is the "normal" way to register a heuristic: using a lua function
+ dns:register_heuristic("udp",heur_dissect_dns)
+elseif default_settings.heur_regmode == 2 then
+ -- this is to test the fix for bug 10695:
+ dns:register_heuristic("udp",dns.dissector)
+elseif default_settings.heur_regmode == 3 then
+ -- and this too is to test the fix for bug 10695:
+ dns:register_heuristic("udp", function (...) return dns.dissector(...); end )
+end
-- We're done!
-- our protocol (Proto) gets automatically registered after this script finishes loading
diff --git a/test/lua/verify_dissector.lua b/test/lua/verify_dissector.lua
index 46ec704e40..99003a0ee7 100644
--- a/test/lua/verify_dissector.lua
+++ b/test/lua/verify_dissector.lua
@@ -135,6 +135,19 @@ local lines = {
-- dissector, then the first one by the heuristic, then the second one by
-- a conversation match
local numtests = 1 + #lines[1] + #lines[2] + #lines[3] + #lines[4]
+
+local hasHeuristic = true
+
+-- grab passed-in arguments
+local args = { ... }
+if #args > 0 then
+ for _, arg in ipairs(args) do
+ if arg == "no_heur" then
+ numtests = numtests - 1
+ end
+ end
+end
+
print("going to run "..numtests.." tests")
-- for an example of what we're reading through to verify, look at end of this file
diff --git a/test/suite-wslua.sh b/test/suite-wslua.sh
index 04e7a70ca3..9b18de4072 100755
--- a/test/suite-wslua.sh
+++ b/test/suite-wslua.sh
@@ -48,12 +48,50 @@ wslua_step_dissector_test() {
if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
echo
cat ./testin.txt
- test_step_failed "exit status of $DUT: $RETURNVALUE"
+ test_step_failed "subtest-1 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/empty.pcap -X lua_script:$TESTS_DIR/lua/verify_dissector.lua > testout.txt 2>&1
+ grep -q "All tests passed!" testout.txt
+ if [ $? -ne 0 ]; then
+ cat ./testin.txt
+ cat ./testout.txt
+ test_step_failed "subtest-1 didn't find pass marker"
+ fi
+
+ # run tshark with the dissector script again, but in mode 2.
+ $TSHARK -r $CAPTURE_DIR/dns_port.pcap -V -X lua_script:$TESTS_DIR/lua/dissector.lua -X lua_script1:heur_regmode=2 > testin.txt 2>&1
+ RETURNVALUE=$?
+ if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
+ echo
+ cat ./testin.txt
+ test_step_failed "subtest-1 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/empty.pcap -X lua_script:$TESTS_DIR/lua/verify_dissector.lua -X lua_script1:no_heur > testout.txt 2>&1
+ grep -q "All tests passed!" testout.txt
+ if [ $? -ne 0 ]; then
+ cat ./testin.txt
+ cat ./testout.txt
+ test_step_failed "subtest-1 didn't find pass marker"
+ fi
+
+ # run tshark with the dissector script again, but in mode 3.
+ $TSHARK -r $CAPTURE_DIR/dns_port.pcap -V -X lua_script:$TESTS_DIR/lua/dissector.lua -X lua_script1:heur_regmode=3 > testin.txt 2>&1
+ RETURNVALUE=$?
+ if [ ! $RETURNVALUE -eq $EXIT_OK ]; then
+ echo
+ cat ./testin.txt
+ test_step_failed "subtest-1 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/empty.pcap -X lua_script:$TESTS_DIR/lua/verify_dissector.lua -X lua_script1:no_heur > testout.txt 2>&1
if grep -q "All tests passed!" testout.txt; then
test_step_ok
else