Skip to content

Commit 15332e7

Browse files
committed
Allow special case to test for 0 value on a given monitor
(Required for ALLOW_BACKPROP unnittest)
1 parent e6e9add commit 15332e7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

tools/Python/mctest/mctest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,10 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, compfilt
376376
if test.didrun and not failed:
377377
formatstr = "%-" + "%ds: " % (maxnamelen+1) + \
378378
"{:3d}.".format(math.floor(test.runtime)) + str(test.runtime-int(test.runtime)).split('.')[1][:2]
379-
logging.info(formatstr % test.get_display_name() + " [val: " + str(test.testval) + " / " + str(test.targetval) + " = " + str(round(100.0*test.testval/test.targetval)) + " %]")
379+
if test.targetval!=0: # Normal situation, non-zero target value
380+
logging.info(formatstr % test.get_display_name() + " [val: " + str(test.testval) + " / " + str(test.targetval) + " = " + str(round(100.0*test.testval/test.targetval)) + " %]")
381+
else: # Special case, expected test target value is 0
382+
logging.info(formatstr % test.get_display_name() + " [val: " + str(test.testval) + " vs " + str(test.targetval) + " (absolute vs 0) ]")
380383

381384
# save test result to disk
382385
test.testcomplete = True

tools/Python/mctest/mcviewtest.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_cell_tuple(cellobj, refval=None):
8585
# if this is a second test of the same instr, it was already compiled, thus 0.001 compiletime is nonsense
8686
compiletime = ""
8787
return (state, compiletime, "", "", "", burl)
88-
elif not cellobj["testval"]:
88+
elif cellobj["testval"]==None:
8989
testval = "missing"
9090
runtime = "%.2f s" % cellobj["runtime"]
9191
compiletime = "%.2f s" % cellobj["compiletime"]
@@ -102,8 +102,15 @@ def get_cell_tuple(cellobj, refval=None):
102102

103103
# Always use embedded target value
104104
refval = float(cellobj["targetval"])
105-
106-
refp = abs(float(cellobj["testval"])/refval*100)
105+
testval = float(cellobj["testval"])
106+
# Special case, target test value is 0 explicitly:
107+
if refval==0:
108+
if testval==0:
109+
refp=100
110+
else:
111+
refp=0
112+
else: # Standard case, target test value is non-zero
113+
refp = abs(testval/refval*100)
107114
if abs(refp-100) > ERROR_PERCENT_THRESSHOLD_ACCEPT:
108115
state = 2
109116
else:

0 commit comments

Comments
 (0)