2015-01-21 04:29:55 +08:00
|
|
|
local cmds = require('commands')
|
|
|
|
local getopt = require('getopt')
|
|
|
|
local bin = require('bin')
|
|
|
|
local utils = require('utils')
|
|
|
|
local dumplib = require('html_dumplib')
|
2020-04-05 18:56:35 +08:00
|
|
|
local ansicolors = require('ansicolors')
|
2015-01-21 04:29:55 +08:00
|
|
|
|
2019-04-29 00:46:06 +08:00
|
|
|
copyright = ''
|
|
|
|
author = 'Iceman'
|
2020-05-19 15:13:31 +08:00
|
|
|
version = 'v1.0.3'
|
2020-04-05 18:56:35 +08:00
|
|
|
desc = [[
|
2020-05-19 15:13:31 +08:00
|
|
|
This script will load several traces files in current working directory/traces/ folder and do
|
2015-01-21 04:29:55 +08:00
|
|
|
"data load"
|
2019-03-09 17:34:43 +08:00
|
|
|
"lf search 1 u"
|
2015-03-19 00:32:43 +08:00
|
|
|
|
2019-03-09 17:34:43 +08:00
|
|
|
The following tracefiles will be loaded:
|
2015-03-19 00:32:43 +08:00
|
|
|
em*.pm3
|
2020-05-19 15:13:31 +08:00
|
|
|
modulation*.pm3
|
2019-04-29 00:46:06 +08:00
|
|
|
]]
|
2020-04-05 18:56:35 +08:00
|
|
|
example = [[
|
2020-08-14 00:42:05 +08:00
|
|
|
1. script run data_tracetest
|
2019-04-29 00:46:06 +08:00
|
|
|
]]
|
|
|
|
usage = [[
|
2020-08-14 00:42:05 +08:00
|
|
|
script run data_tracetest [-h]
|
2020-04-05 18:56:35 +08:00
|
|
|
]]
|
|
|
|
arguments = [[
|
2019-03-09 17:34:43 +08:00
|
|
|
-h : this help
|
2015-01-21 04:29:55 +08:00
|
|
|
]]
|
|
|
|
local DEBUG = true -- the debug flag
|
2019-03-09 17:34:43 +08:00
|
|
|
---
|
2015-01-21 04:29:55 +08:00
|
|
|
-- A debug printout-function
|
2019-04-29 00:46:06 +08:00
|
|
|
local function dbg(args)
|
|
|
|
if not DEBUG then return end
|
|
|
|
if type(args) == 'table' then
|
2019-03-09 17:34:43 +08:00
|
|
|
local i = 1
|
|
|
|
while result[i] do
|
|
|
|
dbg(result[i])
|
|
|
|
i = i+1
|
|
|
|
end
|
|
|
|
else
|
2019-04-29 00:46:06 +08:00
|
|
|
print('###', args)
|
2019-03-09 17:34:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
---
|
2015-01-21 04:29:55 +08:00
|
|
|
-- This is only meant to be used when errors occur
|
2019-04-29 00:46:06 +08:00
|
|
|
local function oops(err)
|
|
|
|
print('ERROR:', err)
|
|
|
|
core.clearCommandBuffer()
|
|
|
|
return nil, err
|
2015-01-21 04:29:55 +08:00
|
|
|
end
|
2019-03-09 17:34:43 +08:00
|
|
|
---
|
2015-01-21 04:29:55 +08:00
|
|
|
-- Usage help
|
2019-04-29 00:46:06 +08:00
|
|
|
local function help()
|
|
|
|
print(copyright)
|
|
|
|
print(author)
|
|
|
|
print(version)
|
2019-03-09 17:34:43 +08:00
|
|
|
print(desc)
|
2020-04-05 18:56:35 +08:00
|
|
|
print(ansicolors.cyan..'Usage'..ansicolors.reset)
|
2019-04-29 00:46:06 +08:00
|
|
|
print(usage)
|
2020-04-05 18:56:35 +08:00
|
|
|
print(ansicolors.cyan..'Arguments'..ansicolors.reset)
|
|
|
|
print(arguments)
|
|
|
|
print(ansicolors.cyan..'Example usage'..ansicolors.reset)
|
|
|
|
print(example)
|
2015-01-21 04:29:55 +08:00
|
|
|
end
|
|
|
|
--
|
|
|
|
-- Exit message
|
2019-04-29 00:46:06 +08:00
|
|
|
local function ExitMsg(msg)
|
2019-03-09 17:34:43 +08:00
|
|
|
print( string.rep('--',20) )
|
|
|
|
print( string.rep('--',20) )
|
|
|
|
print(msg)
|
|
|
|
print()
|
2015-01-21 04:29:55 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function main(args)
|
|
|
|
|
2019-03-09 17:34:43 +08:00
|
|
|
print( string.rep('--',20) )
|
|
|
|
print( string.rep('--',20) )
|
|
|
|
|
2020-10-10 04:25:33 +08:00
|
|
|
local cmdDataLoad = 'data load -f %s';
|
2020-05-19 15:13:31 +08:00
|
|
|
local cwd = core.cwd();
|
2020-06-08 09:15:10 +08:00
|
|
|
|
2020-05-19 15:13:31 +08:00
|
|
|
local tracesEM = "find '"..cwd.."/traces/ ' -iname 'em*.pm3' -type f"
|
|
|
|
local tracesMOD = "find '"..cwd.."/traces/' -iname 'modulation*.pm3' -type f"
|
2019-03-09 17:34:43 +08:00
|
|
|
|
|
|
|
local write2File = false
|
2019-04-29 00:46:06 +08:00
|
|
|
local outputTemplate = os.date('testtest_%Y-%m-%d_%H%M%S')
|
2019-03-09 17:34:43 +08:00
|
|
|
|
|
|
|
-- Arguments for the script
|
|
|
|
for o, arg in getopt.getopt(args, 'h') do
|
2019-04-29 00:46:06 +08:00
|
|
|
if o == 'h' then return help() end
|
2019-03-09 17:34:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
core.clearCommandBuffer()
|
|
|
|
|
|
|
|
local files = {}
|
|
|
|
|
|
|
|
-- Find a set of traces staring with EM
|
|
|
|
local p = assert( io.popen(tracesEM))
|
|
|
|
for file in p:lines() do
|
|
|
|
table.insert(files, file)
|
|
|
|
end
|
|
|
|
p.close();
|
|
|
|
|
2020-05-19 15:13:31 +08:00
|
|
|
-- Find a set of traces staring with MODULATION
|
2019-03-09 17:34:43 +08:00
|
|
|
p = assert( io.popen(tracesMOD) )
|
|
|
|
for file in p:lines() do
|
|
|
|
table.insert(files, file)
|
|
|
|
end
|
|
|
|
p.close();
|
|
|
|
|
2019-04-29 00:46:06 +08:00
|
|
|
local cmdLFSEARCH = 'lf search 1 u'
|
2019-03-09 17:34:43 +08:00
|
|
|
|
|
|
|
-- main loop
|
|
|
|
io.write('Starting to test traces > ')
|
|
|
|
for _,file in pairs(files) do
|
|
|
|
|
2019-04-29 00:46:06 +08:00
|
|
|
local x = 'data load '..file
|
2019-03-09 17:34:43 +08:00
|
|
|
dbg(x)
|
|
|
|
core.console(x)
|
|
|
|
|
|
|
|
dbg(cmdLFSEARCH)
|
|
|
|
core.console(cmdLFSEARCH)
|
|
|
|
|
|
|
|
core.clearCommandBuffer()
|
|
|
|
|
2019-07-11 19:01:34 +08:00
|
|
|
if core.kbd_enter_pressed() then
|
2019-04-29 00:46:06 +08:00
|
|
|
print('aborted by user')
|
2019-03-09 17:34:43 +08:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
io.write('\n')
|
|
|
|
|
|
|
|
print( string.rep('--',20) )
|
2015-01-21 04:29:55 +08:00
|
|
|
|
|
|
|
end
|
2019-03-12 07:12:26 +08:00
|
|
|
main(args)
|