summaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 17:44:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 17:44:17 +0000
commit2d78050fd56b8188aa5a65ad2667e301b60eea45 (patch)
treeb54d4adac6de0a196b8bb8a67b34fe186c21378f /test/lua
parentAdding upstream version 4.2.2. (diff)
downloadwireshark-2d78050fd56b8188aa5a65ad2667e301b60eea45.tar.xz
wireshark-2d78050fd56b8188aa5a65ad2667e301b60eea45.zip
Adding upstream version 4.2.4.upstream/4.2.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/lua')
-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
4 files changed, 28 insertions, 4 deletions
diff --git a/test/lua/acme_file.lua b/test/lua/acme_file.lua
index f159ba2..59c48dc 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 6b4aff9..2d96712 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 cc03898..b4306c6 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 dbed8ce..5e61ffc 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
}