OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
Ken Russell (switch to Gerrit)
2013/12/05 00:40:15
May be worth updating copyright year.
Zhenyao Mo
2013/12/05 01:48:31
Done here and all other newly added files
| |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """code generator for OpenGL ES 2.0 conformance tests.""" | |
7 | |
8 import os | |
9 import re | |
10 import sys | |
11 | |
12 def ReadFileAsLines(filename): | |
13 """Reads a file, removing blank lines and lines that start with #""" | |
14 file = open(filename, "r") | |
15 raw_lines = file.readlines() | |
16 file.close() | |
17 lines = [] | |
18 for line in raw_lines: | |
19 line = line.strip() | |
20 if len(line) > 0 and not line.startswith("#"): | |
21 lines.append(line) | |
22 return lines | |
23 | |
24 | |
25 def GenerateTests(file): | |
26 """Generates gles2_conform_test_autogen.cc""" | |
27 | |
28 tests = ReadFileAsLines( | |
29 "../../third_party/gles2_conform/GTF_ES/glsl/GTF/mustpass_es20.run") | |
30 | |
31 file.write(""" | |
32 #include "gpu/gles2_conform_support/gles2_conform_test.h" | |
33 #include "testing/gtest/include/gtest/gtest.h" | |
34 """) | |
35 | |
36 for test in tests: | |
37 file.write(""" | |
38 TEST(GLES2ConformTest, %(name)s) { | |
39 EXPECT_TRUE(RunGLES2ConformTest("%(path)s")); | |
40 } | |
41 """ % { | |
42 "name": re.sub(r'[^A-Za-z0-9]', '_', test), | |
43 "path": test, | |
44 }) | |
45 | |
46 | |
47 def main(argv): | |
48 """This is the main function.""" | |
49 | |
50 if len(argv) >= 1: | |
51 dir = argv[0] | |
52 else: | |
53 dir = '.' | |
54 | |
55 file = open(os.path.join(dir, 'gles2_conform_test_autogen.cc'), 'wb') | |
56 GenerateTests(file) | |
57 file.close() | |
58 | |
59 return 0 | |
60 | |
61 | |
62 if __name__ == '__main__': | |
63 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |