From c8a98f37ec300b522a732c349a7d3f0c17b7168d Mon Sep 17 00:00:00 2001 From: Hadriel Kaplan Date: Wed, 19 Mar 2014 12:14:09 -0400 Subject: 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 --- test/lua/acme_file.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/lua/acme_file.lua') 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") -- cgit v1.2.1