summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/tests/gles_conformance_tests
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/tests/gles_conformance_tests')
-rwxr-xr-xgfx/angle/src/tests/gles_conformance_tests/generate_gles_conformance_tests.py68
-rwxr-xr-xgfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.cpp92
-rwxr-xr-xgfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.h69
-rwxr-xr-xgfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests_main.cpp23
4 files changed, 252 insertions, 0 deletions
diff --git a/gfx/angle/src/tests/gles_conformance_tests/generate_gles_conformance_tests.py b/gfx/angle/src/tests/gles_conformance_tests/generate_gles_conformance_tests.py
new file mode 100755
index 000000000..8ed313a16
--- /dev/null
+++ b/gfx/angle/src/tests/gles_conformance_tests/generate_gles_conformance_tests.py
@@ -0,0 +1,68 @@
+import os
+import re
+import sys
+
+def ReadFileAsLines(filename):
+ """Reads a file, removing blank lines and lines that start with #"""
+ file = open(filename, "r")
+ raw_lines = file.readlines()
+ file.close()
+ lines = []
+ for line in raw_lines:
+ line = line.strip()
+ if len(line) > 0 and not line.startswith("#"):
+ lines.append(line)
+ return lines
+
+def GetSuiteName(testName):
+ return testName[:testName.find("/")]
+
+def GetTestName(testName):
+ replacements = { ".test": "", ".": "_" }
+ splitTestName = testName.split("/")
+ cleanName = splitTestName[-2] + "_" + splitTestName[-1]
+ for replaceKey in replacements:
+ cleanName = cleanName.replace(replaceKey, replacements[replaceKey])
+ return cleanName
+
+def GenerateTests(outFile, testNames):
+ # Remove duplicate tests
+ testNames = list(set(testNames))
+ testSuites = []
+
+ outFile.write("#include \"gles_conformance_tests.h\"\n\n")
+
+ for test in testNames:
+ testSuite = GetSuiteName(test)
+ if not testSuite in testSuites:
+ outFile.write("DEFINE_CONFORMANCE_TEST_CLASS(" + testSuite + ");\n\n")
+ testSuites.append(testSuite)
+
+ outFile.write("TYPED_TEST(" + testSuite + ", " + GetTestName(test) + ")\n")
+ outFile.write("{\n")
+ outFile.write(" run(\"" + test + "\");\n")
+ outFile.write("}\n\n")
+
+def GenerateTestList(sourceFile, rootDir):
+ tests = [ ]
+ fileName, fileExtension = os.path.splitext(sourceFile)
+ if fileExtension == ".run":
+ lines = ReadFileAsLines(sourceFile)
+ for line in lines:
+ tests += GenerateTestList(os.path.join(os.path.dirname(sourceFile), line), rootDir)
+ elif fileExtension == ".test":
+ tests.append(os.path.relpath(os.path.realpath(sourceFile), rootDir).replace("\\", "/"))
+ return tests;
+
+def main(argv):
+ tests = GenerateTestList(argv[0], argv[1])
+ tests.sort()
+
+ output = open(argv[2], 'wb')
+ GenerateTests(output, tests)
+ output.close()
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.cpp b/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.cpp
new file mode 100755
index 000000000..0a16bc6b0
--- /dev/null
+++ b/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.cpp
@@ -0,0 +1,92 @@
+#include "gles_conformance_tests.h"
+#include "GTFMain.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <vector>
+#include <sstream>
+#include <stdarg.h>
+
+static std::vector<char> FormatArg(const char* fmt, ...)
+{
+ va_list vararg;
+ va_start(vararg, fmt);
+ int len = vsnprintf(NULL, 0, fmt, vararg);
+ va_end(vararg);
+
+ std::vector<char> buf(len + 1);
+
+ va_start(vararg, fmt);
+ vsnprintf(buf.data(), buf.size(), fmt, vararg);
+ va_end(vararg);
+
+ return buf;
+}
+
+static std::string GetExecutableDirectory()
+{
+ std::vector<char> executableFileBuf(MAX_PATH);
+ DWORD executablePathLen = GetModuleFileNameA(NULL, executableFileBuf.data(), executableFileBuf.size());
+ if (executablePathLen == 0)
+ {
+ return false;
+ }
+
+ std::string executableLocation = executableFileBuf.data();
+ size_t lastPathSepLoc = executableLocation.find_last_of("\\/");
+ if (lastPathSepLoc != std::string::npos)
+ {
+ executableLocation = executableLocation.substr(0, lastPathSepLoc);
+ }
+ else
+ {
+ executableLocation = "";
+ }
+
+ return executableLocation;
+}
+
+void RunConformanceTest(const std::string &testPath, EGLNativeDisplayType nativeDisplay)
+{
+ std::vector<char*> args;
+
+ // Empty first argument for the program name
+ args.push_back("");
+
+ std::vector<char> widthArg = FormatArg("-width=%u", 64);
+ args.push_back(widthArg.data());
+
+ std::vector<char> heightArg = FormatArg("-height=%u", 64);
+ args.push_back(heightArg.data());
+
+ std::vector<char> displayArg = FormatArg("-d=%llu", nativeDisplay);
+ args.push_back(displayArg.data());
+
+ std::vector<char> runArg = FormatArg("-run=%s/conformance_tests/%s", GetExecutableDirectory().c_str(), testPath.c_str());
+ args.push_back(runArg.data());
+
+ // Redirect cout
+ std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
+ std::ostringstream strCout;
+ std::cout.rdbuf(strCout.rdbuf());
+
+ if (GTFMain(args.size(), args.data()) != 0)
+ {
+ FAIL() << "GTFMain failed.";
+ }
+
+ // Restore old cout
+ std::cout.rdbuf(oldCoutStreamBuf);
+ std::string log = strCout.str();
+
+ // Look for failures
+ size_t offset = 0;
+ std::string offsetSearchString = "failure = ";
+ while ((offset = log.find("failure = ", offset)) != std::string::npos)
+ {
+ offset += offsetSearchString.length();
+
+ size_t failureCount = atoll(log.c_str() + offset);
+ EXPECT_EQ(0, failureCount) << log;
+ }
+}
diff --git a/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.h b/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.h
new file mode 100755
index 000000000..df911b034
--- /dev/null
+++ b/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests.h
@@ -0,0 +1,69 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#ifndef CONFORMANCE_TESTS_CONFORMANCE_TEST_H_
+#define CONFORMANCE_TESTS_CONFORMANCE_TEST_H_
+
+#include "gtest/gtest.h"
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#include <string>
+
+struct D3D9
+{
+ static EGLNativeDisplayType GetNativeDisplay()
+ {
+ return EGL_DEFAULT_DISPLAY;
+ }
+};
+
+struct D3D11
+{
+ static EGLNativeDisplayType GetNativeDisplay()
+ {
+ return EGL_D3D11_ONLY_DISPLAY_ANGLE;
+ }
+};
+
+#define CONFORMANCE_TESTS_ES2 2
+#define CONFORMANCE_TESTS_ES3 3
+
+#if CONFORMANCE_TESTS_TYPE == CONFORMANCE_TESTS_ES2
+ typedef testing::Types<D3D9, D3D11> ConformanceTestTypes;
+#elif CONFORMANCE_TESTS_TYPE == CONFORMANCE_TESTS_ES3
+ typedef testing::Types<D3D11> ConformanceTestTypes;
+#else
+# error "Unknown CONFORMANCE_TESTS_TYPE"
+#endif
+
+#define DEFINE_CONFORMANCE_TEST_CLASS(name) \
+ template <typename T> class name : public ConformanceTest<T> { }; \
+ TYPED_TEST_CASE(name, ConformanceTestTypes);
+
+template <typename T>
+class ConformanceTest : public testing::Test
+{
+ public:
+ ConformanceTest()
+ : mNativeDisplay(T::GetNativeDisplay())
+ {
+ }
+
+ protected:
+ void run(const std::string &testPath)
+ {
+ RunConformanceTest(testPath, mNativeDisplay);
+ }
+
+ private:
+ EGLNativeDisplayType mNativeDisplay;
+};
+
+void RunConformanceTest(const std::string &testPath, EGLNativeDisplayType nativeDisplay);
+
+#endif // CONFORMANCE_TESTS_CONFORMANCE_TEST_H_
diff --git a/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests_main.cpp b/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests_main.cpp
new file mode 100755
index 000000000..0b95d5c89
--- /dev/null
+++ b/gfx/angle/src/tests/gles_conformance_tests/gles_conformance_tests_main.cpp
@@ -0,0 +1,23 @@
+//
+// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "gles_conformance_tests.h"
+
+#include "gtest/gtest.h"
+
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#include <map>
+#include <string>
+#include <vector>
+
+int main(int argc, char** argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+ int rt = RUN_ALL_TESTS();
+ return rt;
+}