Commit 0b8758b8 authored by Fabrice de Gans-Riberi's avatar Fabrice de Gans-Riberi Committed by Commit Bot

[Fuchsia] Fix a potential race condition in test_launcher.

The test launcher creates a /data directory for each of its
children. This is implemented as a directory with a unique number in
its name. Access to the number was not thread-safe, which this CL
fixes by using atomic operations to increase the number.

This is a potential fix for the content_unittests failure seen here:
https://ci.chromium.org/p/chromium/builders/luci.chromium.try/fuchsia_x64/117497

Change-Id: I42614b0de36e65ffb8bc811813132a8781036896
Reviewed-on: https://chromium-review.googlesource.com/1255926Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595887}
parent 65ec4285
......@@ -68,6 +68,7 @@
#if defined(OS_FUCHSIA)
#include <lib/zx/job.h>
#include "base/atomic_sequence_num.h"
#include "base/base_paths_fuchsia.h"
#include "base/fuchsia/default_job.h"
#include "base/fuchsia/file_utils.h"
......@@ -347,11 +348,10 @@ int LaunchChildTestProcessWithOptions(const CommandLine& command_line,
// Create the test subdirectory with a name that is unique to the child test
// process (qualified by parent PID and an autoincrementing test process
// index).
static size_t child_launch_index = 0;
static base::AtomicSequenceNumber child_launch_index;
base::FilePath nested_data_path = data_path.AppendASCII(
base::StringPrintf("test-%" PRIuS "-%" PRIuS,
base::Process::Current().Pid(), child_launch_index));
++child_launch_index;
base::StringPrintf("test-%" PRIuS "-%d", base::Process::Current().Pid(),
child_launch_index.GetNext()));
CHECK(!base::DirectoryExists(nested_data_path));
CHECK(base::CreateDirectory(nested_data_path));
DCHECK(base::DirectoryExists(nested_data_path));
......
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