81740aa5 |
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') |
6 | |
7 | example =[[ |
8 | 1. script run tracetest |
81740aa5 |
9 | ]] |
10 | author = "Iceman" |
13d77ef9 |
11 | usage = "script run tracetest" |
81740aa5 |
12 | desc =[[ |
13 | This script will load several traces files in ../traces/ folder and do |
14 | "data load" |
13d77ef9 |
15 | "lf search 1 u" |
16 | |
17 | The following tracefiles will be loaded: |
18 | em*.pm3 |
19 | m*.pm3 |
81740aa5 |
20 | |
21 | Arguments: |
22 | -h : this help |
81740aa5 |
23 | ]] |
24 | |
25 | local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds |
26 | local DEBUG = true -- the debug flag |
27 | --- |
28 | -- A debug printout-function |
29 | function dbg(args) |
30 | if not DEBUG then |
31 | return |
32 | end |
33 | |
34 | if type(args) == "table" then |
35 | local i = 1 |
36 | while result[i] do |
37 | dbg(result[i]) |
38 | i = i+1 |
39 | end |
40 | else |
41 | print("###", args) |
42 | end |
43 | end |
44 | --- |
45 | -- This is only meant to be used when errors occur |
46 | function oops(err) |
47 | print("ERROR: ",err) |
48 | end |
49 | --- |
50 | -- Usage help |
51 | function help() |
52 | print(desc) |
53 | print("Example usage") |
54 | print(example) |
55 | end |
56 | -- |
57 | -- Exit message |
58 | function ExitMsg(msg) |
59 | print( string.rep('--',20) ) |
60 | print( string.rep('--',20) ) |
61 | print(msg) |
62 | print() |
63 | end |
64 | |
65 | |
66 | local function main(args) |
67 | |
68 | print( string.rep('--',20) ) |
69 | print( string.rep('--',20) ) |
70 | |
71 | local cmdDataLoad = 'data load %s'; |
72 | local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f" |
73 | local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f" |
74 | |
13d77ef9 |
75 | local write2File = false |
81740aa5 |
76 | local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S") |
77 | |
78 | -- Arguments for the script |
13d77ef9 |
79 | for o, arg in getopt.getopt(args, 'h') do |
81740aa5 |
80 | if o == "h" then return help() end |
81740aa5 |
81 | end |
13d77ef9 |
82 | |
81740aa5 |
83 | core.clearCommandBuffer() |
84 | |
85 | local files = {} |
86 | |
87 | -- Find a set of traces staring with EM |
88 | local p = assert( io.popen(tracesEM)) |
89 | for file in p:lines() do |
90 | table.insert(files, file) |
91 | end |
92 | p.close(); |
93 | |
94 | -- Find a set of traces staring with MOD |
95 | p = assert( io.popen(tracesMOD) ) |
96 | for file in p:lines() do |
97 | table.insert(files, file) |
98 | end |
99 | p.close(); |
100 | |
13d77ef9 |
101 | local cmdLFSEARCH = "lf search 1 u" |
81740aa5 |
102 | |
103 | -- main loop |
104 | io.write('Starting to test traces > ') |
105 | for _,file in pairs(files) do |
106 | |
107 | local x = "data load "..file |
108 | dbg(x) |
109 | core.console(x) |
110 | |
111 | dbg(cmdLFSEARCH) |
112 | core.console(cmdLFSEARCH) |
113 | |
114 | core.clearCommandBuffer() |
115 | |
116 | if core.ukbhit() then |
117 | print("aborted by user") |
118 | break |
119 | end |
120 | end |
121 | io.write('\n') |
122 | |
81740aa5 |
123 | print( string.rep('--',20) ) |
124 | |
125 | end |
126 | main(args) |