test(fuzzing): adding variable coverage
Adding the capability to produce coverage of the arguments of the
SMC calls as generated by the fuzzer. The output from the FVP will
be routed to UART3 where a python flow will read the data to create
tables of each SMC call with its fields shown and values given. The
option is enabled by adding SMC_FUZZ_VARIABLE_COVERAGE=1 to the
corresponding TFTF config.
Change-Id: I2d4d310976aa2c0447efbd8ec0676bb9f8699828
Signed-off-by: Mark Dykes <mark.dykes@arm.com>
diff --git a/smc_fuzz/script/readsmclist.py b/smc_fuzz/script/readsmclist.py
index 3bfcb6a..d351552 100755
--- a/smc_fuzz/script/readsmclist.py
+++ b/smc_fuzz/script/readsmclist.py
@@ -14,6 +14,9 @@
argstartbit = {}
argendbit = {}
argdefval = {}
+smcid = {}
+defval = {}
+sdef = {}
smcname = ""
argnum = ""
argname = ""
@@ -23,9 +26,54 @@
smclist_lines = smclistfile.readlines()
smclistfile.close()
for sline in smclist_lines:
+ svar = 0
lcon = 0
sl = sline.strip()
- sinstr = re.search(r'^smc:\s*([a-zA-Z0-9_]+)$',sl)
+ sinstr = re.search(r'^smc:\s*([a-zA-Z0-9_]+)\s*0x([a-fA-F0-9]+)\s*$',sl)
+ if sinstr:
+ smcname = sinstr.group(1)
+ arglst[sinstr.group(1)] = []
+ argnumfield[sinstr.group(1)] = {}
+ argfieldname[sinstr.group(1)] = {}
+ argstartbit[sinstr.group(1)] = {}
+ argendbit[sinstr.group(1)] = {}
+ argdefval[sinstr.group(1)] = {}
+ smcid[sinstr.group(2)] = sinstr.group(1)
+ svar = 1
+ lcon = 1
+ argoccupy = {}
+ if not seq:
+ seq = seq + 1
+ else:
+ if seq != 2:
+ print("Error: out of sequence for smc call",end=" ")
+ print(smcname)
+ sys.exit()
+ else:
+ seq = 1
+ sinstr = re.search(r'^smc:\s*([a-zA-Z0-9_]+)\s*([a-zA-Z0-9_]+)\s*$',sl)
+ if sinstr and (svar == 0):
+ smcname = sinstr.group(1)
+ arglst[sinstr.group(1)] = []
+ argnumfield[sinstr.group(1)] = {}
+ argfieldname[sinstr.group(1)] = {}
+ argstartbit[sinstr.group(1)] = {}
+ argendbit[sinstr.group(1)] = {}
+ argdefval[sinstr.group(1)] = {}
+ sdef[sinstr.group(1)] = sinstr.group(2)
+ smcid[sinstr.group(2)] = sinstr.group(1)
+ lcon = 1
+ argoccupy = {}
+ if not seq:
+ seq = seq + 1
+ else:
+ if seq != 2:
+ print("Error: out of sequence for smc call",end=" ")
+ print(smcname)
+ sys.exit()
+ else:
+ seq = 1
+ sinstr = re.search(r'^smc:\s*([a-zA-Z0-9_]+)\s*$',sl)
if sinstr:
smcname = sinstr.group(1)
arglst[sinstr.group(1)] = []
@@ -181,6 +229,10 @@
if seq != 2:
print("Error: out of sequence for field")
sys.exit()
+ sinstr = re.search(r'^define ([a-zA-Z0-9_]+)\s*=\s*0x([a-fA-F0-9]+|\d+)$',sl)
+ if sinstr:
+ defval[sinstr.group(1)] = sinstr.group(2)
+ lcon = 1
if not lcon:
cline = re.search(r'^#',sl)
if not cline:
@@ -191,3 +243,11 @@
if(seq != 2):
print("incorrect ending for smc specification")
sys.exit()
+
+ for smccal,dval in sdef.items():
+ if dval in defval:
+ smcid[defval[dval]] = smccal
+ else:
+ print("Error: cannot find define value",end=" ")
+ print(dval)
+ sys.exit()