Commit 31868665 by Jamie Madill Committed by Commit Bot

Test Runner: Only run watchdog in child processes.

For single test execution we don't need to be running the watchdog thread. This only serves to cause timeouts in slow running tests. Adds a new method to keep the --batch-id argument in the list of parameters so other functions can process them. Bug: angleproject:5124 Bug: angleproject:5218 Change-Id: I958230149b7d79830802cd55f67f0190de607200 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2495282Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e86b4257
...@@ -42,6 +42,7 @@ constexpr char kResultFileArg[] = "--results-file="; ...@@ -42,6 +42,7 @@ constexpr char kResultFileArg[] = "--results-file=";
constexpr char kHistogramJsonFileArg[] = "--histogram-json-file="; constexpr char kHistogramJsonFileArg[] = "--histogram-json-file=";
constexpr char kListTests[] = "--gtest_list_tests"; constexpr char kListTests[] = "--gtest_list_tests";
constexpr char kPrintTestStdout[] = "--print-test-stdout"; constexpr char kPrintTestStdout[] = "--print-test-stdout";
constexpr char kBatchId[] = "--batch-id=";
#if defined(NDEBUG) #if defined(NDEBUG)
constexpr int kDefaultTestTimeout = 20; constexpr int kDefaultTestTimeout = 20;
#else #else
...@@ -93,6 +94,12 @@ bool ParseIntArg(const char *flag, const char *argument, int *valueOut) ...@@ -93,6 +94,12 @@ bool ParseIntArg(const char *flag, const char *argument, int *valueOut)
return true; return true;
} }
bool ParseIntArgNoDelete(const char *flag, const char *argument, int *valueOut)
{
ParseIntArg(flag, argument, valueOut);
return false;
}
bool ParseFlag(const char *expected, const char *actual, bool *flagOut) bool ParseFlag(const char *expected, const char *actual, bool *flagOut)
{ {
if (strcmp(expected, actual) == 0) if (strcmp(expected, actual) == 0)
...@@ -806,7 +813,8 @@ TestSuite::TestSuite(int *argc, char **argv) ...@@ -806,7 +813,8 @@ TestSuite::TestSuite(int *argc, char **argv)
mTotalResultCount(0), mTotalResultCount(0),
mMaxProcesses(std::min(NumberOfProcessors(), kDefaultMaxProcesses)), mMaxProcesses(std::min(NumberOfProcessors(), kDefaultMaxProcesses)),
mTestTimeout(kDefaultTestTimeout), mTestTimeout(kDefaultTestTimeout),
mBatchTimeout(kDefaultBatchTimeout) mBatchTimeout(kDefaultBatchTimeout),
mBatchId(-1)
{ {
Optional<int> filterArgIndex; Optional<int> filterArgIndex;
bool alsoRunDisabledTests = false; bool alsoRunDisabledTests = false;
...@@ -1034,6 +1042,8 @@ bool TestSuite::parseSingleArg(const char *argument) ...@@ -1034,6 +1042,8 @@ bool TestSuite::parseSingleArg(const char *argument)
ParseIntArg("--max-processes=", argument, &mMaxProcesses) || ParseIntArg("--max-processes=", argument, &mMaxProcesses) ||
ParseIntArg(kTestTimeoutArg, argument, &mTestTimeout) || ParseIntArg(kTestTimeoutArg, argument, &mTestTimeout) ||
ParseIntArg("--batch-timeout=", argument, &mBatchTimeout) || ParseIntArg("--batch-timeout=", argument, &mBatchTimeout) ||
// Other test functions consume the batch ID, so keep it in the list.
ParseIntArgNoDelete(kBatchId, argument, &mBatchId) ||
ParseStringArg("--results-directory=", argument, &mResultsDirectory) || ParseStringArg("--results-directory=", argument, &mResultsDirectory) ||
ParseStringArg(kResultFileArg, argument, &mResultsFile) || ParseStringArg(kResultFileArg, argument, &mResultsFile) ||
ParseStringArg("--isolated-script-test-output=", argument, &mResultsFile) || ParseStringArg("--isolated-script-test-output=", argument, &mResultsFile) ||
...@@ -1115,7 +1125,7 @@ bool TestSuite::launchChildTestProcess(uint32_t batchId, ...@@ -1115,7 +1125,7 @@ bool TestSuite::launchChildTestProcess(uint32_t batchId,
args.push_back(resultsFileArg.c_str()); args.push_back(resultsFileArg.c_str());
std::stringstream batchIdStream; std::stringstream batchIdStream;
batchIdStream << "--batch-id=" << batchId; batchIdStream << kBatchId << batchId;
std::string batchIdString = batchIdStream.str(); std::string batchIdString = batchIdStream.str();
args.push_back(batchIdString.c_str()); args.push_back(batchIdString.c_str());
...@@ -1274,7 +1284,8 @@ int TestSuite::run() ...@@ -1274,7 +1284,8 @@ int TestSuite::run()
// Run tests serially. // Run tests serially.
if (!mBotMode) if (!mBotMode)
{ {
if (!angle::IsDebuggerAttached()) // Only start the watchdog if the debugger is not attached and we're a child process.
if (!angle::IsDebuggerAttached() && mBatchId != -1)
{ {
startWatchdog(); startWatchdog();
} }
......
...@@ -151,6 +151,7 @@ class TestSuite ...@@ -151,6 +151,7 @@ class TestSuite
int mMaxProcesses; int mMaxProcesses;
int mTestTimeout; int mTestTimeout;
int mBatchTimeout; int mBatchTimeout;
int mBatchId;
std::vector<std::string> mChildProcessArgs; std::vector<std::string> mChildProcessArgs;
std::map<TestIdentifier, FileLine> mTestFileLines; std::map<TestIdentifier, FileLine> mTestFileLines;
std::vector<ProcessInfo> mCurrentProcesses; std::vector<ProcessInfo> mCurrentProcesses;
......
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