Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / gpu / gles2_conform_support / generate_gles2_conform_tests.py
blobdf2980a11a4303dde37b79675312768cde74af2a
1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """code generator for OpenGL ES 2.0 conformance tests."""
8 import os
9 import re
10 import sys
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
25 def GenerateTests(file):
26 """Generates gles2_conform_test_autogen.cc"""
28 tests = ReadFileAsLines(
29 "../../third_party/gles2_conform/GTF_ES/glsl/GTF/mustpass_es20.run")
31 file.write("""
32 #include "gpu/gles2_conform_support/gles2_conform_test.h"
33 #include "testing/gtest/include/gtest/gtest.h"
34 """)
36 for test in tests:
37 file.write("""
38 TEST(GLES2ConformTest, %(name)s) {
39 EXPECT_TRUE(RunGLES2ConformTest("%(path)s"));
41 """ % {
42 "name": re.sub(r'[^A-Za-z0-9]', '_', test),
43 "path": test,
47 def main(argv):
48 """This is the main function."""
50 if len(argv) >= 1:
51 dir = argv[0]
52 else:
53 dir = '.'
55 file = open(os.path.join(dir, 'gles2_conform_test_autogen.cc'), 'wb')
56 GenerateTests(file)
57 file.close()
59 return 0
62 if __name__ == '__main__':
63 sys.exit(main(sys.argv[1:]))