Fix non-bot mode sharding on Android and disable elsewhere.

There is no need to apply sharding internally on Android,
since it is done on the host, except when listing tests.

And on other platforms sharding in non-bot mode is not useful.

Patch authored by Yuly Novikov (ynovikov@chromium.org)

Bug: angleproject:5417
Change-Id: Iddc0e1a38fb514617dce527acc99d0dce85ca177
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3399250
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill 2021-09-17 14:39:36 -04:00 коммит произвёл Angle LUCI CQ
Родитель fa3241b706
Коммит fdadc420a2
1 изменённых файлов: 28 добавлений и 20 удалений

Просмотреть файл

@ -964,6 +964,17 @@ void GTestListTests(const std::map<TestIdentifier, TestResult> &resultsMap)
}
}
}
// On Android, batching is done on the host, i.e. externally.
// TestSuite executes on the device and should just passthrough all args to GTest.
bool UsesExternalBatching()
{
#if defined(ANGLE_PLATFORM_ANDROID)
return true;
#else
return false;
#endif
}
} // namespace
// static
@ -1095,6 +1106,12 @@ TestSuite::TestSuite(int *argc, char **argv)
++argIndex;
}
if (UsesExternalBatching() && mBotMode)
{
printf("Bot mode is mutually exclusive with external batching.\n");
exit(EXIT_FAILURE);
}
mTestResults.currentTestTimeout = mTestTimeout;
#if defined(ANGLE_PLATFORM_ANDROID)
@ -1242,27 +1259,18 @@ TestSuite::TestSuite(int *argc, char **argv)
// If there's only one shard, we can use the testSet as defined above.
if (mShardCount > 1)
{
testSet = GetShardTests(testSet, mShardIndex, mShardCount, &mTestFileLines,
alsoRunDisabledTests);
if (!mBotMode)
if (!mBotMode && !UsesExternalBatching())
{
mFilterString = GetTestFilter(testSet);
if (filterArgIndex.valid())
{
argv[filterArgIndex.value()] = const_cast<char *>(mFilterString.c_str());
}
else
{
// Note that we only add a filter string if we previously deleted a shard
// index/count argument. So we will have space for the new filter string in
// argv.
AddArg(argc, argv, mFilterString.c_str());
}
// Force-re-initialize GoogleTest flags to load the shard filter.
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
printf("Sharding is only supported in bot mode or external batching.\n");
exit(EXIT_FAILURE);
}
// With external batching, we must use exactly the testSet as defined externally.
// But when listing tests, we do need to apply sharding ourselves,
// since we use our own implementation for listing tests and not GTest directly.
if (!UsesExternalBatching() || mGTestListTests || mListTests)
{
testSet = GetShardTests(testSet, mShardIndex, mShardCount, &mTestFileLines,
alsoRunDisabledTests);
}
}
}