summaryrefslogtreecommitdiff
path: root/test/lua/acme_file.lua
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-03-19 12:14:09 -0400
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-03-19 17:02:40 +0000
commitc8a98f37ec300b522a732c349a7d3f0c17b7168d (patch)
tree6eedd23e705a4f8b801850cf782281de206fac52 /test/lua/acme_file.lua
parenta68e3a410c210e798aa9c96c03ef5cc075f19ca9 (diff)
downloadwireshark-c8a98f37ec300b522a732c349a7d3f0c17b7168d.tar.gz
Fix lua file testsuite not working and weak heuristic readers not being registered
The testsuite for Lua file reader/writer uses the acme_file.lua script to generate a pcapng file from an Acme sipmsg.log file. It then compares the tshark verbose output of this new pcapng file to a sip.pcapng file in the test/captures directory that was previously made. Unfortunately, the acme_file.lua script generates a timestamp based on local system timezone, rather than UTC, so the testsuite fails if not run in the EST timezone where the sip.pcapng file was originally made. This has now been fixed. Also, trying to register new weak heuristic readers fails because the GArray is terminated with a NULL-based row without Glib knowing about that. So this commit changes it to let Glib handle the NULL-terminated row, so that appending takes it into account automatically. Change-Id: I037ce1cfbda03585b3a1e159df78ff8ebb41fc32 Reviewed-on: https://code.wireshark.org/review/741 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'test/lua/acme_file.lua')
-rw-r--r--test/lua/acme_file.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/lua/acme_file.lua b/test/lua/acme_file.lua
index 8eeaea5473..29a325e1d2 100644
--- a/test/lua/acme_file.lua
+++ b/test/lua/acme_file.lua
@@ -196,6 +196,10 @@ if DEBUG or DEBUG2 then
end
end
+-- this should be done as a preference setting
+local ALWAYS_UDP = true
+
+
local fh = FileHandler.new("Oracle Acme Packet logs", "acme", "A file reader for Oracle Acme Packet message logs such as sipmsg.log","rs")
@@ -323,6 +327,14 @@ end
-- monthlist table for getting month number value from 3-char name (number is table index)
local monthlist = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
+-- Compute the difference in seconds between local time and UTC
+-- from http://lua-users.org/wiki/TimeZone
+local function get_timezone()
+ local now = os.time()
+ return os.difftime(now, os.time(os.date("!*t", now)))
+end
+local timezone = get_timezone()
+
local function get_timestamp(line, file_position, seeking)
local i, line_pos, month, day, hour, min, sec, milli = line:find(header_time_pattern)
if not month then
@@ -387,6 +399,8 @@ local function get_timestamp(line, file_position, seeking)
dprint("timestamp conversion failed")
end
+ timet = timet + timezone
+
-- make an NSTime
statics.nstime = NSTime(timet, milli * 1000000)
packets[file_position][TTIME] = statics.nstime
@@ -1192,6 +1206,11 @@ local function parse_header(file, line, file_position, seeking)
ttype = UDP
end
+ -- override above decisions based on configuration
+ if ALWAYS_UDP then
+ ttype = UDP
+ end
+
direction = get_direction(direction)
if direction == nil then
dprint("parse_header: failed to convert direction")