summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures_ws.py1
-rw-r--r--test/lua/acme_file.lua4
-rw-r--r--test/lua/inspect.lua5
-rw-r--r--test/lua/proto.lua8
-rw-r--r--test/lua/verify_globals.lua15
-rw-r--r--test/suite_dfilter/group_function.py8
-rw-r--r--test/suite_dissection.py4
-rw-r--r--test/suite_sharkd.py36
8 files changed, 74 insertions, 7 deletions
diff --git a/test/fixtures_ws.py b/test/fixtures_ws.py
index ceee4025..0bd4c391 100644
--- a/test/fixtures_ws.py
+++ b/test/fixtures_ws.py
@@ -182,6 +182,7 @@ def features(cmd_tshark, make_env):
have_gnutls='with GnuTLS' in tshark_v,
have_pkcs11='and PKCS #11 support' in tshark_v,
have_brotli='with brotli' in tshark_v,
+ have_zstd='with Zstandard' in tshark_v,
have_plugins='binary plugins supported' in tshark_v,
)
diff --git a/test/lua/acme_file.lua b/test/lua/acme_file.lua
index f159ba2d..59c48dc6 100644
--- a/test/lua/acme_file.lua
+++ b/test/lua/acme_file.lua
@@ -438,7 +438,9 @@ function State:get_timestamp(line, file_position, seeking)
self.nstime = NSTime(timet, milli * 1000000)
self.packets[file_position][TTIME] = self.nstime
- timet = timet + (milli/1000)
+ -- For Lua 5.3 and later, make sure we have an integer via a method
+ -- that also works on Lua 5.1. (os.date doesn't handle fractional seconds.)
+ timet = timet + math.floor(milli/1000)
dprint2("found time of ", os.date("%c",timet), " with value=",timet)
return self.nstime, line_pos
diff --git a/test/lua/inspect.lua b/test/lua/inspect.lua
index 6b4aff9c..2d967128 100644
--- a/test/lua/inspect.lua
+++ b/test/lua/inspect.lua
@@ -416,7 +416,10 @@ function inspect.marshal(inString, options)
inString = "return " .. inString
end
- local t = assert(loadstring(inString))()
+ -- loadstring was removed after Lua 5.1, load given a string
+ -- argument does the same thing
+ local load = (_VERSION == "Lua 5.1") and loadstring or load
+ local t = assert(load(inString))()
removeIndex(t)
diff --git a/test/lua/proto.lua b/test/lua/proto.lua
index cc038989..b4306c69 100644
--- a/test/lua/proto.lua
+++ b/test/lua/proto.lua
@@ -9,8 +9,9 @@ local testlib = require("testlib")
local OTHER = "other"
-- expected number of runs per type
+-- # of fields test doesn't work on Lua 5.4
local taptests = {
- [OTHER]=48
+ [OTHER]=47
}
testlib.init(taptests)
@@ -156,7 +157,10 @@ local myfields = { pf_trasaction_id, pf_flags,
--dns.fields = myfields
testlib.test(OTHER,"Proto.fields-set", pcall(setValue,dns,"fields",myfields))
testlib.test(OTHER,"Proto.fields-get", pcall(getValue,dns,"fields"))
-testlib.test(OTHER,"Proto.fields-get", #dns.fields == #myfields)
+-- This test doesn't work on Lua 5.4 because the # operator includes the
+-- reference(s) that are the linked list of allocated and free keys,
+-- starting with LUA_RIDX_LAST + 1 == 3.
+-- testlib.test(OTHER,"Proto.fields-get", #dns.fields == #myfields)
local pf_foo = ProtoField.uint16("myfoo.com", "Fooishly", base.DEC, rcodes, 0x000F)
diff --git a/test/lua/verify_globals.lua b/test/lua/verify_globals.lua
index dbed8ceb..5e61ffce 100644
--- a/test/lua/verify_globals.lua
+++ b/test/lua/verify_globals.lua
@@ -35,13 +35,20 @@ local ignore = {
"getfenv",
"io.gfind",
"setfenv",
+ "loadstring", -- call load with a string argument
+ "math.log10", -- call math.log with second argument
"math.mod",
+ "module",
"newproxy",
+ "package.loaders", -- renamed package.searchers
+ "package.seeall", -- used with module
"string.gfind",
"table.foreach",
"table.foreachi",
"table.getn",
+ "table.maxn",
"table.setn",
+ "unpack", -- replaced by table.unpack
-- in Lua 5.2+ only
"bit32",
@@ -55,6 +62,14 @@ local ignore = {
"table.pack",
"table.unpack",
+ -- removed in Lua 5.3
+ "math.atan2", -- use math.atan with two arguments
+ "math.cosh",
+ "math.sinh",
+ "math.tanh",
+ "math.pow", -- use x^y
+ "math.frexp",
+ "math.ldexp", -- use x * 2.0^exp
}
diff --git a/test/suite_dfilter/group_function.py b/test/suite_dfilter/group_function.py
index 08c9795c..c8a0c522 100644
--- a/test/suite_dfilter/group_function.py
+++ b/test/suite_dfilter/group_function.py
@@ -85,3 +85,11 @@ class TestFunctionNested:
def test_function_nested_1(self, checkDFilterCount):
dfilter = 'abs(min(tcp.srcport, tcp.dstport)) == 80'
checkDFilterCount(dfilter, 1)
+
+ def test_function_nested_2(self, checkDFilterCount):
+ dfilter = 'min(tcp.srcport * 10, tcp.dstport * 10, udp.srcport * 10, udp.dstport * 10) == 800'
+ checkDFilterCount(dfilter, 1)
+
+ def test_function_nested_3(self, checkDFilterCount):
+ dfilter = 'min(len(tcp.payload), len(udp.payload)) == 153'
+ checkDFilterCount(dfilter, 1)
diff --git a/test/suite_dissection.py b/test/suite_dissection.py
index ee90c930..18eb4a2e 100644
--- a/test/suite_dissection.py
+++ b/test/suite_dissection.py
@@ -919,7 +919,9 @@ class TestDissectCommunityId:
self.check_baseline(dirs, stdout, 'communityid-filtered.txt')
class TestDecompressMongo:
- def test_decompress_zstd(self, cmd_tshark, capture_file, test_env):
+ def test_decompress_zstd(self, cmd_tshark, features, capture_file, test_env):
+ if not features.have_zstd:
+ pytest.skip('Requires zstd.')
stdout = subprocess.check_output((cmd_tshark,
'-d', 'tcp.port==27017,mongo',
'-r', capture_file('mongo-zstd.pcapng'),
diff --git a/test/suite_sharkd.py b/test/suite_sharkd.py
index db736dcc..d8c1ef2f 100644
--- a/test/suite_sharkd.py
+++ b/test/suite_sharkd.py
@@ -75,7 +75,23 @@ class TestSharkd:
check_sharkd_session((
{"jsonrpc":"2.0", "id":1, "method":"status"},
), (
- {"jsonrpc":"2.0","id":1,"result":{"frames":0,"duration":0.000000000,"columns":["No.","Time","Source","Destination","Protocol","Length","Info"]}},
+ {"jsonrpc":"2.0","id":1,"result":{"frames":0,"duration":0.000000000,"columns":["No.","Time","Source","Destination","Protocol","Length","Info"],
+ "column_info":[{
+ "title":"No.","format": "%m","visible":True, "resolved":True
+ },{
+ "title": "Time", "format": "%t", "visible":True, "resolved":True
+ },{
+ "title": "Source", "format": "%s", "visible":True, "resolved":True
+ },{
+ "title": "Destination", "format": "%d", "visible":True, "resolved":True
+ },{
+ "title": "Protocol", "format": "%p", "visible":True, "resolved":True
+ },{
+ "title": "Length", "format": "%L", "visible":True, "resolved":True
+ },{
+ "title": "Info", "format": "%i", "visible":True, "resolved":True
+ }]
+ }},
))
def test_sharkd_req_status(self, check_sharkd_session, capture_file):
@@ -88,7 +104,23 @@ class TestSharkd:
{"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
{"jsonrpc":"2.0","id":2,"result":{"frames": 4, "duration": 0.070345000,
"filename": "dhcp.pcap", "filesize": 1400,
- "columns":["No.","Time","Source","Destination","Protocol","Length","Info"]}},
+ "columns":["No.","Time","Source","Destination","Protocol","Length","Info"],
+ "column_info":[{
+ "title":"No.","format": "%m","visible":True, "resolved":True
+ },{
+ "title": "Time", "format": "%t", "visible":True, "resolved":True
+ },{
+ "title": "Source", "format": "%s", "visible":True, "resolved":True
+ },{
+ "title": "Destination", "format": "%d", "visible":True, "resolved":True
+ },{
+ "title": "Protocol", "format": "%p", "visible":True, "resolved":True
+ },{
+ "title": "Length", "format": "%L", "visible":True, "resolved":True
+ },{
+ "title": "Info", "format": "%i", "visible":True, "resolved":True
+ }]
+ }},
))
def test_sharkd_req_analyse(self, check_sharkd_session, capture_file):