decryption works, but addid doesn't because of unique pointer layers
[wireshark-sm.git] / test / lua / verify_globals.lua
blobc42e70a2d5172397c44f1a0bacc7ad6152d55716
1 -- verify_globals.lua
3 -- ignore things that change on different machines or every release
4 -- the following items still have to exist, but their values don't have to match
5 local filter = {
6 -- differences by machine
7 "DATA_DIR",
8 "USER_DIR",
9 "package.cpath",
10 "package.path",
11 "package.loaded",
12 "run_user_scripts_when_superuser",
13 "running_superuser",
15 -- differences in Lua versions
16 "_VERSION",
17 "package.config",
18 "utf8.charpattern" -- some versions allow overlong encodings
21 -- the following items don't have to exist
22 local ignore = {
23 -- deprecated in Lua 5.3, removed in Lua 5.4
24 -- but might appear in 5.4 with 5.3 backwards compatibility mode
25 "bit32", -- 5.3+ has bitwise operators, we include BitOp
26 "math.atan2", -- use math.atan with two arguments
27 "math.cosh",
28 "math.log10", -- call math.log with second argument
29 "math.sinh",
30 "math.tanh",
31 "math.pow", -- use x^y
32 "math.frexp",
33 "math.ldexp", -- use x * 2.0^exp
35 -- new in Lua 5.4
36 "coroutine.close",
37 "debug.setcstacklimit", -- function that existed in 5.4.1, stub-only in 5.4.2+
38 "warn"
42 local arg={...} -- get passed-in args
44 -- arg1 = path to find inspect
45 -- arg2 = filename to read in (optional, unless 'verify' is set)
46 -- arg3 = 'verify' to verify all of read-in file is in _G (default); 'new' to output all items in _G that are not in read-in file
47 -- arg4 = 'nometa' to ignore metatables; 'meta' otherwise (default)
49 local add_path = "lua/?.lua;"
50 if #arg > 0 then
51 add_path = arg[1].."?.lua;"
52 end
54 print("package.path = " .. package.path)
56 -- need the path to find inspect.lua
57 local old_path = package.path
58 package.path = add_path .. package.path
60 local inspect = require("inspect")
62 package.path = old_path -- return path to original
64 print("-- Wireshark version: " .. get_version())
66 if #arg == 1 then
67 -- no more args, so just output globals
68 print(inspect(_G, { serialize = true, filter = inspect.makeFilter(filter) }))
69 return
70 end
72 local file = assert(io.open(arg[2], "r"))
73 local input = file:read("*all")
74 input = inspect.marshal(input)
76 local nometa = false
77 if #arg > 3 and arg[4] == "nometa" then
78 nometa = true
79 end
81 if #arg == 2 or arg[3] == "verify" then
82 print(string.rep("\n", 2))
83 print("Verifying input file '"..arg[2].."' is contained within the global table")
84 local ret, diff = inspect.compare(input, _G, {
85 ['filter'] = inspect.makeFilter(filter),
86 ['ignore'] = inspect.makeFilter(ignore),
87 ['nonumber'] = true,
88 ['nometa'] = nometa
90 if not ret then
91 print("Comparison failed - global table does not have all the items in the input file!")
92 print(string.rep("\n", 2))
93 print(string.rep("-", 80))
94 print("Differences are:")
95 print(inspect(diff))
96 else
97 print("\n-----------------------------\n")
98 print("All tests passed!\n\n")
99 end
100 return
101 elseif #arg > 2 and arg[3] == "new" then
102 local ret, diff = inspect.compare(_G, input, {
103 ['filter'] = inspect.makeFilter(filter),
104 ['ignore'] = inspect.makeFilter(ignore),
105 ['nonumber'] = true,
106 ['keep'] = true,
107 ['nometa'] = nometa
109 if not ret then
110 print(inspect(diff))
111 else
112 print("\n-----------------------------\n")
113 print("No new items!\n\n")