]> git.saurik.com Git - apple/security.git/blob - tests/TrustTests/gen_test_plist.py
Security-59306.11.20.tar.gz
[apple/security.git] / tests / TrustTests / gen_test_plist.py
1 #!/usr/bin/python
2 import sys
3 import Foundation
4 from glob import glob
5 import re
6 import os
7
8 test_dir = sys.argv[1]
9 outfile = sys.argv[2]
10
11 test_plist = Foundation.NSMutableDictionary.dictionary()
12 test_plist['Project'] = 'Security'
13 test_list = Foundation.NSMutableArray.array()
14
15 test_files = glob(test_dir + '/*/*.m')
16
17 for filename in test_files:
18 f = open(filename, 'r')
19 for line in f:
20 match = re.search('@interface ([a-zA-Z0-9_]+) ?: ?Trust[a-zA-Z0-9_]+TestCase', line)
21 if match:
22 regex_string = test_dir + '/([a-zA-Z0-9_]+/)'
23 test_dir_match = re.search(regex_string, filename)
24 if not test_dir_match:
25 print 'failed to find test dir name for ' + filename + " with regex " + regex_string
26 sys.exit(1)
27 test_dictionary = Foundation.NSMutableDictionary.dictionary()
28 test_dictionary['TestName'] = test_dir_match.group(1) + match.group(1)
29 test_dictionary['ShowSubtestResults']= True
30 test_dictionary['WorkingDirectory'] = '/AppleInternal/XCTests/com.apple.security/'
31 test_dictionary['AsRoot'] = True
32
33 test_command = Foundation.NSMutableArray.array()
34 test_command.append('/AppleInternal/CoreOS/tests/Security/TrustTests')
35 test_command.append('-c ' + match.group(1))
36 test_command.append('-t TrustTests')
37
38 test_dictionary['Command'] = test_command
39
40 test_list.append(test_dictionary)
41 f.close()
42
43 test_plist['Tests'] = test_list
44
45 out_dir = os.path.dirname(outfile)
46 if not os.path.exists(out_dir):
47 os.makedirs(out_dir)
48 success = test_plist.writeToFile_atomically_(outfile, 1)
49 if not success:
50 print "test plist failed to write, error!"
51 sys.exit(1)