blob: 7629c8b4fbf1d2d6f8881270171ee2ec04361477 [file] [log] [blame]
Duncan Sands067e2e22011-03-25 07:17:44 +00001#!/usr/bin/python
Bill Wendling3a8eaa72011-10-20 00:45:46 +00002import re, string, sys, os, time, math
Duncan Sands067e2e22011-03-25 07:17:44 +00003
4DEBUG = 0
Duncan Sands067e2e22011-03-25 07:17:44 +00005
Bill Wendling3a8eaa72011-10-20 00:45:46 +00006(tp, exp) = ('compile', 'exec')
Duncan Sands067e2e22011-03-25 07:17:44 +00007
8def parse(file):
Bill Wendling3a8eaa72011-10-20 00:45:46 +00009 f = open(file, 'r')
Duncan Sands067e2e22011-03-25 07:17:44 +000010 d = f.read()
11
Bill Wendling3a8eaa72011-10-20 00:45:46 +000012 # Cleanup weird stuff
13 d = re.sub(r',\d+:\d', '', d)
14
Duncan Sands067e2e22011-03-25 07:17:44 +000015 r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000016
Duncan Sands067e2e22011-03-25 07:17:44 +000017 test = {}
18 fname = ''
19 for t in r:
20 if DEBUG:
21 print t
Bill Wendling3a8eaa72011-10-20 00:45:46 +000022
Duncan Sands067e2e22011-03-25 07:17:44 +000023 if t[0] == 'PASS' or t[0] == 'FAIL' :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000024 tmp = t[2].split('llvm-test/')
Duncan Sands067e2e22011-03-25 07:17:44 +000025
26 if DEBUG:
27 print tmp
Bill Wendling3a8eaa72011-10-20 00:45:46 +000028
Duncan Sands067e2e22011-03-25 07:17:44 +000029 if len(tmp) == 2:
30 fname = tmp[1].strip('\r\n')
31 else:
32 fname = tmp[0].strip('\r\n')
Bill Wendling3a8eaa72011-10-20 00:45:46 +000033
34 if not test.has_key(fname):
Duncan Sands067e2e22011-03-25 07:17:44 +000035 test[fname] = {}
Bill Wendling3a8eaa72011-10-20 00:45:46 +000036
37 test[fname][t[1] + ' state'] = t[0]
38 test[fname][t[1] + ' time'] = float('nan')
Duncan Sands067e2e22011-03-25 07:17:44 +000039 else :
40 try:
41 n = t[0].split('RESULT-')[1]
Bill Wendling3a8eaa72011-10-20 00:45:46 +000042
Duncan Sands067e2e22011-03-25 07:17:44 +000043 if DEBUG:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000044 print "n == ", n;
Duncan Sands067e2e22011-03-25 07:17:44 +000045
Bill Wendling3a8eaa72011-10-20 00:45:46 +000046 if n == 'compile-success':
47 test[fname]['compile time'] = float(t[2].split('program')[1].strip('\r\n'))
48
49 elif n == 'exec-success':
50 test[fname]['exec time'] = float(t[2].split('program')[1].strip('\r\n'))
Duncan Sands067e2e22011-03-25 07:17:44 +000051 if DEBUG:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000052 print test[fname][string.replace(n, '-success', '')]
53
Duncan Sands067e2e22011-03-25 07:17:44 +000054 else :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000055 # print "ERROR!"
Duncan Sands067e2e22011-03-25 07:17:44 +000056 sys.exit(1)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000057
Duncan Sands067e2e22011-03-25 07:17:44 +000058 except:
59 continue
60
61 return test
62
63# Diff results and look for regressions.
64def diffResults(d_old, d_new):
65
66 for t in sorted(d_old.keys()) :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000067 if d_new.has_key(t):
68
Duncan Sands067e2e22011-03-25 07:17:44 +000069 # Check if the test passed or failed.
Bill Wendling3a8eaa72011-10-20 00:45:46 +000070 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
71
72 if not d_old[t].has_key(x) and not d_new[t].has_key(x):
73 continue
74
Duncan Sands067e2e22011-03-25 07:17:44 +000075 if d_old[t].has_key(x):
76 if d_new[t].has_key(x):
Bill Wendling3a8eaa72011-10-20 00:45:46 +000077
Duncan Sands067e2e22011-03-25 07:17:44 +000078 if d_old[t][x] == 'PASS':
79 if d_new[t][x] != 'PASS':
Bill Wendling3a8eaa72011-10-20 00:45:46 +000080 print t + " *** REGRESSION (" + x + " now fails)"
Duncan Sands067e2e22011-03-25 07:17:44 +000081 else:
82 if d_new[t][x] == 'PASS':
Bill Wendling3a8eaa72011-10-20 00:45:46 +000083 print t + " * NEW PASS (" + x + " now fails)"
Duncan Sands067e2e22011-03-25 07:17:44 +000084
Duncan Sands067e2e22011-03-25 07:17:44 +000085 else :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000086 print t + "*** REGRESSION (" + x + " now fails)"
87
88 if x == 'compile state' or x == 'exec state':
89 continue
90
91 # For execution time, if there is no result it's a fail.
92 if not d_old[t].has_key(x) and not d_new[t].has_key(x):
93 continue
94 elif not d_new[t].has_key(x):
95 print t + " *** REGRESSION (" + x + ")"
96 elif not d_old[t].has_key(x):
97 print t + " * NEW PASS (" + x + ")"
98
99 if math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
100 continue
101
102 elif math.isnan(d_old[t][x]) and not math.isnan(d_new[t][x]):
103 print t + " * NEW PASS (" + x + ")"
104
105 elif not math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
106 print t + " *** REGRESSION (" + x + ")"
107
108 if d_new[t][x] > d_old[t][x] and \
109 (d_new[t][x] - d_old[t][x]) / d_new[t][x] > .05:
110 print t + " *** REGRESSION (" + x + ")"
111
Duncan Sands067e2e22011-03-25 07:17:44 +0000112 else :
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000113 print t + ": Removed from test-suite."
Duncan Sands067e2e22011-03-25 07:17:44 +0000114
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000115# Main
Duncan Sands067e2e22011-03-25 07:17:44 +0000116if len(sys.argv) < 3 :
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000117 print 'Usage:', sys.argv[0], '<old log> <new log>'
118 sys.exit(-1)
Duncan Sands067e2e22011-03-25 07:17:44 +0000119
120d_old = parse(sys.argv[1])
121d_new = parse(sys.argv[2])
122
Duncan Sands067e2e22011-03-25 07:17:44 +0000123diffResults(d_old, d_new)