Commit 4428d395 by Jamie Madill Committed by Commit Bot

dEQP: Abort gtest run on exception.

Prevents massive infra failures when the tests are all broken. This also gives the GoogleTest harness the ability to handle different test result types. Bug: angleproject:2552 Change-Id: Id9832e8557e2ee4e6a248a27729f67a81bf2d830 Reviewed-on: https://chromium-review.googlesource.com/1064014Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 0f8aab8b
......@@ -260,6 +260,23 @@ void dEQPCaseList::initialize()
}
}
bool TestPassed(TestResult result)
{
switch (result)
{
case TestResult::Pass:
return true;
case TestResult::Fail:
return false;
case TestResult::NotSupported:
return true;
case TestResult::Exception:
return false;
default:
return false;
}
}
template <size_t TestModuleIndex>
class dEQPTest : public testing::TestWithParam<size_t>
{
......@@ -288,18 +305,26 @@ class dEQPTest : public testing::TestWithParam<size_t>
protected:
void runTest() const
{
if (sExceptions > 1)
{
std::cout << "Too many exceptions, skipping all remaining tests." << std::endl;
return;
}
const auto &caseInfo = GetCaseList().getCaseInfo(GetParam());
std::cout << caseInfo.mDEQPName << std::endl;
bool result = deqp_libtester_run(caseInfo.mDEQPName.c_str());
TestResult result = deqp_libtester_run(caseInfo.mDEQPName.c_str());
bool testPassed = TestPassed(result);
if (caseInfo.mExpectation == gpu::GPUTestExpectationsParser::kGpuTestPass)
{
EXPECT_TRUE(result);
sPasses += (result ? 1u : 0u);
sFails += (!result ? 1u : 0u);
EXPECT_TRUE(testPassed);
sPasses += (testPassed ? 1u : 0u);
sFails += (!testPassed ? 1u : 0u);
}
else if (result)
else if (testPassed)
{
std::cout << "Test expected to fail but passed!" << std::endl;
sUnexpectedPasses++;
......@@ -308,11 +333,17 @@ class dEQPTest : public testing::TestWithParam<size_t>
{
sFails++;
}
if (result == TestResult::Exception)
{
sExceptions++;
}
}
static unsigned int sPasses;
static unsigned int sFails;
static unsigned int sUnexpectedPasses;
static unsigned int sExceptions;
};
template <size_t TestModuleIndex>
......@@ -321,6 +352,8 @@ template <size_t TestModuleIndex>
unsigned int dEQPTest<TestModuleIndex>::sFails = 0;
template <size_t TestModuleIndex>
unsigned int dEQPTest<TestModuleIndex>::sUnexpectedPasses = 0;
template <size_t TestModuleIndex>
unsigned int dEQPTest<TestModuleIndex>::sExceptions = 0;
// static
template <size_t TestModuleIndex>
......
......@@ -26,10 +26,19 @@
# define ANGLE_LIBTESTER_EXPORT
#endif
// Possible results of deqp_libtester_run
enum class TestResult
{
Pass,
Fail,
NotSupported,
Exception,
};
// Exported to the tester app.
ANGLE_LIBTESTER_EXPORT int deqp_libtester_main(int argc, const char *argv[]);
ANGLE_LIBTESTER_EXPORT bool deqp_libtester_init_platform(int argc, const char *argv[]);
ANGLE_LIBTESTER_EXPORT void deqp_libtester_shutdown_platform();
ANGLE_LIBTESTER_EXPORT bool deqp_libtester_run(const char *caseName);
ANGLE_LIBTESTER_EXPORT TestResult deqp_libtester_run(const char *caseName);
#endif // ANGLE_DEQP_LIBTESTER_H_
......@@ -205,7 +205,7 @@ ANGLE_LIBTESTER_EXPORT void deqp_libtester_shutdown_platform()
g_platform = nullptr;
}
ANGLE_LIBTESTER_EXPORT bool deqp_libtester_run(const char *caseName)
ANGLE_LIBTESTER_EXPORT TestResult deqp_libtester_run(const char *caseName)
{
const char *emptyString = "";
if (g_platform == nullptr && !deqp_libtester_init_platform(1, &emptyString))
......@@ -224,18 +224,18 @@ ANGLE_LIBTESTER_EXPORT bool deqp_libtester_run(const char *caseName)
switch (result.getCode())
{
case QP_TEST_RESULT_PASS:
return true;
return TestResult::Pass;
case QP_TEST_RESULT_NOT_SUPPORTED:
std::cout << "Not supported! " << result.getDescription() << std::endl;
return true;
return TestResult::NotSupported;
case QP_TEST_RESULT_QUALITY_WARNING:
std::cout << "Quality warning! " << result.getDescription() << std::endl;
return true;
return TestResult::Pass;
case QP_TEST_RESULT_COMPATIBILITY_WARNING:
std::cout << "Compatiblity warning! " << result.getDescription() << std::endl;
return true;
return TestResult::Pass;
default:
return false;
return TestResult::Fail;
}
}
else
......@@ -246,7 +246,8 @@ ANGLE_LIBTESTER_EXPORT bool deqp_libtester_run(const char *caseName)
catch (const std::exception &e)
{
std::cout << "Exception running test: " << e.what() << std::endl;
return TestResult::Exception;
}
return false;
return TestResult::Fail;
}
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