modcheck.py 2.01 KB
Newer Older
1 2 3 4
#!/usr/bin/python
import os,sys
import subprocess

5 6 7 8 9

print "Scroll down for summary"
print ""
print ""

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
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():
37
  command = 'make dummy '
38 39 40 41 42 43 44 45
  deps = get_deps(k)
  for i in mods.keys():
    if i in deps:
      command += i + "=1 "
    else:
      command += i + "=0 "
  commands.append(command)

Toon Peters's avatar
Toon Peters committed
46 47 48
endResult = []
failed = 0

49
for i in commands:
Daniele Lacamera's avatar
Daniele Lacamera committed
50
  print 'Checking config:\n\t%s' % i
Toon Peters's avatar
Toon Peters committed
51 52

  subprocess.call(['make','clean'])
53 54 55
  sys.stdout.flush()
  sys.stderr.flush()

56
  args = i.split(' ')
Toon Peters's avatar
Toon Peters committed
57

58 59 60 61 62 63
  # Remove the last item (which is a blank)
  ret = subprocess.call(args[:-1])
  sys.stdout.flush()
  sys.stderr.flush()

  if ret == 0:
Toon Peters's avatar
Toon Peters committed
64 65 66 67 68 69 70 71 72 73
    print "**********************************************************"
    print "*******************  CONFIG PASSED!  *******************"
    endResult.append({"test": i, "result": "PASS"})
  else:
    failed += 1
    print "**********************************************************"
    print "*******************  CONFIG FAILED!  *******************"
    endResult.append({"test": i, "result": "FAIL"})
  print "**********************************************************"

74 75 76 77 78 79
print ""
print "***************************************************************************"
print "                           Executive Summary"
print "***************************************************************************"
print ""

Toon Peters's avatar
Toon Peters committed
80 81 82 83 84 85 86 87 88
for r in endResult:
  print "Test:", r["test"]
  print "Status:", r["result"]
  print ""

print "***********************"
print "%d out of %d Failed" % (failed, len(endResult))
print "***********************"

89 90 91 92
if failed:
  sys.exit(1)
else:
  sys.exit(0)