Commit 5df9f523 by Geoff Lang

Automate the DEQP tests by wrapping them in the gtest suite.

BUG=angle:497 Change-Id: If0a72c053bccccc4369ec78dd70173bbadb1be7b Reviewed-on: https://chromium-review.googlesource.com/200044Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 6ba49d94
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
{ {
'OutputDirectory': '$(SolutionDir)$(ConfigurationName)_$(Platform)', 'OutputDirectory': '$(SolutionDir)$(ConfigurationName)_$(Platform)',
'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)', 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
'CharacterSet': '1', # UNICODE 'CharacterSet': '0', # ASCII
}, },
'msvs_settings': 'msvs_settings':
{ {
......
...@@ -388,7 +388,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh ...@@ -388,7 +388,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
windowClass.cbWndExtra = 0; windowClass.cbWndExtra = 0;
windowClass.hInstance = GetModuleHandle(NULL); windowClass.hInstance = GetModuleHandle(NULL);
windowClass.hIcon = NULL; windowClass.hIcon = NULL;
windowClass.hCursor = LoadCursorW(NULL, IDC_ARROW); windowClass.hCursor = LoadCursorA(NULL, IDC_ARROW);
windowClass.hbrBackground = 0; windowClass.hbrBackground = 0;
windowClass.lpszMenuName = NULL; windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = mClassName.c_str(); windowClass.lpszClassName = mClassName.c_str();
......
//
// 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 "gtest/gtest.h"
#include "deqp_tests.h"
#include <EGL/eglext.h>
#include <map>
#include <string>
#include <vector>
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
typedef std::pair<std::string, EGLNativeDisplayType> NameDisplayTypePair;
typedef std::map<std::string, EGLNativeDisplayType> DisplayTypeMap;
DisplayTypeMap allDisplays;
allDisplays["d3d11"] = EGL_D3D11_ONLY_DISPLAY_ANGLE;
// Iterate through the command line arguments and check if they are config names
std::vector<NameDisplayTypePair> requestedDisplays;
for (size_t i = 1; i < static_cast<size_t>(argc); i++)
{
DisplayTypeMap::const_iterator iter = allDisplays.find(argv[i]);
if (iter != allDisplays.end())
{
requestedDisplays.push_back(*iter);
}
}
// If no configs were requested, run them all
if (requestedDisplays.empty())
{
for (DisplayTypeMap::const_iterator i = allDisplays.begin(); i != allDisplays.end(); i++)
{
requestedDisplays.push_back(*i);
}
}
// Run each requested config
int rt = 0;
for (size_t i = 0; i < requestedDisplays.size(); i++)
{
DEQPConfig config;
config.displayType = requestedDisplays[i].second;
config.width = 256;
config.height = 256;
config.hidden = false;
SetCurrentConfig(config);
std::cout << "Running test configuration \"" << requestedDisplays[i].first << "\".\n";
rt |= RUN_ALL_TESTS();
}
return rt;
}
//
// 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 "deqp_tests.h"
#include <EGL/eglext.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <sstream>
#include <stdarg.h>
#include <windows.h>
#include "tcuDefs.hpp"
#include "tcuCommandLine.hpp"
#include "tcuPlatform.hpp"
#include "tcuApp.hpp"
#include "tcuResource.hpp"
#include "tcuTestLog.hpp"
#include "tcuTestExecutor.hpp"
#include "deUniquePtr.hpp"
#include "tes3TestPackage.hpp"
#include "win32/tcuWin32EglPlatform.hpp"
// Register the gles3 test cases
static tcu::TestPackage* createTestPackage(tcu::TestContext& testCtx)
{
return new deqp::gles3::TestPackage(testCtx);
}
tcu::TestPackageDescriptor g_gles3PackageDescriptor("dEQP-GLES3", createTestPackage);
// Create a platform that supports custom display types
class Win32EglCustomDisplayPlatform : public tcu::Win32EglPlatform
{
public:
Win32EglCustomDisplayPlatform(EGLNativeDisplayType displayType)
: mDisplayType(displayType)
{
}
virtual ~Win32EglCustomDisplayPlatform()
{
}
virtual tcu::NativeDisplay* createDefaultDisplay()
{
return new tcu::Win32EglDisplay(mDisplayType);
}
private:
EGLNativeDisplayType mDisplayType;
};
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;
}
static DEQPConfig kCurrentConfig = { 256, 256, false, EGL_D3D11_ONLY_DISPLAY_ANGLE };
void SetCurrentConfig(const DEQPConfig& config)
{
kCurrentConfig = config;
}
const DEQPConfig& GetCurrentConfig()
{
return kCurrentConfig;
}
void RunDEQPTest(const std::string &testPath, const DEQPConfig& config)
{
try
{
std::vector<char*> args;
// Empty first argument for the program name
args.push_back("deqp-gles3");
std::vector<char> visibilityArg = FormatArg("--deqp-visibility=%s", config.hidden ? "hidden" : "windowed");
args.push_back(visibilityArg.data());
std::vector<char> widthArg = FormatArg("--deqp-surface-width=%u", config.width);
args.push_back(widthArg.data());
std::vector<char> heightArg = FormatArg("--deqp-surface-height=%u", config.height);
args.push_back(heightArg.data());
std::vector<char> testNameArg = FormatArg("--deqp-case=%s", testPath.c_str());
args.push_back(testNameArg.data());
// Redirect cout
std::streambuf* oldCoutStreamBuf = std::cout.rdbuf();
std::ostringstream strCout;
std::cout.rdbuf(strCout.rdbuf());
tcu::CommandLine cmdLine(args.size(), args.data());
tcu::DirArchive archive(GetExecutableDirectory().c_str());
tcu::TestLog log(cmdLine.getLogFileName(), cmdLine.getLogFlags());
de::UniquePtr<tcu::Platform> platform(new Win32EglCustomDisplayPlatform(config.displayType));
de::UniquePtr<tcu::App> app(new tcu::App(*platform, archive, log, cmdLine));
// Main loop.
for (;;)
{
if (!app->iterate())
{
break;
}
}
// Restore old cout
std::cout.rdbuf(oldCoutStreamBuf);
EXPECT_EQ(0, app->getResult().numFailed) << strCout.str();
}
catch (const std::exception& e)
{
FAIL() << e.what();
}
}
//
// 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 DEQP_TESTS_DEQP_TESTS_H_
#define DEQP_TESTS_DEQP_TESTS_H_
#include "gtest/gtest.h"
#include <EGL/egl.h>
#include <string>
struct DEQPConfig
{
size_t width;
size_t height;
bool hidden;
EGLNativeDisplayType displayType;
};
void SetCurrentConfig(const DEQPConfig& config);
const DEQPConfig& GetCurrentConfig();
void RunDEQPTest(const std::string &testPath, const DEQPConfig& config);
#endif // DEQP_TESTS_DEQP_TESTS_H_
dEQP-GLES3.functional.prerequisite.*
dEQP-GLES3.functional.buffer.write.*
dEQP-GLES3.functional.samplers.*
dEQP-GLES3.functional.state_query.internal_format.*
dEQP-GLES3.functional.shaders.preprocessor.basic.*
dEQP-GLES3.functional.shaders.preprocessor.invalid_redefinitions.*
dEQP-GLES3.functional.shaders.preprocessor.comments.*
dEQP-GLES3.functional.shaders.preprocessor.function_definitions.*
dEQP-GLES3.functional.shaders.preprocessor.recursion.*
dEQP-GLES3.functional.shaders.preprocessor.function_redefinitions.*
dEQP-GLES3.functional.shaders.preprocessor.semantic.*
dEQP-GLES3.functional.shaders.preprocessor.invalid_ops.*
dEQP-GLES3.functional.shaders.preprocessor.directive.*
dEQP-GLES3.functional.shaders.preprocessor.extensions.*
dEQP-GLES3.functional.shaders.preprocessor.invalid_expressions.*
dEQP-GLES3.functional.shaders.preprocessor.operator_precedence.*
dEQP-GLES3.functional.shaders.constants.*
dEQP-GLES3.functional.shaders.linkage.varying.interpolation.*
dEQP-GLES3.functional.shaders.linkage.varying.usage.*
dEQP-GLES3.functional.shaders.conversions.scalar_to_scalar.*
dEQP-GLES3.functional.shaders.conversions.scalar_to_vector.*
dEQP-GLES3.functional.shaders.conversions.vector_to_scalar.*
dEQP-GLES3.functional.shaders.conversions.vector_illegal.*
dEQP-GLES3.functional.shaders.conversions.vector_to_vector.*
dEQP-GLES3.functional.texture.mipmap.2d.basic.*
dEQP-GLES3.functional.texture.mipmap.2d.affine.*
dEQP-GLES3.functional.texture.mipmap.2d.bias.*
dEQP-GLES3.functional.texture.mipmap.cube.projected.*
dEQP-GLES3.functional.texture.mipmap.cube.bias.*
dEQP-GLES3.functional.texture.mipmap.3d.basic.*
dEQP-GLES3.functional.texture.mipmap.3d.affine.*
dEQP-GLES3.functional.texture.mipmap.3d.projected.*
dEQP-GLES3.functional.texture.mipmap.3d.bias.*
dEQP-GLES3.functional.multisample.*
dEQP-GLES3.functional.shaders.linkage.varying.basic_types.*
dEQP-GLES3.functional.shaders.linkage.varying.struct.*
dEQP-GLES3.functional.shaders.linkage.varying.interpolation.*
dEQP-GLES3.functional.shaders.linkage.varying.usage.*
dEQP-GLES3.functional.shaders.linkage.uniform.*
dEQP-GLES3.functional.rasterizer_discard.*
\ No newline at end of file
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 GetCleanTestName(testName):
replacements = { "dEQP-": "", ".*": "", ".":"_", }
cleanName = testName
for replaceKey in replacements:
cleanName = cleanName.replace(replaceKey, replacements[replaceKey])
return cleanName
def GenerateTests(outFile, testNames):
''' Remove duplicate tests '''
testNames = list(set(testNames))
outFile.write("#include \"deqp_tests.h\"\n\n")
for test in testNames:
outFile.write("TEST(deqp, " + GetCleanTestName(test) + ")\n")
outFile.write("{\n")
outFile.write(" RunDEQPTest(\"" + test + "\", GetCurrentConfig());\n")
outFile.write("}\n\n")
def main(argv):
tests = ReadFileAsLines(argv[0])
output = open(argv[1], 'wb')
GenerateTests(output, tests)
output.close()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
...@@ -41,8 +41,8 @@ DWORD WINAPI EGLThreadTest::ThreadingTestEntryPoint(LPVOID lpParameter) ...@@ -41,8 +41,8 @@ DWORD WINAPI EGLThreadTest::ThreadingTestEntryPoint(LPVOID lpParameter)
void EGLThreadTest::ThreadingTest() void EGLThreadTest::ThreadingTest()
{ {
mEGL = LoadLibrary(L"libEGL.dll"); mEGL = LoadLibrary(TEXT("libEGL.dll"));
mGLESv2 = LoadLibrary(L"libGLESv2.dll"); mGLESv2 = LoadLibrary(TEXT("libGLESv2.dll"));
EXPECT_TRUE(mEGL != NULL); EXPECT_TRUE(mEGL != NULL);
EXPECT_TRUE(mGLESv2 != NULL); EXPECT_TRUE(mGLESv2 != NULL);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
'variables': 'variables':
{ {
'angle_build_conformance_tests%': '0', 'angle_build_conformance_tests%': '0',
'angle_build_deqp_tests%': '0',
}, },
'targets': 'targets':
[ [
...@@ -293,6 +294,70 @@ ...@@ -293,6 +294,70 @@
}, },
], ],
}], }],
['angle_build_deqp_tests',
{
'targets':
[
{
'target_name': 'deqp_tests',
'type': 'executable',
'includes': [ '../build/common_defines.gypi', ],
'dependencies':
[
'../src/angle.gyp:libGLESv2',
'../src/angle.gyp:libEGL',
'gtest',
'third_party/deqp/src/deqp/modules/gles3/gles3.gyp:deqp-gles3',
'third_party/deqp/src/deqp/framework/platform/platform.gyp:tcutil-platform',
],
'include_dirs':
[
'../include',
'third_party/googletest/include',
'deqp_tests',
],
'variables':
{
'deqp_tests_output_dir': '<(SHARED_INTERMEDIATE_DIR)/deqp_tests',
'deqp_tests_input_file': 'deqp_tests/deqp_tests.txt',
'deqp_tests_generated_file': '<(deqp_tests_output_dir)/generated_deqp_tests.cpp',
},
'sources':
[
'<!@(python <(angle_path)/enumerate_files.py deqp_tests -types *.cpp *.h *.inl)',
'<(deqp_tests_generated_file)',
],
'actions':
[
{
'action_name': 'generate_deqp_tests',
'message': 'Generating dEQP tests...',
'msvs_cygwin_shell': 0,
'variables':
{
'deqp_tests_generator_script': 'deqp_tests/generate_deqp_tests.py',
},
'inputs':
[
'<(deqp_tests_generator_script)',
'<(deqp_tests_input_file)',
],
'outputs':
[
'<(deqp_tests_generated_file)',
],
'action':
[
'python',
'<(deqp_tests_generator_script)',
'<(deqp_tests_input_file)',
'<(deqp_tests_generated_file)',
],
},
],
},
],
}],
], ],
}], }],
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment