Merge pull request #4477 from tmiguelf:feature/soup_cleanup

PiperOrigin-RevId: 611133343
Change-Id: Ieef806f51fcbc2877805dae415f76d03547b8dfa
This commit is contained in:
Copybara-Service 2024-02-28 09:48:31 -08:00
commit e15c5a51b8

View File

@ -630,13 +630,13 @@ bool DeathTestImpl::Passed(bool status_ok) {
#ifndef GTEST_OS_WINDOWS #ifndef GTEST_OS_WINDOWS
// Note: The return value points into args, so the return value's lifetime is // Note: The return value points into args, so the return value's lifetime is
// bound to that of args. // bound to that of args.
static std::unique_ptr<char*[]> CreateArgvFromArgs( static std::vector<char*> CreateArgvFromArgs(std::vector<std::string>& args) {
std::vector<std::string>& args) { std::vector<char*> result;
auto result = std::make_unique<char*[]>(args.size() + 1); result.reserve(args.size() + 1);
for (size_t i = 0; i < args.size(); ++i) { for (auto& arg : args) {
result[i] = &args[i][0]; result.push_back(&arg[0]);
} }
result[args.size()] = nullptr; // extra null terminator result.push_back(nullptr); // Extra null terminator.
return result; return result;
} }
#endif #endif
@ -1036,8 +1036,8 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
// "Fuchsia Test Component" which contains a "Fuchsia Component Manifest") // "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
// Launching processes is a privileged operation in Fuchsia, and the // Launching processes is a privileged operation in Fuchsia, and the
// declaration indicates that the ability is required for the component. // declaration indicates that the ability is required for the component.
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args); std::vector<char*> argv = CreateArgvFromArgs(args);
status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(), status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.data(),
nullptr, 2, spawn_actions, nullptr, 2, spawn_actions,
child_process_.reset_and_get_address(), nullptr); child_process_.reset_and_get_address(), nullptr);
GTEST_DEATH_TEST_CHECK_(status == ZX_OK); GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
@ -1388,8 +1388,8 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
// is necessary. // is necessary.
FlushInfoLog(); FlushInfoLog();
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args); std::vector<char*> argv = CreateArgvFromArgs(args);
const pid_t child_pid = ExecDeathTestSpawnChild(argv.get(), pipe_fd[0]); const pid_t child_pid = ExecDeathTestSpawnChild(argv.data(), pipe_fd[0]);
GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
set_child_pid(child_pid); set_child_pid(child_pid);
set_read_fd(pipe_fd[0]); set_read_fd(pipe_fd[0]);