Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 2 | import re, string, sys, os, time, math |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 3 | |
| 4 | DEBUG = 0 |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 5 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 6 | (tp, exp) = ('compile', 'exec') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 7 | |
| 8 | def parse(file): |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 9 | f = open(file, 'r') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 10 | d = f.read() |
| 11 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 12 | # Cleanup weird stuff |
| 13 | d = re.sub(r',\d+:\d', '', d) |
| 14 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 15 | r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 16 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 17 | test = {} |
| 18 | fname = '' |
| 19 | for t in r: |
| 20 | if DEBUG: |
| 21 | print t |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 22 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 23 | if t[0] == 'PASS' or t[0] == 'FAIL' : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 24 | tmp = t[2].split('llvm-test/') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 25 | |
| 26 | if DEBUG: |
| 27 | print tmp |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 28 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 29 | if len(tmp) == 2: |
| 30 | fname = tmp[1].strip('\r\n') |
| 31 | else: |
| 32 | fname = tmp[0].strip('\r\n') |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 33 | |
| 34 | if not test.has_key(fname): |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 35 | test[fname] = {} |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 36 | |
| 37 | test[fname][t[1] + ' state'] = t[0] |
| 38 | test[fname][t[1] + ' time'] = float('nan') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 39 | else : |
| 40 | try: |
| 41 | n = t[0].split('RESULT-')[1] |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 42 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 43 | if DEBUG: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 44 | print "n == ", n; |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 45 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 46 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 51 | if DEBUG: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 52 | print test[fname][string.replace(n, '-success', '')] |
| 53 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 54 | else : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 55 | # print "ERROR!" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 56 | sys.exit(1) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 57 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 58 | except: |
| 59 | continue |
| 60 | |
| 61 | return test |
| 62 | |
| 63 | # Diff results and look for regressions. |
| 64 | def diffResults(d_old, d_new): |
| 65 | |
| 66 | for t in sorted(d_old.keys()) : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 67 | if d_new.has_key(t): |
| 68 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 69 | # Check if the test passed or failed. |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 70 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 75 | if d_old[t].has_key(x): |
| 76 | if d_new[t].has_key(x): |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 77 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 78 | if d_old[t][x] == 'PASS': |
| 79 | if d_new[t][x] != 'PASS': |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 80 | print t + " *** REGRESSION (" + x + " now fails)" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 81 | else: |
| 82 | if d_new[t][x] == 'PASS': |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 83 | print t + " * NEW PASS (" + x + " now fails)" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 84 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 85 | else : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 86 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 112 | else : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 113 | print t + ": Removed from test-suite." |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 114 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 115 | # Main |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 116 | if len(sys.argv) < 3 : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame^] | 117 | print 'Usage:', sys.argv[0], '<old log> <new log>' |
| 118 | sys.exit(-1) |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 119 | |
| 120 | d_old = parse(sys.argv[1]) |
| 121 | d_new = parse(sys.argv[2]) |
| 122 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 123 | diffResults(d_old, d_new) |