dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / kernel-cache-tests / testall.py
1 #!/usr/bin/python2.7
2
3 import string
4 import os
5 import json
6 import sys
7 import imp
8 import os.path
9 import traceback
10
11 sys.dont_write_bytecode = True
12
13 import KernelCollection
14
15
16 if __name__ == "__main__":
17 test_dir = os.path.realpath(os.path.dirname(__file__))
18 sys.path.append(test_dir)
19 all_tests = os.listdir(test_dir)
20 all_tests.sort()
21 test_to_run = ""
22 if len(sys.argv) == 2:
23 test_to_run = sys.argv[1]
24 all_tests = [ test_to_run ]
25 for f in all_tests:
26 test_case = test_dir + "/" + f + "/test.py"
27 if os.path.isfile(test_case):
28 py_mod = imp.load_source(f, test_case)
29 check_func = getattr(py_mod, "check", 0)
30 if check_func == 0:
31 print "FAIL: " + f + ", missing check() function";
32 else:
33 try:
34 kernelCollection = KernelCollection.KernelCollection(test_to_run != "")
35 check_func(kernelCollection)
36 print "PASS: " + f
37 except AssertionError, e:
38 _, _, tb = sys.exc_info()
39 tb_info = traceback.extract_tb(tb)
40 filename, line, func, text = tb_info[-1]
41 print "FAIL: " + f + ", " + text
42 except KeyError, e:
43 _, _, tb = sys.exc_info()
44 tb_info = traceback.extract_tb(tb)
45 filename, line, func, text = tb_info[-1]
46 print "FAIL: " + f + ", " + text
47