Commit ee07cb31 by Jamie Madill Committed by Commit Bot

Test Harness: Allow filter with sharding params.

Some tweaks to when we call gtest initialization allows this to work. Bug: angleproject:3162 Change-Id: I75159108d3f746f666e57c1a6495a8c8616ef1cf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2024335 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 12c0e765
...@@ -357,19 +357,12 @@ std::vector<TestIdentifier> GetFilteredTests(std::map<TestIdentifier, FileLine> ...@@ -357,19 +357,12 @@ std::vector<TestIdentifier> GetFilteredTests(std::map<TestIdentifier, FileLine>
return FilterTests(fileLinesOut, gtestIDFilter, alsoRunDisabledTests); return FilterTests(fileLinesOut, gtestIDFilter, alsoRunDisabledTests);
} }
std::vector<TestIdentifier> GetCompiledInTests(std::map<TestIdentifier, FileLine> *fileLinesOut,
bool alsoRunDisabledTests)
{
TestIdentifierFilter passthroughFilter = [](const TestIdentifier &id) { return true; };
return FilterTests(fileLinesOut, passthroughFilter, alsoRunDisabledTests);
}
std::vector<TestIdentifier> GetShardTests(int shardIndex, std::vector<TestIdentifier> GetShardTests(int shardIndex,
int shardCount, int shardCount,
std::map<TestIdentifier, FileLine> *fileLinesOut, std::map<TestIdentifier, FileLine> *fileLinesOut,
bool alsoRunDisabledTests) bool alsoRunDisabledTests)
{ {
std::vector<TestIdentifier> allTests = GetCompiledInTests(fileLinesOut, alsoRunDisabledTests); std::vector<TestIdentifier> allTests = GetFilteredTests(fileLinesOut, alsoRunDisabledTests);
std::vector<TestIdentifier> shardTests; std::vector<TestIdentifier> shardTests;
for (int testIndex = shardIndex; testIndex < static_cast<int>(allTests.size()); for (int testIndex = shardIndex; testIndex < static_cast<int>(allTests.size());
...@@ -713,12 +706,6 @@ TestSuite::TestSuite(int *argc, char **argv) ...@@ -713,12 +706,6 @@ TestSuite::TestSuite(int *argc, char **argv)
exit(1); exit(1);
} }
if (mShardCount > 0)
{
printf("Cannot use filter file in conjunction with sharding parameters.\n");
exit(1);
}
uint32_t fileSize = 0; uint32_t fileSize = 0;
if (!GetFileSize(mFilterFile.c_str(), &fileSize)) if (!GetFileSize(mFilterFile.c_str(), &fileSize))
{ {
...@@ -745,18 +732,14 @@ TestSuite::TestSuite(int *argc, char **argv) ...@@ -745,18 +732,14 @@ TestSuite::TestSuite(int *argc, char **argv)
AddArg(argc, argv, mFilterString.c_str()); AddArg(argc, argv, mFilterString.c_str());
} }
// Call into gtest internals to force parameterized test name registration.
// TODO(jmadill): Clean this up so we don't need to call it.
testing::internal::UnitTestImpl *impl = testing::internal::GetUnitTestImpl();
impl->RegisterParameterizedTests();
if (mShardCount > 0) if (mShardCount > 0)
{ {
if (hasFilter) // Call into gtest internals to force parameterized test name registration.
{ testing::internal::UnitTestImpl *impl = testing::internal::GetUnitTestImpl();
printf("Cannot use gtest_filter in conjunction with sharding parameters.\n"); impl->RegisterParameterizedTests();
exit(1);
} // Initialize internal GoogleTest filter arguments so we can call "FilterMatchesTest".
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
mTestQueue = GetShardTests(mShardIndex, mShardCount, &mTestFileLines, alsoRunDisabledTests); mTestQueue = GetShardTests(mShardIndex, mShardCount, &mTestFileLines, alsoRunDisabledTests);
mFilterString = GetTestFilter(mTestQueue); mFilterString = GetTestFilter(mTestQueue);
...@@ -764,6 +747,9 @@ TestSuite::TestSuite(int *argc, char **argv) ...@@ -764,6 +747,9 @@ TestSuite::TestSuite(int *argc, char **argv)
// Note that we only add a filter string if we previously deleted a shader index/count // Note that we only add a filter string if we previously deleted a shader index/count
// argument. So we will have space for the new filter string in argv. // argument. So we will have space for the new filter string in argv.
AddArg(argc, argv, mFilterString.c_str()); AddArg(argc, argv, mFilterString.c_str());
// Force-re-initialize GoogleTest flags to load the shard filter.
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
} }
testing::InitGoogleTest(argc, argv); testing::InitGoogleTest(argc, argv);
......
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