chromium/third_party/crashpad/crashpad/test/multiprocess_exec_test.cc

// Copyright 2014 The Crashpad Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "test/multiprocess_exec.h"

#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "partition_alloc/buildflags.h"
#include "test/test_paths.h"
#include "util/file/file_io.h"

namespace crashpad {
namespace test {
namespace {

class TestMultiprocessExec final : public MultiprocessExec {};

// This fails under macOS 12; https://crbug.com/1341377
//
// TODO(tasak): enable this test after making address randomization not to
// keep /dev/urandom open.
// PartitionAllocator opens /dev/urandom because of address randomization.
// (c.f. //base/rand_util_posix.cc and
// //base/allocator/partition_allocator/src/partition_alloc/random.cc) So when
// making PartitionAllocator default, multiprocess_exec_test_child will crash
// because of LOG(FATAL) << "close". https://crbug.com/1153544
#if defined(OS_POSIX) && PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \
    defined(OS_MAC)
#define MAYBE_MultiprocessExec
#else
#define MAYBE_MultiprocessExec
#endif
TEST(MultiprocessExec, MAYBE_MultiprocessExec) {}


CRASHPAD_CHILD_TEST_MAIN(SimpleMultiprocess) {}

TEST(MultiprocessExec, MultiprocessExecSimpleChild) {}

CRASHPAD_CHILD_TEST_MAIN(SimpleMultiprocessReturnsNonZero) {}

class TestMultiprocessExecEmpty final : public MultiprocessExec {};

TEST(MultiprocessExec, MultiprocessExecSimpleChildReturnsNonZero) {}

#if !BUILDFLAG(IS_WIN)

CRASHPAD_CHILD_TEST_MAIN(BuiltinTrapChild) {}

class TestBuiltinTrapTermination final : public MultiprocessExec {};

TEST(MultiprocessExec, BuiltinTrapTermination) {}

#endif  // !BUILDFLAG(IS_WIN)

}  // namespace
}  // namespace test
}  // namespace crashpad