Commit 336202d7 by Jamie Madill Committed by Commit Bot

Test Runner: Pass batch ID to child processes.

This will let both the ANGLETest and dEQP test runners handle child processes correctly. The existing ANGLETest runner will reuse displays, and the dEQP test runner will write to a batch-unique filename. This solves the problem of the multi-process --bot-mode writing to the same file from multiple children simultaneously. Long-term it will be good to include the dEQP QPA files into the test artifacts. Also disables flushing after every log write when running as a child process. This hugely improves performance on machines with no SSD. Test: https://chromium-swarm.appspot.com/task?id=4f2b87c4f8234910 Bug: angleproject:5157 Change-Id: I226d24adf55e0f8b98e5a8e7947862e6906b4c40 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2464424Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 3e8305f5
...@@ -31,6 +31,7 @@ namespace ...@@ -31,6 +31,7 @@ namespace
{ {
bool gGlobalError = false; bool gGlobalError = false;
bool gExpectError = false; bool gExpectError = false;
uint32_t gBatchId = 0;
constexpr char kInfoTag[] = "*RESULT"; constexpr char kInfoTag[] = "*RESULT";
...@@ -101,6 +102,7 @@ constexpr APIInfo kEGLDisplayAPIs[] = { ...@@ -101,6 +102,7 @@ constexpr APIInfo kEGLDisplayAPIs[] = {
constexpr char kdEQPEGLString[] = "--deqp-egl-display-type="; constexpr char kdEQPEGLString[] = "--deqp-egl-display-type=";
constexpr char kANGLEEGLString[] = "--use-angle="; constexpr char kANGLEEGLString[] = "--use-angle=";
constexpr char kdEQPCaseString[] = "--deqp-case="; constexpr char kdEQPCaseString[] = "--deqp-case=";
constexpr char kBatchIdString[] = "--batch-id=";
std::array<char, 500> gCaseStringBuffer; std::array<char, 500> gCaseStringBuffer;
...@@ -523,6 +525,19 @@ void dEQPTest<TestModuleIndex>::SetUpTestCase() ...@@ -523,6 +525,19 @@ void dEQPTest<TestModuleIndex>::SetUpTestCase()
argv.push_back("--deqp-visibility=hidden"); argv.push_back("--deqp-visibility=hidden");
} }
std::string logNameString;
if (gBatchId != 0)
{
std::stringstream logNameStream;
logNameStream << "--deqp-log-filename=test-results-batch-" << std::setfill('0')
<< std::setw(3) << gBatchId << ".qpa";
logNameString = logNameStream.str();
argv.push_back(logNameString.c_str());
// Flushing during multi-process execution punishes HDDs. http://anglebug.com/5157
argv.push_back("--deqp-log-flush=disable");
}
// Init the platform. // Init the platform.
if (!deqp_libtester_init_platform(static_cast<int>(argv.size()), argv.data(), if (!deqp_libtester_init_platform(static_cast<int>(argv.size()), argv.data(),
reinterpret_cast<void *>(&HandlePlatformError))) reinterpret_cast<void *>(&HandlePlatformError)))
...@@ -627,6 +642,12 @@ void HandleCaseName(const char *caseString, int *argc, int argIndex, char **argv ...@@ -627,6 +642,12 @@ void HandleCaseName(const char *caseString, int *argc, int argIndex, char **argv
argv[argIndex] = gCaseStringBuffer.data(); argv[argIndex] = gCaseStringBuffer.data();
} }
void HandleBatchId(const char *batchIdString)
{
std::stringstream batchIdStream(batchIdString);
batchIdStream >> gBatchId;
}
} // anonymous namespace } // anonymous namespace
// Called from main() to process command-line arguments. // Called from main() to process command-line arguments.
...@@ -652,6 +673,10 @@ void InitTestHarness(int *argc, char **argv) ...@@ -652,6 +673,10 @@ void InitTestHarness(int *argc, char **argv)
{ {
HandleCaseName(argv[argIndex] + strlen(kdEQPCaseString), argc, argIndex, argv); HandleCaseName(argv[argIndex] + strlen(kdEQPCaseString), argc, argIndex, argv);
} }
else if (strncmp(argv[argIndex], kBatchIdString, strlen(kBatchIdString)) == 0)
{
HandleBatchId(argv[argIndex] + strlen(kBatchIdString));
}
argIndex++; argIndex++;
} }
} }
......
...@@ -315,6 +315,7 @@ constexpr uint32_t kWindowReuseLimit = 50; ...@@ -315,6 +315,7 @@ constexpr uint32_t kWindowReuseLimit = 50;
constexpr char kUseConfig[] = "--use-config="; constexpr char kUseConfig[] = "--use-config=";
constexpr char kReuseDisplays[] = "--reuse-displays"; constexpr char kReuseDisplays[] = "--reuse-displays";
constexpr char kEnableANGLEPerTestCaptureLabel[] = "--angle-per-test-capture-label"; constexpr char kEnableANGLEPerTestCaptureLabel[] = "--angle-per-test-capture-label";
constexpr char kBatchId[] = "--batch-id=";
void SetupEnvironmentVarsForCaptureReplay() void SetupEnvironmentVarsForCaptureReplay()
{ {
...@@ -1358,12 +1359,17 @@ void ANGLEProcessTestArgs(int *argc, char *argv[]) ...@@ -1358,12 +1359,17 @@ void ANGLEProcessTestArgs(int *argc, char *argv[])
{ {
SetSelectedConfig(argv[argIndex] + strlen(kUseConfig)); SetSelectedConfig(argv[argIndex] + strlen(kUseConfig));
} }
if (strncmp(argv[argIndex], kReuseDisplays, strlen(kReuseDisplays)) == 0) else if (strncmp(argv[argIndex], kReuseDisplays, strlen(kReuseDisplays)) == 0)
{ {
gReuseDisplays = true; gReuseDisplays = true;
} }
if (strncmp(argv[argIndex], kEnableANGLEPerTestCaptureLabel, else if (strncmp(argv[argIndex], kBatchId, strlen(kBatchId)) == 0)
strlen(kEnableANGLEPerTestCaptureLabel)) == 0) {
// TODO(jmadill): Remove this once default. http://anglebug.com/5124
gReuseDisplays = true;
}
else if (strncmp(argv[argIndex], kEnableANGLEPerTestCaptureLabel,
strlen(kEnableANGLEPerTestCaptureLabel)) == 0)
{ {
gEnableANGLEPerTestCaptureLabel = true; gEnableANGLEPerTestCaptureLabel = true;
} }
......
...@@ -1009,7 +1009,8 @@ void TestSuite::onCrashOrTimeout(TestResultType crashOrTimeout) ...@@ -1009,7 +1009,8 @@ void TestSuite::onCrashOrTimeout(TestResultType crashOrTimeout)
WriteOutputFiles(true, mTestResults, mResultsFile, mHistogramJsonFile, mTestSuiteName.c_str()); WriteOutputFiles(true, mTestResults, mResultsFile, mHistogramJsonFile, mTestSuiteName.c_str());
} }
bool TestSuite::launchChildTestProcess(const std::vector<TestIdentifier> &testsInBatch) bool TestSuite::launchChildTestProcess(uint32_t batchId,
const std::vector<TestIdentifier> &testsInBatch)
{ {
constexpr uint32_t kMaxPath = 1000; constexpr uint32_t kMaxPath = 1000;
...@@ -1055,8 +1056,10 @@ bool TestSuite::launchChildTestProcess(const std::vector<TestIdentifier> &testsI ...@@ -1055,8 +1056,10 @@ bool TestSuite::launchChildTestProcess(const std::vector<TestIdentifier> &testsI
args.push_back(filterFileArg.c_str()); args.push_back(filterFileArg.c_str());
args.push_back(resultsFileArg.c_str()); args.push_back(resultsFileArg.c_str());
// TODO(jmadill): Remove this once migrated. http://anglebug.com/3162 std::stringstream batchIdStream;
args.push_back("--reuse-displays"); batchIdStream << "--batch-id=" << batchId;
std::string batchIdString = batchIdStream.str();
args.push_back(batchIdString.c_str());
for (const std::string &arg : mChildProcessArgs) for (const std::string &arg : mChildProcessArgs)
{ {
...@@ -1207,6 +1210,8 @@ int TestSuite::run() ...@@ -1207,6 +1210,8 @@ int TestSuite::run()
Timer messageTimer; Timer messageTimer;
messageTimer.start(); messageTimer.start();
uint32_t batchId = 0;
while (!mTestQueue.empty() || !mCurrentProcesses.empty()) while (!mTestQueue.empty() || !mCurrentProcesses.empty())
{ {
bool progress = false; bool progress = false;
...@@ -1217,7 +1222,7 @@ int TestSuite::run() ...@@ -1217,7 +1222,7 @@ int TestSuite::run()
std::vector<TestIdentifier> testsInBatch = mTestQueue.front(); std::vector<TestIdentifier> testsInBatch = mTestQueue.front();
mTestQueue.pop(); mTestQueue.pop();
if (!launchChildTestProcess(testsInBatch)) if (!launchChildTestProcess(++batchId, testsInBatch))
{ {
return 1; return 1;
} }
......
...@@ -123,7 +123,7 @@ class TestSuite ...@@ -123,7 +123,7 @@ class TestSuite
private: private:
bool parseSingleArg(const char *argument); bool parseSingleArg(const char *argument);
bool launchChildTestProcess(const std::vector<TestIdentifier> &testsInBatch); bool launchChildTestProcess(uint32_t batchId, const std::vector<TestIdentifier> &testsInBatch);
bool finishProcess(ProcessInfo *processInfo); bool finishProcess(ProcessInfo *processInfo);
int printFailuresAndReturnCount() const; int printFailuresAndReturnCount() const;
void startWatchdog(); void startWatchdog();
......
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