Hash :
0c1d4403
Author :
Date :
2015-10-29T10:13:49
dEQP: Use full GTest name in non-standalone. With crbug.com/509883 fixed, we can use the full test names. BUG=509883 BUG=angleproject:1153 Change-Id: I62bf60fb5066de8c0cc118512ba0d9e9bbd94303 Reviewed-on: https://chromium-review.googlesource.com/309653 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
//
// Copyright 2015 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.
//
// angle_deqp_gtest:
// dEQP and GoogleTest integration logic. Calls through to the random
// order executor.
#include <stdint.h>
#include <zlib.h>
#include <gtest/gtest.h>
#include "angle_deqp_libtester.h"
#include "common/angleutils.h"
#include "common/debug.h"
#include "gpu_test_expectations_parser.h"
#include "system_utils.h"
namespace
{
const char *g_CaseListFiles[] =
{
"dEQP-GLES2-cases.txt.gz",
"dEQP-GLES3-cases.txt.gz",
"dEQP-EGL-cases.txt.gz",
};
const char *g_TestExpectationsFiles[] =
{
"deqp_gles2_test_expectations.txt",
"deqp_gles3_test_expectations.txt",
"deqp_egl_test_expectations.txt",
};
class dEQPCaseList
{
public:
dEQPCaseList(size_t testModuleIndex);
struct CaseInfo
{
CaseInfo(const std::string &dEQPName,
const std::string &gTestName,
int expectation)
: mDEQPName(dEQPName),
mGTestName(gTestName),
mExpectation(expectation)
{
}
std::string mDEQPName;
std::string mGTestName;
int mExpectation;
};
void initialize();
const CaseInfo &getCaseInfo(size_t caseIndex) const
{
ASSERT(mInitialized);
ASSERT(caseIndex < mCaseInfoList.size());
return mCaseInfoList[caseIndex];
}
size_t numCases() const
{
ASSERT(mInitialized);
return mCaseInfoList.size();
}
private:
std::vector<CaseInfo> mCaseInfoList;
gpu::GPUTestExpectationsParser mTestExpectationsParser;
gpu::GPUTestBotConfig mTestConfig;
size_t mTestModuleIndex;
bool mInitialized;
};
dEQPCaseList::dEQPCaseList(size_t testModuleIndex)
: mTestModuleIndex(testModuleIndex),
mInitialized(false)
{
}
void dEQPCaseList::initialize()
{
if (mInitialized)
{
return;
}
mInitialized = true;
std::string exeDir = angle::GetExecutableDirectory();
std::stringstream caseListPathStr;
caseListPathStr << exeDir << "/deqp_support/" << g_CaseListFiles[mTestModuleIndex];
std::string caseListPath = caseListPathStr.str();
std::stringstream testExpectationsPathStr;
testExpectationsPathStr << exeDir << "/deqp_support/"
<< g_TestExpectationsFiles[mTestModuleIndex];
std::string testExpectationsPath = testExpectationsPathStr.str();
if (!mTestExpectationsParser.LoadTestExpectationsFromFile(testExpectationsPath))
{
std::stringstream errorMsgStream;
for (const auto &message : mTestExpectationsParser.GetErrorMessages())
{
errorMsgStream << std::endl << " " << message;
}
FAIL() << "Failed to load test expectations." << errorMsgStream.str();
}
if (!mTestConfig.LoadCurrentConfig(nullptr))
{
FAIL() << "Failed to load test configuration.";
}
std::stringstream caseListStream;
std::vector<char> buf(1024 * 1024 * 16);
gzFile *fi = static_cast<gzFile *>(gzopen(caseListPath.c_str(), "rb"));
if (fi == nullptr)
{
FAIL() << "Failed to read gzipped test information.";
}
gzrewind(fi);
while (!gzeof(fi))
{
int len = gzread(fi, &buf[0], static_cast<unsigned int>(buf.size()) - 1);
buf[len] = '\0';
caseListStream << &buf[0];
}
gzclose(fi);
while (!caseListStream.eof())
{
std::string inString;
std::getline(caseListStream, inString);
if (inString.substr(0, 4) == "TEST")
{
std::string dEQPName = inString.substr(6);
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());
int expectation = mTestExpectationsParser.GetTestExpectation(dEQPName, mTestConfig);
if (expectation != gpu::GPUTestExpectationsParser::kGpuTestSkip)
{
mCaseInfoList.push_back(CaseInfo(dEQPName, gTestName, expectation));
}
}
}
}
template <size_t TestModuleIndex>
class dEQPTest : public testing::TestWithParam<size_t>
{
public:
static testing::internal::ParamGenerator<size_t> GetTestingRange()
{
return testing::Range<size_t>(0, GetCaseList().numCases());
}
static std::string GetCaseGTestName(size_t caseIndex)
{
const auto &caseInfo = GetCaseList().getCaseInfo(caseIndex);
return caseInfo.mGTestName;
}
static const dEQPCaseList &GetCaseList()
{
static dEQPCaseList sCaseList(TestModuleIndex);
sCaseList.initialize();
return sCaseList;
}
protected:
void runTest()
{
const auto &caseInfo = GetCaseList().getCaseInfo(GetParam());
std::cout << caseInfo.mDEQPName << std::endl;
bool result = deqp_libtester_run(caseInfo.mDEQPName.c_str());
if (caseInfo.mExpectation == gpu::GPUTestExpectationsParser::kGpuTestPass)
{
EXPECT_TRUE(result);
}
else if (result)
{
std::cout << "Test expected to fail but passed!" << std::endl;
}
}
};
class dEQP_GLES2 : public dEQPTest<0>
{
};
class dEQP_GLES3 : public dEQPTest<1>
{
};
class dEQP_EGL : public dEQPTest<2>
{
};
// TODO(jmadill): add different platform configs, or ability to choose platform
#define ANGLE_INSTANTIATE_DEQP_TEST_CASE(DEQP_TEST) \
TEST_P(DEQP_TEST, Default) { runTest(); } \
\
INSTANTIATE_TEST_CASE_P(, DEQP_TEST, DEQP_TEST::GetTestingRange(), \
[](const testing::TestParamInfo<size_t> &info) \
{ \
return DEQP_TEST::GetCaseGTestName(info.param); \
})
#ifdef ANGLE_DEQP_GLES2_TESTS
ANGLE_INSTANTIATE_DEQP_TEST_CASE(dEQP_GLES2);
#endif
#ifdef ANGLE_DEQP_GLES3_TESTS
ANGLE_INSTANTIATE_DEQP_TEST_CASE(dEQP_GLES3);
#endif
#ifdef ANGLE_DEQP_EGL_TESTS
ANGLE_INSTANTIATE_DEQP_TEST_CASE(dEQP_EGL);
#endif
} // anonymous namespace