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

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

Issue 7563021: Added WebGL conformance test expectation script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated regex. Created 9 years, 4 months 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 | « chrome/chrome_tests.gypi ('k') | 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
11 sent to the C++ header file. 11 sent to the C++ header file.
12 """ 12 """
13 13
14 __author__ = 'jrt@chromium.org (Joe Tessler)'
15
16 import getopt 14 import getopt
17 import os 15 import os
18 import re 16 import re
19 import sys 17 import sys
20 18
21 COPYRIGHT = """\ 19 COPYRIGHT = """\
22 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 20 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
23 // Use of this source code is governed by a BSD-style license that can be 21 // Use of this source code is governed by a BSD-style license that can be
24 // found in the LICENSE file. 22 // found in the LICENSE file.
25 23
26 """ 24 """
27 WARNING = """\ 25 WARNING = """\
28 // This file is auto-generated from a script. DO NOT EDIT! 26 // This file is auto-generated from a script. DO NOT EDIT!
29 // It is included by webgl_conformance_tests.cc 27 // It is included by webgl_conformance_tests.cc
30 28
31 """ 29 """
32 HEADER_GUARD = """\ 30 HEADER_GUARD = """\
33 #ifndef CHROME_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_ 31 #ifndef CHROME_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_
34 #define CHROME_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_ 32 #define CHROME_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_
35 33
36 """ 34 """
37 HEADER_GUARD_END = """ 35 HEADER_GUARD_END = """
38 #endif // CHROME_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_ 36 #endif // CHROME_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_
39 """ 37 """
40 38
41 # Assume this script is run from the src/chrome/ directory. 39 # Assume this script is run from the src/chrome/ directory.
42 INPUT_DIR = "../third_party/webgl_conformance" 40 INPUT_DIR = "../third_party/webgl_conformance"
43 INPUT_FILE = "00_test_list.txt" 41 INPUT_FILE = "00_test_list.txt"
42 EXPECTATION_FILE = "test/gpu/webgl_conformance_test_expectations.txt"
43 EXPECTATION_REGEXP = re.compile(
44 r'^(?P<BUG>\S+)\s+'
45 '(?P<OS>(\s*(WIN|MAC|LINUX)\s*)+):'
46 '(?P<TEST>[^=]+)='
47 '(?P<OUTCOME>(\s*(PASS|FAIL|TIMEOUT)\s*)+)')
48
49 def is_matching_os(expected_os_list):
50 """Returns true if the current OS is in the given list.
51
52 Given a list containing 'WIN', 'MAC' or 'LINUX', return true if the current
53 OS, represented as 'win32', 'darwin' or 'linux*', respectively, exists in the
54 list.
55 """
56 if sys.platform.startswith('linux') and 'LINUX' in expected_os_list:
57 return True;
58 if sys.platform == 'darwin' and 'MAC' in expected_os_list:
59 return True;
60 if sys.platform == 'win32' and 'WIN' in expected_os_list:
61 return True;
62 return False;
44 63
45 def main(argv): 64 def main(argv):
46 """Main function for the WebGL conformance test list generator. 65 """Main function for the WebGL conformance test list generator.
47 66
48 If "-i" or "--input" is specified, the parsed *.txt files are printed to 67 If "-i" or "--input" is specified, the parsed *.txt files are printed to
49 standard output and no header file is generated. In this case, "output" 68 standard output and no header file is generated. In this case, "output"
50 is os.devnull, meaning all output.write() calls are NOPs. 69 is os.devnull, meaning all output.write() calls are NOPs.
51 """ 70 """
52 try: 71 try:
53 opts, args = getopt.getopt(argv, "i", "input") 72 opts, args = getopt.getopt(argv, "i", "input")
(...skipping 11 matching lines...) Expand all
65 elif len(args) == 1: 84 elif len(args) == 1:
66 output_file = args[0] 85 output_file = args[0]
67 else: 86 else:
68 print >> sys.stderr, "ERROR: Specify a single output header file." 87 print >> sys.stderr, "ERROR: Specify a single output header file."
69 return 1 88 return 1
70 89
71 if not os.path.exists(os.path.join(INPUT_DIR, INPUT_FILE)): 90 if not os.path.exists(os.path.join(INPUT_DIR, INPUT_FILE)):
72 print >> sys.stderr, "ERROR: WebGL conformance tests do not exist." 91 print >> sys.stderr, "ERROR: WebGL conformance tests do not exist."
73 return 1 92 return 1
74 93
94 test_prefix = {}
95 if os.path.exists(EXPECTATION_FILE):
96 test_expectations = open(EXPECTATION_FILE)
97 for line in test_expectations:
98 line_match = EXPECTATION_REGEXP.match(line)
99 if line_match:
100 match_dict = line_match.groupdict()
101 os_list = match_dict['OS'].strip().split()
102 if not is_matching_os(os_list):
103 continue
104 test = match_dict['TEST'].strip()
105 outcome_list = match_dict['OUTCOME'].strip().split()
106 if 'TIMEOUT' in outcome_list:
107 test_prefix[test] = "DISABLED_"
108 elif 'FAIL' in outcome_list:
109 if 'PASS' in outcome_list:
110 test_prefix[test] = "FLAKY_"
111 else:
112 test_prefix[test] = "FAILS_"
113 test_expectations.close()
114
75 output = open(output_file, "w") 115 output = open(output_file, "w")
76 output.write(COPYRIGHT) 116 output.write(COPYRIGHT)
77 output.write(WARNING) 117 output.write(WARNING)
78 output.write(HEADER_GUARD) 118 output.write(HEADER_GUARD)
79 119
80 unparsed_files = [INPUT_FILE] 120 unparsed_files = [INPUT_FILE]
81 while unparsed_files: 121 while unparsed_files:
82 filename = unparsed_files.pop(0) 122 filename = unparsed_files.pop(0)
83 try: 123 try:
84 input = open(os.path.join(INPUT_DIR, filename)) 124 input = open(os.path.join(INPUT_DIR, filename))
(...skipping 14 matching lines...) Expand all
99 unparsed_files.append(url) 139 unparsed_files.append(url)
100 140
101 # Convert the filename to a valid test name and output the gtest code. 141 # Convert the filename to a valid test name and output the gtest code.
102 elif not print_input_files and url: 142 elif not print_input_files and url:
103 name = os.path.splitext(url)[0] 143 name = os.path.splitext(url)[0]
104 name = re.sub("\W+", "_", name) 144 name = re.sub("\W+", "_", name)
105 # Cannot use os.path.join() because Windows with use "\\" but this path 145 # Cannot use os.path.join() because Windows with use "\\" but this path
106 # is sent through javascript. 146 # is sent through javascript.
107 url = "%s/%s" % (os.path.dirname(filename), url) 147 url = "%s/%s" % (os.path.dirname(filename), url)
108 if os.path.exists(os.path.join(INPUT_DIR, url)): 148 if os.path.exists(os.path.join(INPUT_DIR, url)):
149 # Append "DISABLED_" or "FAILS_" if needed.
150 if name in test_prefix:
151 name = test_prefix[name] + name
109 output.write('CONFORMANCE_TEST(%s,\n "%s");\n' % (name, url)) 152 output.write('CONFORMANCE_TEST(%s,\n "%s");\n' % (name, url))
110 else: 153 else:
111 print >> sys.stderr, "WARNING: %s does not exist (skipped)." % url 154 print >> sys.stderr, "WARNING: %s does not exist (skipped)." % url
112 input.close() 155 input.close()
113 156
114 output.write(HEADER_GUARD_END) 157 output.write(HEADER_GUARD_END)
115 output.close() 158 output.close()
116 return 0 159 return 0
117 160
118 if __name__ == "__main__": 161 if __name__ == "__main__":
119 sys.exit(main(sys.argv[1:])) 162 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/gpu/webgl_conformance_test_expectations.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698