Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/test/gpu/generate_webgl_conformance_test_list.py

Issue 8885003: Fix webgl conformance test list generation script. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/gpu/webgl_conformance_test_expectations.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Auto-generates the WebGL conformance test list header file. 6 """Auto-generates the WebGL conformance test list header file.
7 7
8 Parses the WebGL conformance test *.txt file, which contains a list of URLs 8 Parses the WebGL conformance test *.txt file, which contains a list of URLs
9 for individual conformance tests (each on a new line). It recursively parses 9 for individual conformance tests (each on a new line). It recursively parses
10 *.txt files. For each test URL, the matching gtest call is created and 10 *.txt files. For each test URL, the matching gtest call is created and
(...skipping 27 matching lines...) Expand all
38 38
39 """ 39 """
40 40
41 # Assume this script is run from the src/chrome/test/gpu directory. 41 # Assume this script is run from the src/chrome/test/gpu directory.
42 INPUT_DIR = "../../../third_party/webgl_conformance" 42 INPUT_DIR = "../../../third_party/webgl_conformance"
43 INPUT_FILE = "00_test_list.txt" 43 INPUT_FILE = "00_test_list.txt"
44 OUTPUT_FILE = "webgl_conformance_test_list_autogen.h" 44 OUTPUT_FILE = "webgl_conformance_test_list_autogen.h"
45 EXPECTATION_FILE = "webgl_conformance_test_expectations.txt" 45 EXPECTATION_FILE = "webgl_conformance_test_expectations.txt"
46 EXPECTATION_REGEXP = re.compile( 46 EXPECTATION_REGEXP = re.compile(
47 r'^(?P<BUG>\S+)\s+' 47 r'^(?P<BUG>\S+)\s+'
48 '(?P<OS>(\s*(WIN|MAC|LINUX)\s*)+):' 48 '(?P<MODIFIER>(\s*(WIN|MAC|LINUX|RELEASE|DEBUG)\s*)+):'
49 '(?P<TEST>[^=]+)=' 49 '(?P<TEST>[^=]+)='
50 '(?P<OUTCOME>(\s*(PASS|FAIL|TIMEOUT)\s*)+)') 50 '(?P<OUTCOME>(\s*(PASS|FAIL|TIMEOUT)\s*)+)')
51 51
52 def is_matching_os(expected_os_list): 52 def map_to_macro_conditions(modifier_list):
53 """Returns true if the current OS is in the given list. 53 """Returns a string containing macro conditions wrapped in '(*)'.
54 54
55 Given a list containing 'WIN', 'MAC' or 'LINUX', return true if the current 55 Given a list containing 'WIN', 'MAC', 'LINUX', 'RELEASE', or 'DEBUG',
56 OS, represented as 'win32', 'darwin' or 'linux*', respectively, exists in the 56 return the corresponding macro conditions.
57 list.
58 """ 57 """
59 if sys.platform.startswith('linux') and 'LINUX' in expected_os_list: 58 rt = ''
60 return True; 59 release = False
61 if sys.platform == 'darwin' and 'MAC' in expected_os_list: 60 debug = False
62 return True; 61 for modifier in modifier_list:
63 if sys.platform == 'win32' and 'WIN' in expected_os_list: 62 if modifier == 'RELEASE':
64 return True; 63 release = True
65 return False; 64 elif modifier == 'DEBUG':
65 debug = True
66 else:
67 if rt:
68 rt += ' || '
69 if modifier == 'WIN':
70 rt = rt + 'defined(OS_WIN)'
71 elif modifier == 'MAC':
72 rt = rt + 'defined(OS_MACOSX)'
73 elif modifier == 'LINUX':
74 rt = rt + 'defined(OS_LINUX)'
75
76 if release == debug:
77 return rt
78
79 if rt:
80 rt = '(' + rt + ') and '
Ken Russell (switch to Gerrit) 2011/12/08 23:36:25 Shouldn't "and" be "&&"? If so is it possible to
Zhenyao Mo 2011/12/09 19:21:39 Thanks for catching this. I manually added a LINUX
81
82 if debug:
83 rt = rt + '!defined(NDEBUG)'
84 if release:
85 rt = rt + 'defined(NDEBUG)'
86
87 return rt
66 88
67 def main(argv): 89 def main(argv):
68 """Main function for the WebGL conformance test list generator. 90 """Main function for the WebGL conformance test list generator.
69 """ 91 """
70
71 if not os.path.exists(os.path.join(INPUT_DIR, INPUT_FILE)): 92 if not os.path.exists(os.path.join(INPUT_DIR, INPUT_FILE)):
72 print >> sys.stderr, "ERROR: WebGL conformance tests do not exist." 93 print >> sys.stderr, "ERROR: WebGL conformance tests do not exist."
73 print >> sys.stderr, "Run the script from the directory containing it." 94 print >> sys.stderr, "Run the script from the directory containing it."
74 return 1 95 return 1
75 if not os.path.exists(EXPECTATION_FILE): 96 if not os.path.exists(EXPECTATION_FILE):
76 print >> sys.stderr, "ERROR: test expectations file does not exist." 97 print >> sys.stderr, "ERROR: test expectations file does not exist."
77 print >> sys.stderr, "Run the script from the directory containing it." 98 print >> sys.stderr, "Run the script from the directory containing it."
78 return 1 99 return 1
79 100
101 output = open(OUTPUT_FILE, "w")
102 output.write(COPYRIGHT)
103 output.write(WARNING)
104 output.write(HEADER_GUARD)
105
80 test_prefix = {} 106 test_prefix = {}
81 test_expectations = open(EXPECTATION_FILE) 107 test_expectations = open(EXPECTATION_FILE)
82 for line in test_expectations: 108 for line in test_expectations:
83 line_match = EXPECTATION_REGEXP.match(line) 109 line_match = EXPECTATION_REGEXP.match(line)
84 if line_match: 110 if line_match:
85 match_dict = line_match.groupdict() 111 match_dict = line_match.groupdict()
86 os_list = match_dict['OS'].strip().split() 112 modifier_list = match_dict['MODIFIER'].strip().split()
87 if not is_matching_os(os_list): 113 macro_conditions = map_to_macro_conditions(modifier_list)
88 continue
89 test = match_dict['TEST'].strip() 114 test = match_dict['TEST'].strip()
90 outcome_list = match_dict['OUTCOME'].strip().split() 115 outcome_list = match_dict['OUTCOME'].strip().split()
91 if 'TIMEOUT' in outcome_list: 116 if 'TIMEOUT' in outcome_list:
92 test_prefix[test] = "DISABLED_" 117 prefix = "DISABLED_"
93 elif 'FAIL' in outcome_list: 118 elif 'FAIL' in outcome_list:
94 if 'PASS' in outcome_list: 119 if 'PASS' in outcome_list:
95 test_prefix[test] = "FLAKY_" 120 prefix = "FLAKY_"
96 else: 121 else:
97 test_prefix[test] = "FAILS_" 122 prefix = "FAILS_"
123 if macro_conditions:
124 output.write('#if %s\n' % macro_conditions)
125 output.write('#define MAYBE_%s %s%s\n' % (test, prefix, test))
126 output.write('#elif !defined(MAYBE_%s)\n' % test)
127 output.write('#define MAYBE_%s %s\n' % (test, test))
128 output.write('#endif\n')
129 test_prefix[test] = 'MAYBE_'
130 else:
131 test_prefix[test] = prefix
98 test_expectations.close() 132 test_expectations.close()
99 133
100 output = open(OUTPUT_FILE, "w")
101 output.write(COPYRIGHT)
102 output.write(WARNING)
103 output.write(HEADER_GUARD)
104
105 unparsed_files = [INPUT_FILE] 134 unparsed_files = [INPUT_FILE]
106 while unparsed_files: 135 while unparsed_files:
107 filename = unparsed_files.pop(0) 136 filename = unparsed_files.pop(0)
108 try: 137 try:
109 input = open(os.path.join(INPUT_DIR, filename)) 138 input = open(os.path.join(INPUT_DIR, filename))
110 except IOError: 139 except IOError:
111 print >> sys.stderr, "WARNING: %s does not exist (skipped)." % filename 140 print >> sys.stderr, "WARNING: %s does not exist (skipped)." % filename
112 continue 141 continue
113 142
114 for url in input: 143 for url in input:
(...skipping 26 matching lines...) Expand all
141 else: 170 else:
142 print >> sys.stderr, "WARNING: %s does not exist (skipped)." % url 171 print >> sys.stderr, "WARNING: %s does not exist (skipped)." % url
143 input.close() 172 input.close()
144 173
145 output.write(HEADER_GUARD_END) 174 output.write(HEADER_GUARD_END)
146 output.close() 175 output.close()
147 return 0 176 return 0
148 177
149 if __name__ == "__main__": 178 if __name__ == "__main__":
150 sys.exit(main(sys.argv[1:])) 179 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | chrome/test/gpu/webgl_conformance_test_expectations.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698