-
Notifications
You must be signed in to change notification settings - Fork 219
/
modcheck.py
executable file
·92 lines (75 loc) · 2.01 KB
/
modcheck.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
#!/usr/bin/python
import os,sys
import subprocess
print "Scroll down for summary"
print ""
print ""
f = open('MODTREE')
mods = {}
commands = []
def get_deps(mod):
if not mod in mods.keys():
return []
deps = mods[mod]
retlist = [mod]
for i in deps.split(' '):
retlist.append(i)
for j in get_deps(i):
retlist.append(j)
return retlist
while(True):
r = f.readline()
if r == '':
break
if r != '\n':
strings = r.split(':')
mod = strings[0]
deps = strings[1].rstrip('\n')
mods[mod] = deps.strip(' ')
for k,v in mods.iteritems():
command = 'make dummy '
deps = get_deps(k)
for i in mods.keys():
if i in deps:
command += i + "=1 "
else:
command += i + "=0 "
commands.append(command)
endResult = []
failed = 0
for i in commands:
print 'Checking config:\n\t%s' % i
subprocess.call(['make','clean'])
sys.stdout.flush()
sys.stderr.flush()
args = i.split(' ')
# Remove the last item (which is a blank)
ret = subprocess.call(args[:-1])
sys.stdout.flush()
sys.stderr.flush()
if ret == 0:
print "**********************************************************"
print "******************* CONFIG PASSED! *******************"
endResult.append({"test": i, "result": "PASS"})
else:
failed += 1
print "**********************************************************"
print "******************* CONFIG FAILED! *******************"
endResult.append({"test": i, "result": "FAIL"})
print "**********************************************************"
print ""
print "***************************************************************************"
print " Executive Summary"
print "***************************************************************************"
print ""
for r in endResult:
print "Test:", r["test"]
print "Status:", r["result"]
print ""
print "***********************"
print "%d out of %d Failed" % (failed, len(endResult))
print "***********************"
if failed:
sys.exit(1)
else:
sys.exit(0)