Commit 39185acc by Jamie Madill Committed by Commit Bot

Test Runner: Re-use displays when using "bot mode".

This will allow us to speed up test execution by using multiple processes on non-Windows platforms. Because of the process isolation of "bot mode" we don't run into display re-use bugs like we do when running in a single process. Bug: angleproject:3162 Change-Id: I25370d4a07236e34f87e1c1efef8684f9891ecf8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2407835Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent c03c4490
......@@ -169,8 +169,14 @@ const char *GetColorName(GLColor color)
return nullptr;
}
// Always re-use displays when using --bot-mode in the test runner.
bool gBotModeEnabled = false;
bool ShouldAlwaysForceNewDisplay()
{
if (gBotModeEnabled)
return false;
// We prefer to reuse config displays. This is faster and solves a driver issue where creating
// many displays causes crashes. However this exposes other driver bugs on many other platforms.
// Conservatively enable the feature only on Windows Intel and NVIDIA for now.
......@@ -307,55 +313,9 @@ TestPlatformContext gPlatformContext;
constexpr uint32_t kWindowReuseLimit = 50;
constexpr char kUseConfig[] = "--use-config=";
constexpr char kSeparateProcessPerConfig[] = "--separate-process-per-config";
constexpr char kBotMode[] = "--bot-mode";
constexpr char kEnableANGLEPerTestCaptureLabel[] = "--angle-per-test-capture-label";
bool RunSeparateProcessesForEachConfig(int *argc, char *argv[])
{
std::vector<const char *> commonArgs;
for (int argIndex = 0; argIndex < *argc; ++argIndex)
{
if (strncmp(argv[argIndex], kSeparateProcessPerConfig, strlen(kSeparateProcessPerConfig)) !=
0)
{
commonArgs.push_back(argv[argIndex]);
}
}
// Force GoogleTest init now so that we hit the test config init in angle_test_instantiate.cpp.
// After instantiation is finished we can gather a full list of enabled configs. Then we can
// iterate the list of configs to spawn a child process for each enabled config.
testing::InitGoogleTest(argc, argv);
std::vector<std::string> configNames = GetAvailableTestPlatformNames();
bool success = true;
for (const std::string &config : configNames)
{
std::stringstream strstr;
strstr << kUseConfig << config;
std::string configStr = strstr.str();
std::vector<const char *> childArgs = commonArgs;
childArgs.push_back(configStr.c_str());
ProcessHandle process(childArgs, false, false);
if (!process->started() || !process->finish())
{
std::cerr << "Launching child config " << config << " failed.\n";
}
else if (process->getExitCode() != 0)
{
std::cerr << "Child config " << config << " failed with exit code "
<< process->getExitCode() << ".\n";
success = false;
}
}
return success;
}
void SetupEnvironmentVarsForCaptureReplay()
{
const ::testing::TestInfo *const testInfo =
......@@ -1395,10 +1355,9 @@ void ANGLEProcessTestArgs(int *argc, char *argv[])
{
SetSelectedConfig(argv[argIndex] + strlen(kUseConfig));
}
if (strncmp(argv[argIndex], kSeparateProcessPerConfig, strlen(kSeparateProcessPerConfig)) ==
0)
if (strncmp(argv[argIndex], kBotMode, strlen(kBotMode)) == 0)
{
gSeparateProcessPerConfig = true;
gBotModeEnabled = true;
}
if (strncmp(argv[argIndex], kEnableANGLEPerTestCaptureLabel,
strlen(kEnableANGLEPerTestCaptureLabel)) == 0)
......@@ -1406,23 +1365,4 @@ void ANGLEProcessTestArgs(int *argc, char *argv[])
gEnableANGLEPerTestCaptureLabel = true;
}
}
if (gSeparateProcessPerConfig)
{
if (IsConfigSelected())
{
std::cout << "Cannot use both a single test config and separate processes.\n";
exit(1);
}
if (RunSeparateProcessesForEachConfig(argc, argv))
{
exit(0);
}
else
{
std::cout << "Some subprocesses failed.\n";
exit(1);
}
}
}
......@@ -148,7 +148,6 @@ constexpr size_t kMaxConfigNameLen = 100;
std::array<char, kMaxConfigNameLen> gSelectedConfig;
} // namespace
bool gSeparateProcessPerConfig = false;
bool gEnableANGLEPerTestCaptureLabel = false;
bool IsConfigSelected()
......@@ -677,12 +676,6 @@ bool IsPlatformAvailable(const PlatformParameters &param)
<< " because it is not available.\n";
}
}
// Disable all tests in the parent process when running child processes.
if (gSeparateProcessPerConfig)
{
return false;
}
return result;
}
......
......@@ -244,10 +244,6 @@ std::vector<std::string> GetAvailableTestPlatformNames();
void SetSelectedConfig(const char *selectedConfig);
bool IsConfigSelected();
// Use a separate isolated process per test config. This works around
// driver flakiness when using multiple APIs/windows/etc in the same
// process.
extern bool gSeparateProcessPerConfig;
extern bool gEnableANGLEPerTestCaptureLabel;
// For use with ANGLE_INSTANTIATE_TEST_ARRAY
......
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