Hash :
5df9f523
Author :
Date :
2014-05-16T10:37:47
Automate the DEQP tests by wrapping them in the gtest suite. BUG=angle:497 Change-Id: If0a72c053bccccc4369ec78dd70173bbadb1be7b Reviewed-on: https://chromium-review.googlesource.com/200044 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
//
// 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();
}
}