1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local bin = require('bin')
4 local utils = require('utils')
5 local dumplib = require('html_dumplib')
8 1. script run tracetest
9 2. script run tracetest -o
13 usage = "script run tracetest -o <filename>"
15 This script will load several traces files in ../traces/ folder and do
24 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
25 local DEBUG = true -- the debug flag
27 -- A debug printout-function
33 if type(args) == "table" then
44 -- This is only meant to be used when errors occur
52 print("Example usage")
58 print( string.rep('--',20) )
59 print( string.rep('--',20) )
65 local function main(args)
67 print( string.rep('--',20) )
68 print( string.rep('--',20) )
70 local cmdDataLoad = 'data load %s';
71 local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f"
72 local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f"
74 local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S")
76 -- Arguments for the script
77 for o, arg in getopt.getopt(args, 'ho:') do
78 if o == "h" then return help() end
79 if o == "o" then outputTemplate = arg end
82 core.clearCommandBuffer()
86 -- Find a set of traces staring with EM
87 local p = assert( io.popen(tracesEM))
88 for file in p:lines() do
89 table.insert(files, file)
93 -- Find a set of traces staring with MOD
94 p = assert( io.popen(tracesMOD) )
95 for file in p:lines() do
96 table.insert(files, file)
100 local cmdLFSEARCH = "lf search 1"
103 io.write('Starting to test traces > ')
104 for _,file in pairs(files) do
106 local x = "data load "..file
111 core.console(cmdLFSEARCH)
113 core.clearCommandBuffer()
115 if core.ukbhit() then
116 print("aborted by user")
122 -- Write dump to files
124 local bar = dumplib.SaveAsText(emldata, outputTemplate..'.txt')
125 print(("Wrote output to: %s"):format(bar))
129 print( string.rep('--',20) )