This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
forked from AMReX-Codes/regression_testing
-
Notifications
You must be signed in to change notification settings - Fork 3
/
reg_test_gc.py
executable file
·201 lines (158 loc) · 4.5 KB
/
reg_test_gc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env python
import os
import shutil
import sys
import getopt
import string
import argparse
import test_util
import params
import test_report as report
def reg_test_gc(argv):
usage = """
./reg_test_gc [--before|-b 2000-00-00]
testfile.ini
"""
if len(sys.argv) == 1:
print usage
sys.exit(2)
try:
opts, next = getopt.getopt(argv[1:], "b:",
["before="])
except getopt.GetoptError:
print "invalid calling sequence"
print usage
sys.exit(2)
# defaults
gcdate = ""
for o, a in opts:
if o == "--before" or o == "-b" :
gcdate = a
try:
testFile = next[0]
except IndexError:
print "ERROR: a test file was not specified"
print usage
sys.exit(2)
if not gcdate:
print "ERROR: date was not specified"
print usage
sys.exit(2)
gcd = valid_date(gcdate)
if gcd == '':
print "ERROR: invalid date", gcdate
print usage
sys.exit(2)
workdir = os.getcwd()
print "loading ", testFile
args=test_util.get_args([testFile])
suite, testList = params.load_params(args)
activeTestList = [t.name for t in testList]
benchmarkTestList = [t for t in testList if not (t.compileTest or t.restartTest)]
benchmarkNotFound = {}
for t in benchmarkTestList:
benchmarkNotFound[t.name] = ''
### clean up the web dir
print "\ncleaning ", suite.webTopDir
os.chdir(suite.webTopDir)
validDirs = []
for d in os.listdir(suite.webTopDir):
if (d.startswith("20") and os.path.isdir(d)):
statusFile = d + '/' + d + '.status'
if (os.path.isfile(statusFile)):
validDirs.append(d)
validDirs.sort()
validDirs.reverse()
latestBMDate = {}
for d in validDirs:
bmtests = benchmarkNotFound.keys()
if d >= gcd and bmtests:
if isBenchmarkDir(d):
for t in bmtests:
if findBenchmark(d,t):
del benchmarkNotFound[t]
latestBMDate[t] = d
else:
if isBenchmarkDir(d) and bmtests:
found = False
for t in bmtests:
if findBenchmark(d,t):
found = True
del benchmarkNotFound[t]
latestBMDate[t] = d
if not found:
rmDir(d)
else:
rmDir(d)
### clean up the test dir
testDirs = os.path.join(suite.testTopDir,suite.suiteName+"-tests")
print "\ncleaning ", testDirs
os.chdir(testDirs)
validDirs = []
for d in os.listdir(testDirs):
if (d.startswith("20") and os.path.isdir(d)):
validDirs.append(d)
validDirs.sort()
validDirs.reverse()
for d in validDirs:
if d < gcd:
tests = [t for t in os.listdir(d) if os.path.isdir(os.path.join(d,t))]
found = False
for t in tests:
if t in latestBMDate.keys() and latestBMDate[t] == d:
found = True
break
if not found:
rmDir(d)
print "\ncreating suite report..."
report.report_all_runs(suite, activeTestList)
print "\nGarbage cleaning finished."
def valid_date(gcdate):
try:
y,m,d = gcdate.split("-")
except ValueError:
return ''
try:
yi = int(y)
if yi > 2099 or yi < 2000:
return ''
except ValueError:
return ''
try:
mi = int(m)
if mi > 12 or mi < 1:
print 'm='+m+'!'
return ''
except ValueError:
return ''
try:
di = int(d)
if di > 31 or di < 1:
return ''
except ValueError:
return ''
return '-'.join([y,m.zfill(2),d.zfill(2)])
def isBenchmarkDir(d):
f = open(os.path.join(d,d+'.status'), 'r')
line = f.readline()
f.close()
if string.find(line, 'BENCHMARKS UPDATED') == -1:
return False
else:
return True
def findBenchmark(d, t):
try:
f = open(os.path.join(d,t+'.status'), 'r')
except:
return False
line = f.readline()
f.close()
if string.find(line, 'benchmarks updated') == -1:
return False
else:
return True
def rmDir(d):
print ' deleting', d
shutil.rmtree(d)
if __name__== "__main__":
reg_test_gc(sys.argv)