]> git.saurik.com Git - apple/dyld.git/blame - testing/run_all_dyld_tests.py
dyld-851.27.tar.gz
[apple/dyld.git] / testing / run_all_dyld_tests.py
CommitLineData
9f83892a
A
1#!/usr/bin/python2.7
2
3import plistlib
4import string
5import sys
6import os
7import shutil
8import subprocess
9
10
11
12
13#
14# Parse dyld's BATS input file and run each test
15#
16if __name__ == "__main__":
17 batsPlist = plistlib.readPlist("/AppleInternal/CoreOS/BATS/unit_tests/dyld.plist")
18 tests = batsPlist["Tests"]
19 passedCount = 0
20 failedCount = 0
21 for test in tests:
22 cwd = test["WorkingDirectory"]
23 if cwd:
24 os.chdir(cwd)
25 cmd = test["Command"]
26 testName = test["TestName"]
27 if cwd:
28 try:
29 runOutput = subprocess.check_output(cmd,stderr= subprocess.STDOUT)
30 lines = runOutput.splitlines()
31 foundBegin = False
32 passed = False
33 failed = False
34 currentTestName = ""
35 for line in lines:
36 line = line.lstrip().rstrip()
37 #print testName + ": " + line
38 beginIndex = string.find(line, "[BEGIN]")
39 if beginIndex != -1:
40 beginName = line[beginIndex + 7:].lstrip()
41 foundBegin = True
42 currentTestName = beginName
43 passIndex = string.find(line, "[PASS]")
44 if passIndex != -1:
45 passName = line[passIndex + 6:].lstrip()
46 passed = True
47 if passName != currentTestName:
48 print >> sys.stderr, "[PASS] name does not match [BEGIN] name for test " + testName
49 failIndex = string.find(line, "[FAIL]")
50 if failIndex != -1:
51 failName = line[failIndex + 6:].lstrip()
52 failed = True
53 if failName != currentTestName:
54 print >> sys.stderr, "[FAIL] name does not match [BEGIN] name for test " + testName
55 if foundBegin:
56 if not passed and not failed:
57 print >> sys.stderr, "[BEGIN] found [PASS] or [FAIL] for test " + testName
58 else:
59 print >> sys.stderr, "Missing [BEGIN] for test " + testName
60 if passed:
61 print "PASSED: " + testName
62 passedCount = passedCount + 1
63 elif failed:
64 print "FAILED: " + testName
65 failedCount = failedCount + 1
66 except subprocess.CalledProcessError as e:
67 print >> sys.stderr, "FAILED: " + testName + " (execution failure)"
68 print "Total PASS count: " + str(passedCount)
69 print "Total FAIL count: " + str(failedCount)
70
71
72def alt():
73 testsTopDir = "/AppleInternal/CoreOS/tests/dyld/"
74 for f in os.listdir(testsTopDir):
75 testRunner = testsTopDir + f + "/run.sh"
76 if os.path.isfile(testRunner):
77 try:
78 runOutput = subprocess.check_output([testRunner],stderr= subprocess.STDOUT)
79 lines = runOutput.splitlines()
80 foundBegin = False
81 passed = False
82 failed = False
83 currentTestName = ""
84 for line in lines:
85 line = line.lstrip().rstrip()
86 #print f + ": " + line
87 beginIndex = string.find(line, "[BEGIN]")
88 if beginIndex != -1:
89 beginName = line[beginIndex + 7:].lstrip()
90 foundBegin = True
91 currentTestName = beginName
92 passIndex = string.find(line, "[PASS]")
93 if passIndex != -1:
94 passName = line[passIndex + 6:].lstrip()
95 passed = True
96 if passName != currentTestName:
97 print >> sys.stderr, "[PASS] name does not match [BEGIN] name for test " + f
98 failIndex = string.find(line, "[FAIL]")
99 if failIndex != -1:
100 failName = line[failIndex + 6:].lstrip()
101 failed = True
102 if failName != currentTestName:
103 print >> sys.stderr, "[FAIL] name does not match [BEGIN] name for test " + f
104 if foundBegin:
105 if not passed and not failed:
106 print >> sys.stderr, "[BEGIN] found [PASS] or [FAIL] for test " + f
107 else:
108 print >> sys.stderr, "Missing [BEGIN] for test " + f
109 if passed:
110 print "PASSED: " + f
111 elif failed:
112 print "FAILED: " + f
113 except subprocess.CalledProcessError as e:
114 print >> sys.stderr, "FAILED: " + f + " (execution failure)"