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

Unified Diff: gpu/khronos_glcts_support/generate_khronos_glcts_tests.py

Issue 556333003: Add support for khronos gl-cts using its drawElements apis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/khronos_glcts_support/DEPS ('k') | gpu/khronos_glcts_support/khronos_glcts.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/khronos_glcts_support/generate_khronos_glcts_tests.py
diff --git a/gpu/khronos_glcts_support/generate_khronos_glcts_tests.py b/gpu/khronos_glcts_support/generate_khronos_glcts_tests.py
new file mode 100755
index 0000000000000000000000000000000000000000..31472865b116ad44665fdf9a38c7036ec37d18a2
--- /dev/null
+++ b/gpu/khronos_glcts_support/generate_khronos_glcts_tests.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Code generator for khronos_glcts tests."""
+
+import os
+import re
+import sys
+import argparse
+
+TEST_DEF_TEMPLATE = """
+TEST(KhronosGLCTSTest, %(gname)s) {
+ EXPECT_TRUE(RunKhronosGLCTSTest("%(cname)s"));
+}
+"""
+
+RUN_FILE_SUITE_PREFIX = {
+ "mustpass_es20.run" : "ES2-CTS.gtf",
+}
+
+def ReadFileAsLines(filename):
+ """
+ Reads a file, yielding each non-blank line
+ and lines that don't begin with #
+ """
+ file = open(filename, "r")
+ lines = file.readlines()
+ file.close()
+ for line in lines:
+ line = line.strip()
+ if len(line) > 0 and not line.startswith("#"):
+ yield line
+
+def ReadRunFile(run_file):
+ """
+ Find all .test tests in a .run file and return their paths.
+ If the .run file contains another .run file, then that is inspected
+ too.
+ """
+ tests = list()
+ base_dir = os.path.dirname(run_file)
+ for line in ReadFileAsLines(run_file):
+ root, ext = os.path.splitext(line)
+ if ext == ".test":
+ tests.append(os.path.join(base_dir, line))
+ elif ext == ".run":
+ tests += ReadRunFile(os.path.join(base_dir, line))
+ else:
+ raise ValueError, "Unexpected line '%s' in '%s'" % (line, run_file)
+ return tests
+
+def GenerateTests(run_files, output):
+ """
+ Generates code for khronos_glcts_test test-cases that are
+ listed in the run_files.
+ """
+ output.write('#include "gpu/khronos_glcts_support/khronos_glcts_test.h"\n')
+ output.write('#include "testing/gtest/include/gtest/gtest.h"\n\n')
+
+ for run_file in run_files:
+ run_file_name = os.path.basename(run_file)
+ run_file_dir = os.path.dirname(run_file)
+ suite_prefix = RUN_FILE_SUITE_PREFIX[run_file_name]
+ output.write("// " + run_file_name + "\n")
+ for test in ReadRunFile(run_file):
+ rel_path = os.path.relpath(test, run_file_dir)
+ root, ext = os.path.splitext(rel_path)
+ name = root.replace('.', '_')
+ name = "%s.%s" % (suite_prefix, name.replace(os.path.sep, '.'))
+ output.write(TEST_DEF_TEMPLATE
+ % {
+ "gname": re.sub(r'[^A-Za-z0-9]', '_', name),
+ "cname": name,
+ })
+ output.write("\n");
+
+def main():
+ """This is the main function."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--outdir", default = ".")
+ parser.add_argument("run_files", nargs = "+")
+
+ args = parser.parse_args()
+
+ output = open(
+ os.path.join(args.outdir, "khronos_glcts_test_autogen.cc"), "wb")
+
+ try:
+ GenerateTests(args.run_files, output)
+ finally:
+ output.close()
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « gpu/khronos_glcts_support/DEPS ('k') | gpu/khronos_glcts_support/khronos_glcts.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698