1 from __future__
import print_function
6 """Simple script that scans all of the test suite results text fed in
7 through stdin and summarises the total number of failures, test
8 points, and test cases."""
10 # Function to parse numbers
11 def number_from_string(str_value
):
12 if str_value
.find("x") != -1:
13 return int(str_value
.replace("0x", "").replace("x", ""), 16);
18 if sys
.version_info
[0]<3:
19 safe_stdin
= sys
.stdin
21 safe_stdin
= io
.TextIOWrapper(sys
.stdin
.buffer, encoding
="latin-1")
22 lines
= safe_stdin
.readlines()
24 # Init the running totals
36 exlist
= ["bug663539"]
43 m
= re
.match(r
'^Simulation started,', line
)
48 # --- Running: gen/ucz80/longor/longor
49 m
= re
.match(r
'^--- Running: (.*)$', line
)
51 #take the name only if not a whitespace, this happens if simulator stops when calling to print the name (stack overflow)
52 stripped_name
= m
.group(1).strip()
53 if stripped_name
!= "":
56 # in case the test program crashes before the "--- Running" message
57 m
= re
.match(r
'^[0-9]+ words read from (.*).ihx', line
)
61 # '--- Summary: f/t/c: ...', where f = # failures, t = # test points,
63 if (re
.search(r
'^--- Summary:', line
)):
65 if line
.count(':') == 1:
66 (summary
, data
) = re
.split(r
':', line
)
68 (summary
, data
, rest
) = re
.split(r
':', line
)
70 (nfailures
, ntests
, ncases
) = re
.split(r
'/', data
)
71 failures
= failures
+ number_from_string(nfailures
)
72 tests
= tests
+ number_from_string(ntests
)
73 cases
= cases
+ number_from_string(ncases
)
75 print("Parsing error at ", name
)
76 print("Bad summary line: ", line
)
78 if (number_from_string(nfailures
)):
79 messagelog
.append("Failure: %s" % name
)
82 # '--- Simulator: b/t: ...', where b = # bytes, t = # ticks
83 if (re
.search(r
'^--- Simulator:', line
)):
85 (simulator
, data
, rest
) = re
.split(r
':', line
)
86 (nbytes
, nticks
) = re
.split(r
'/', data
)
88 print("Bad simulator line", line
)
90 bytes
= bytes
+ int(nbytes
)
91 ticks
= ticks
+ int(nticks
)
98 messagelog
.append("abnormal stop: %s" % name
)
101 # Stop at 0x000228: (106) Invalid instruction 0x00fd
102 if (re
.search(r
'Invalid instruction', line
) or re
.search(r
'unknown instruction', line
)):
104 messagelog
.append("Invalid instruction: %s" % name
)
106 # Stop at 0xXXXXXX: (103) Stack overflow
107 if (re
.search(r
'Stack overflow', line
)):
109 messagelog
.append("Stack overflow: %s" % name
)
112 if (re
.search(r
'HALT instruction', line
) or re
.search(r
'Halt instruction', line
) or re
.search(r
'halt instruction', line
)):
114 messagelog
.append("HALT instruction: %s" % name
)
116 # --- FAIL: "timeout, simulation killed" in xx/xx/testfile.c
117 m
= re
.search(r
'simulation killed',line
)
119 name
= line
.split()[-1]
120 name
= '.'.join(name
.split('.')[0:-1])
123 if (len(sys
.argv
) > 1):
124 print("Summary for '%s':" % sys
.argv
[1], end
=' ')
126 print("%d abnormal stops (" % unmatch
, end
=' ')
128 print("%d invalid instructions," % invalid
, end
=' ')
129 if (stack_overflow
> 0):
130 print("%d Stack overflows," % stack_overflow
, end
=' ')
132 print("%d HALT instructions," % halt
, end
=' ')
134 print("%.0f failures, %.0f tests, %.0f test cases, %.0f bytes, %.0f ticks" % (failures
, tests
, cases
, bytes
, ticks
))
135 for msg
in messagelog
: