Commit 21386a34 by Jamie Madill Committed by Commit Bot

dEQP: Implement --deqp-case for GTest.

This parses the dEQP test name into a GoogleTest-friendly gtest_filter automatically. This makes pasting in test case names from the expectations file more straight-forward. Bug: angleproject:2557 Change-Id: Ib5fbb46ad487a89352d728aebedc1752ddb0673d Reviewed-on: https://chromium-review.googlesource.com/1058252 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 018709fd
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
// dEQP and GoogleTest integration logic. Calls through to the random // dEQP and GoogleTest integration logic. Calls through to the random
// order executor. // order executor.
#include <fstream>
#include <stdint.h> #include <stdint.h>
#include <array>
#include <fstream>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -23,6 +24,15 @@ ...@@ -23,6 +24,15 @@
namespace namespace
{ {
std::string DrawElementsToGoogleTestName(const std::string &dEQPName)
{
std::string gTestName = dEQPName.substr(dEQPName.find('.') + 1);
std::replace(gTestName.begin(), gTestName.end(), '.', '_');
// Occurs in some luminance tests
gTestName.erase(std::remove(gTestName.begin(), gTestName.end(), '-'), gTestName.end());
return gTestName;
}
#if defined(ANGLE_PLATFORM_ANDROID) #if defined(ANGLE_PLATFORM_ANDROID)
const char *gCaseListRelativePath = const char *gCaseListRelativePath =
...@@ -58,6 +68,9 @@ const APIInfo gEGLDisplayAPIs[] = { ...@@ -58,6 +68,9 @@ const APIInfo gEGLDisplayAPIs[] = {
const char *gdEQPEGLString = "--deqp-egl-display-type="; const char *gdEQPEGLString = "--deqp-egl-display-type=";
const char *gANGLEEGLString = "--use-angle="; const char *gANGLEEGLString = "--use-angle=";
const char *gdEQPCaseString = "--deqp-case=";
std::array<char, 500> gCaseStringBuffer;
const APIInfo *gInitAPI = nullptr; const APIInfo *gInitAPI = nullptr;
...@@ -241,13 +254,9 @@ void dEQPCaseList::initialize() ...@@ -241,13 +254,9 @@ void dEQPCaseList::initialize()
std::string dEQPName = angle::TrimString(inString, angle::kWhitespaceASCII); std::string dEQPName = angle::TrimString(inString, angle::kWhitespaceASCII);
if (dEQPName.empty()) if (dEQPName.empty())
continue; continue;
std::string gTestName = dEQPName.substr(dEQPName.find('.') + 1); std::string gTestName = DrawElementsToGoogleTestName(dEQPName);
if (gTestName.empty()) if (gTestName.empty())
continue; continue;
std::replace(gTestName.begin(), gTestName.end(), '.', '_');
// Occurs in some luminance tests
gTestName.erase(std::remove(gTestName.begin(), gTestName.end(), '-'), gTestName.end());
int expectation = mTestExpectationsParser.GetTestExpectation(dEQPName, mTestConfig); int expectation = mTestExpectationsParser.GetTestExpectation(dEQPName, mTestConfig);
if (expectation != gpu::GPUTestExpectationsParser::kGpuTestSkip) if (expectation != gpu::GPUTestExpectationsParser::kGpuTestSkip)
...@@ -431,6 +440,24 @@ void HandleEGLConfigName(const char *configNameString) ...@@ -431,6 +440,24 @@ void HandleEGLConfigName(const char *configNameString)
gEGLConfigName = configNameString; gEGLConfigName = configNameString;
} }
// The --deqp-case flag takes a case expression that is parsed into a --gtest_filter. It converts
// the "dEQP" style names (functional.thing.*) into "GoogleTest" style names (functional_thing_*).
// Currently it does not handle multiple tests and multiple filters in different arguments.
void HandleCaseName(const char *caseString, int *argc, int argIndex, char **argv)
{
std::string googleTestName = DrawElementsToGoogleTestName(caseString);
gCaseStringBuffer.fill(0);
int bytesWritten = snprintf(gCaseStringBuffer.data(), gCaseStringBuffer.size() - 1,
"--gtest_filter=*%s", googleTestName.c_str());
if (bytesWritten <= 0 || static_cast<size_t>(bytesWritten) >= gCaseStringBuffer.size() - 1)
{
std::cout << "Error parsing test case string: " << caseString;
exit(1);
}
argv[argIndex] = gCaseStringBuffer.data();
}
void DeleteArg(int *argc, int argIndex, char **argv) void DeleteArg(int *argc, int argIndex, char **argv)
{ {
(*argc)--; (*argc)--;
...@@ -466,6 +493,11 @@ void InitTestHarness(int *argc, char **argv) ...@@ -466,6 +493,11 @@ void InitTestHarness(int *argc, char **argv)
HandleEGLConfigName(argv[argIndex] + strlen(gdEQPEGLConfigNameString)); HandleEGLConfigName(argv[argIndex] + strlen(gdEQPEGLConfigNameString));
DeleteArg(argc, argIndex, argv); DeleteArg(argc, argIndex, argv);
} }
else if (strncmp(argv[argIndex], gdEQPCaseString, strlen(gdEQPCaseString)) == 0)
{
HandleCaseName(argv[argIndex] + strlen(gdEQPCaseString), argc, argIndex, argv);
argIndex++;
}
else else
{ {
argIndex++; argIndex++;
......
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