Commit 738e180d authored by proberge's avatar proberge Committed by Commit Bot

Try fix flaky chrome_cleaner test failures

The underlying issue seems to be related to a sandboxed process failing
to open or truncate its log file. All the tests shared the same file,
leading to flaky issues despite the tests running with --single-process.

To avoid this issue, we now tell the
cleaner/reporter process and their spawned sandboxes to log to a
temporary folder.

Bug: 1030333
Change-Id: If339c623b148b8b458a32e4d974d6a642bc4f12b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972494
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726142}
parent 1cf44aa4
......@@ -49,6 +49,7 @@ const char* kSwitchesToPropagate[] = {
kExtendedSafeBrowsingEnabledSwitch,
switches::kTestChildProcess,
kTestingSwitch,
kTestLoggingPathSwitch,
};
std::map<SandboxType, base::Process>* g_target_processes = nullptr; // Leaked.
......
......@@ -60,6 +60,10 @@ const std::vector<base::string16> kAllowedLogStringsForSanitizationCheck = {
// IsFilePresentLocally in file_path_sanitization.cc fits Case 1.
L"isfilepresentlocally failed to get attributes: ",
// The cleaner/reporter process spawned by this test spawns a sandbox with
// the test-logging-path flag pointing to a temporary directory.
L"--test-logging-path=",
};
// Parse to |report| the serialized report dumped by |executable_name|. Return
......@@ -338,7 +342,7 @@ class CleanerTest
chrome_cleaner::ExecutionMode execution_mode =
chrome_cleaner::ExecutionMode::kNone) {
base::CommandLine command_line(executable_path);
chrome_cleaner::AppendTestSwitches(&command_line);
chrome_cleaner::AppendTestSwitches(temp_dir_, &command_line);
command_line.AppendSwitchASCII(
chrome_cleaner::kEngineSwitch,
base::NumberToString(static_cast<int>(engine_)));
......
......@@ -233,11 +233,16 @@ bool RegisterTestTask(TaskScheduler* task_scheduler,
return true;
}
void AppendTestSwitches(base::CommandLine* command_line) {
void AppendTestSwitches(const base::ScopedTempDir& temp_dir,
base::CommandLine* command_line) {
command_line->AppendSwitch(kNoRecoveryComponentSwitch);
command_line->AppendSwitch(kNoCrashUploadSwitch);
command_line->AppendSwitch(kNoReportUploadSwitch);
command_line->AppendSwitch(kNoSelfDeleteSwitch);
// Some tests spawn an executable which spawns a sandboxed process. All of
// these logs should go to a temporary directory so we can ensure they are
// deleted after the test.
command_line->AppendSwitchPath(kTestLoggingPathSwitch, temp_dir.GetPath());
}
void ExpectDiskFootprint(const PUPData::PUP& pup,
......
......@@ -109,7 +109,8 @@ bool RegisterTestTask(TaskScheduler* task_scheduler,
// Append switches to the command line that is used to run cleaner or reporter
// in tests. Switches will disable logs upload, profile reset and other side
// effects.
void AppendTestSwitches(base::CommandLine* command_line);
void AppendTestSwitches(const base::ScopedTempDir& temp_dir,
base::CommandLine* command_line);
// Expect the |expected_path| to be found in expanded disk footprint of |pup|.
void ExpectDiskFootprint(const PUPData::PUP& pup,
......
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