Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / compact-results.py
blobc323bc37b989fa6422b5137a1853e764969a8291
1 from __future__ import print_function
3 import sys, re, io
4 import string
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);
14 else:
15 return int(str_value)
17 def running_name_valid(name):
18 if (name != "") and (name.find(" ") == -1) and ((name.find("/") != -1) or re.match(r'^(.*).c$', name)):
19 return True
20 else:
21 return False
23 # Read in everything
24 if sys.version_info[0]<3:
25 safe_stdin = sys.stdin
26 else:
27 safe_stdin = io.TextIOWrapper(sys.stdin.buffer, encoding="latin-1")
28 lines = safe_stdin.readlines()
30 summary_found = False
31 for line in lines:
32 if (re.search(r'^--- Summary:', line)):
33 summary_found = True
34 break
37 outname = ""
38 if len(sys.argv) > 1:
39 outname = sys.argv[1]
41 # Create lines not present in simulation log
42 if not summary_found:
43 print("- Added by compact-results script: %s\n" % sys.argv[1])
44 m = re.match(r'^(.*).out', outname)
45 if (m):
46 outname = m.group(1)
47 print("--- Running: %s\n" % outname)
48 print("--- Summary: 1/0/0: 1 failed of 0 tests in 0 cases.\n")
50 # Init the running totals
51 failures = 0 if summary_found else 1
52 cases = 0
53 tests = 0
54 bytes = 0
55 ticks = 0
56 invalid = 0
57 stack_overflow = 0
59 # hack for valdiag
60 name = ""
61 base = ""
63 for line in lines:
64 # --- Running: gen/ucz80/longor/longor
65 m = re.match(r'^--- Running: (.*)$', line)
66 if (m):
67 #take the name only if not a whitespace, this happens if simulator stops when calling to print the name (stack overflow)
68 stripped_name = m.group(1).strip()
69 if running_name_valid(stripped_name):
70 name = stripped_name
72 # In case the test program crashes before the "--- Running" message
73 m = re.match(r'^[0-9]+ words read from (.*).ihx', line)
74 if (m):
75 name = m.group(1)
77 safe_name = name if name != "" else outname
79 # Get base name from name
80 base = safe_name
81 m = re.match(r'([^/]*)/([^/]*)/([^/]*)/(.*)$', base)
82 if (m):
83 base = m.group(3)
85 # '--- Summary: f/t/c: ...', where f = # failures, t = # test points,
86 # c = # test cases.
87 if (re.search(r'^--- Summary:', line)):
88 try:
89 if line.count(':') == 1:
90 (summary, data) = re.split(r':', line)
91 else:
92 (summary, data, rest) = re.split(r':', line)
94 (nfailures, ntests, ncases) = re.split(r'/', data)
95 tests = tests + number_from_string(ntests)
96 cases = cases + number_from_string(ncases)
97 except ValueError:
98 print("Bad summary line:", line)
99 nfailures = '1'
100 failures = failures + number_from_string(nfailures)
101 if (number_from_string(nfailures)):
102 print("Failure: %s" % safe_name)
104 # '--- Simulator: b/t: ...', where b = # bytes, t = # ticks
105 if (re.search(r'^--- Simulator:', line)):
106 try:
107 (simulator, data, rest) = re.split(r':', line)
108 (nbytes, nticks) = re.split(r'/', data)
109 except ValueError:
110 print("Bad simulator line:", line)
111 else:
112 bytes = bytes + float(nbytes)
113 ticks = ticks + float(nticks)
115 # Stop at 0x000228: (106) Invalid instruction 0x00fd
116 if (re.search(r'Invalid instruction', line) or re.search(r'unknown instruction', line)):
117 invalid += 1;
118 print("Invalid instruction: %s" % safe_name)
120 # Stop at 0xXXXXXX: (103) Stack overflow
121 if (re.search(r'Stack overflow', line)):
122 stack_overflow += 1
123 print("Stack overflow: %s" % safe_name)
126 print("%-35.35s" % sys.argv[1], end=' ')
128 if (invalid > 0):
129 print("%d invalid instructions," % invalid, end=' ')
130 print("(f: %2.0f, t:%4.0f, c: %4.0f, b: %7.0f, T: %9.0f)" % (failures, tests, cases, bytes, ticks))