From 952cd83aefe865e2960bd3e59dbe39c9a44d6595 Mon Sep 17 00:00:00 2001 From: Yavor Goulishev Date: Sat, 22 Feb 2025 02:48:08 +0000 Subject: [PATCH 1/5] Debug Build base_unittests hermetically. b/397476624 --- .github/config/linux-evergreen.json | 1 + base/BUILD.gn | 84 ++++++++++++------- .../partition_alloc_unittest.cc | 4 +- ...lt_dispatch_to_partition_alloc_unittest.cc | 4 +- .../shim/allocator_shim_unittest.cc | 8 +- base/base_paths_posix.cc | 2 +- base/debug/stack_trace.cc | 3 + base/files/file_util_unittest.cc | 6 +- base/files/important_file_writer_cleaner.cc | 2 +- base/process/memory_unittest.cc | 4 +- base/profiler/module_cache.cc | 4 + base/test/BUILD.gn | 30 ++++--- base/threading/platform_thread_posix.cc | 2 +- third_party/fontconfig/include/config.h | 6 ++ third_party/libevent/BUILD.gn | 2 +- 15 files changed, 102 insertions(+), 60 deletions(-) diff --git a/.github/config/linux-evergreen.json b/.github/config/linux-evergreen.json index 0a5074a51b66..52ec91cbd90f 100644 --- a/.github/config/linux-evergreen.json +++ b/.github/config/linux-evergreen.json @@ -5,6 +5,7 @@ ], "targets": [ "base", + "base_unittests", "nplb" ], "includes": [ diff --git a/base/BUILD.gn b/base/BUILD.gn index 98c9ab74d5c6..81e82a83c5ce 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -105,15 +105,7 @@ if (is_apple) { "mac requires mach absolute time ticks") } -# TODO: b/384652502 - Cobalt: Fix compiler errors building hermetically. -# ../../third_party/libevent/signal.c:43:10: fatal error: 'sys/queue.h' file not found -# #include -# Determines whether libevent should be dep. -if (is_cobalt_hermetic_build) { - dep_libevent = false -} else { - dep_libevent = !is_fuchsia && !is_win && !is_mac && !is_nacl -} +dep_libevent = !is_fuchsia && !is_win && !is_mac && !is_nacl # Determines whether message_pump_libevent should be used. use_libevent = dep_libevent && !is_ios @@ -1760,15 +1752,12 @@ component("base") { "debug/proc_maps_linux.cc", "debug/proc_maps_linux.h", "files/dir_reader_linux.h", - "files/scoped_file_linux.cc", "process/internal_linux.cc", "process/internal_linux.h", - "process/memory_linux.cc", "process/process_handle_linux.cc", "process/process_iterator_linux.cc", "process/process_linux.cc", "process/process_metrics_linux.cc", - "threading/platform_thread_linux.cc", "threading/thread_type_delegate.cc", "threading/thread_type_delegate.h", @@ -1789,19 +1778,12 @@ component("base") { # ../../base/process/process_metrics_posix.cc:119:27: error: invalid use of incomplete type 'mallinfo' # struct mallinfo minfo = mallinfo(); "process/process_metrics_posix.cc", + "scoped_native_library.cc", "sync_socket_posix.cc", # base/posix/unix_domain_socket.cc:91:22: error: implicit conversion loses integer precision: "posix/unix_domain_socket.cc", "posix/unix_domain_socket.h", - - # SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW { - # ^ - # ../../third_party/musl/include/malloc.h:19:8: note: previous declaration is here - # size_t malloc_usable_size(void *); - "allocator/partition_allocator/shim/allocator_shim_override_cpp_symbols.h", - "allocator/partition_allocator/shim/allocator_shim_override_glibc_weak_symbols.h", - "allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h", ] } @@ -3568,14 +3550,19 @@ test("base_unittests") { "//starboard:starboard_group", "//starboard/common", ] - } + data_deps = [ + "//base/test:immediate_crash_test_helper", + "//testing/buildbot/filters:base_unittests_filters", + ] + } else { - data_deps = [ - "//base/test:immediate_crash_test_helper", - "//base/test:test_child_process", - "//base/test:test_shared_library", - "//testing/buildbot/filters:base_unittests_filters", - ] + data_deps = [ + "//base/test:immediate_crash_test_helper", + "//base/test:test_child_process", + "//base/test:test_shared_library", + "//testing/buildbot/filters:base_unittests_filters", + ] + } if (is_android && enable_chrome_android_internal) { data_deps += [ "//clank/build/bot/filters:base_unittests_filters" ] @@ -3682,6 +3669,31 @@ test("base_unittests") { } } + if (is_starboard) { + sources -= [ + "debug/proc_maps_linux_unittest.cc", + "debug/stack_trace_unittest.cc", + "files/file_util_unittest.cc", + "files/scoped_file_linux_unittest.cc", + "immediate_crash_unittest.cc", + "memory/platform_shared_memory_region_unittest.cc", + "metrics/field_trial_unittest.cc", + "native_library_unittest.cc", + "process/process_metrics_unittest.cc", + "process/process_util_unittest.cc", + "process/process_unittest.cc", + "profiler/module_cache_unittest.cc", + "profiler/stack_sampling_profiler_unittest.cc", + "profiler/stack_sampler_unittest.cc", + "sync_socket_unittest.cc", + "system/sys_info_unittest.cc", + "test/launcher/test_launcher_unittest.cc", + "test/launcher/test_results_tracker_unittest.cc", + "test/task_environment_unittest.cc", + "task/thread_pool/thread_pool_impl_unittest.cc", + ] + } + if (is_mac) { sources += [ "allocator/partition_allocator/shim/allocator_interception_mac_unittest.mm", @@ -3720,7 +3732,14 @@ test("base_unittests") { "posix/file_descriptor_shuffle_unittest.cc", "posix/unix_domain_socket_unittest.cc", ] - if (!is_nacl && !is_apple) { + if (is_starboard) { + sources -= [ + "message_loop/fd_watch_controller_posix_unittest.cc", + "files/file_descriptor_watcher_posix_unittest.cc", + "posix/unix_domain_socket_unittest.cc", + ] + } + if (!is_nacl && !is_apple && !is_starboard) { sources += [ "profiler/stack_base_address_posix_unittest.cc", "profiler/stack_copier_signal_unittest.cc", @@ -3898,6 +3917,11 @@ test("base_unittests") { "allocator/partition_allocator/thread_cache_unittest.cc", ] + if (is_starboard) { + sources -= [ + "allocator/partition_allocator/page_allocator_unittest.cc", + ] + } if (use_starscan) { sources += [ "allocator/partition_allocator/starscan/pcscan_scheduling_unittest.cc", @@ -3955,7 +3979,7 @@ test("base_unittests") { } } - if (is_fuchsia || is_linux || is_chromeos) { + if (is_fuchsia || (is_linux && !is_cobalt_hermetic_build) || is_chromeos) { sources += [ "debug/elf_reader_unittest.cc", "debug/test_elf_image_builder.cc", @@ -4045,7 +4069,7 @@ test("base_unittests") { [ "//build/config/fuchsia/test/logger.shard.test-cml" ] } - if (!is_fuchsia && !is_ios) { + if (!is_fuchsia && !is_ios && !is_starboard) { sources += [ "files/file_locking_unittest.cc" ] } diff --git a/base/allocator/partition_allocator/partition_alloc_unittest.cc b/base/allocator/partition_allocator/partition_alloc_unittest.cc index 010497bf6070..dee68b29ea30 100644 --- a/base/allocator/partition_allocator/partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/partition_alloc_unittest.cc @@ -54,12 +54,12 @@ #endif #if BUILDFLAG(IS_POSIX) -#if BUILDFLAG(IS_LINUX) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) // We need PKEY_DISABLE_WRITE in this file; glibc defines it in sys/mman.h but // it's actually Linux-specific and other Linux libcs define it in linux/mman.h. // We have to include both to be sure we get the definition. #include -#endif // BUILDFLAG(IS_LINUX) +#endif // BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) #include #include #include diff --git a/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc b/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc index 0dcc19c42b22..ff388e0c42fd 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc @@ -25,7 +25,7 @@ namespace allocator_shim::internal { #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) // Platforms on which we override weak libc symbols. -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) PA_NOINLINE void FreeForTest(void* data) { free(data); @@ -85,7 +85,7 @@ TEST(PartitionAllocAsMalloc, Mallinfo) { #endif } -#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) diff --git a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc index a8539e1323f1..cb1b689e1cae 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc +++ b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc @@ -393,14 +393,14 @@ TEST_F(AllocatorShimTest, InterceptLibcSymbols) { ASSERT_GE(aligned_allocs_intercepted_by_alignment[128], 1u); ASSERT_GE(aligned_allocs_intercepted_by_size[53], 1u); -#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) void* pvalloc_ptr = pvalloc(67); ASSERT_NE(nullptr, pvalloc_ptr); ASSERT_EQ(0u, reinterpret_cast(pvalloc_ptr) % kPageSize); ASSERT_GE(aligned_allocs_intercepted_by_alignment[kPageSize], 1u); // pvalloc rounds the size up to the next page. ASSERT_GE(aligned_allocs_intercepted_by_size[kPageSize], 1u); -#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) #endif // !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE) @@ -432,10 +432,10 @@ TEST_F(AllocatorShimTest, InterceptLibcSymbols) { free(memalign_ptr); ASSERT_GE(frees_intercepted_by_addr[Hash(memalign_ptr)], 1u); -#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) free(pvalloc_ptr); ASSERT_GE(frees_intercepted_by_addr[Hash(pvalloc_ptr)], 1u); -#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) #endif // !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE) diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc index 046b05bf25d3..c83d2a9ac7f5 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -38,7 +38,7 @@ bool PathProviderPosix(int key, FilePath* result) { switch (key) { case FILE_EXE: case FILE_MODULE: { // TODO(evanm): is this correct? -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) FilePath bin_dir; if (!ReadSymbolicLink(FilePath(kProcSelfExe), &bin_dir)) { NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; diff --git a/base/debug/stack_trace.cc b/base/debug/stack_trace.cc index f7d9b08bbc79..833a92a4f0c8 100644 --- a/base/debug/stack_trace.cc +++ b/base/debug/stack_trace.cc @@ -273,7 +273,10 @@ void StackTrace::Print() const { } void StackTrace::OutputToStream(std::ostream* os) const { +// TODO: (cobalt b/398296821) Use stack_trace_starboard.cc or port stack_trace_posix.cc. +#if !defined(IS_COBALT_HERMETIC_BUILD) OutputToStreamWithPrefix(os, nullptr); +#endif } std::string StackTrace::ToString() const { diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc index 42dd27e90ced..59bb6a9b045f 100644 --- a/base/files/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -77,7 +77,7 @@ #include #endif -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) #include #endif @@ -1912,7 +1912,7 @@ TEST_F(FileUtilTest, DeleteDirRecursiveWithOpenFile) { File::FLAG_CREATE | File::FLAG_READ | File::FLAG_WRITE); ASSERT_TRUE(PathExists(file_name3)); -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) // On Windows, holding the file open in sufficient to make it un-deletable. // The POSIX code is verifiable on Linux by creating an "immutable" file but // this is best-effort because it's not supported by all file systems. Both @@ -1933,7 +1933,7 @@ TEST_F(FileUtilTest, DeleteDirRecursiveWithOpenFile) { DeletePathRecursively(test_subdir); EXPECT_FALSE(PathExists(file_name2)); -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) // Make sure that the test can clean up after itself. if (file_attrs_supported) { flags &= ~FS_IMMUTABLE_FL; diff --git a/base/files/important_file_writer_cleaner.cc b/base/files/important_file_writer_cleaner.cc index 46e1263fb591..adb1f3bdba6d 100644 --- a/base/files/important_file_writer_cleaner.cc +++ b/base/files/important_file_writer_cleaner.cc @@ -25,7 +25,7 @@ namespace base { namespace { base::Time GetUpperBoundTime() { -#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA) || defined(IS_COBALT_HERMETIC_BUILD) // If process creation time is not available then use instance creation // time as the upper-bound for old files. Modification times may be // rounded-down to coarse-grained increments, e.g. FAT has 2s granularity, diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc index 090fe9b84625..bbd1e231b1a7 100644 --- a/base/process/memory_unittest.cc +++ b/base/process/memory_unittest.cc @@ -367,7 +367,7 @@ TEST_F(OutOfMemoryDeathTest, SecurityAlignedRealloc) { #endif // BUILDFLAG(IS_WIN) #endif // !BUILDFLAG(IS_MAC) -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) TEST_F(OutOfMemoryDeathTest, Valloc) { ASSERT_OOM_DEATH({ @@ -413,7 +413,7 @@ TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) { value_ = MallocWrapper(test_size_); }); } -#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) // Android doesn't implement posix_memalign(). #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) diff --git a/base/profiler/module_cache.cc b/base/profiler/module_cache.cc index 7911f89e5c2f..4da6bee41596 100644 --- a/base/profiler/module_cache.cc +++ b/base/profiler/module_cache.cc @@ -64,6 +64,9 @@ ModuleCache::~ModuleCache() { } const ModuleCache::Module* ModuleCache::GetModuleForAddress(uintptr_t address) { +#if defined(IS_COBALT_HERMETIC_BUILD) + return nullptr; +#else if (const ModuleCache::Module* module = GetExistingModuleForAddress(address)) return module; @@ -77,6 +80,7 @@ const ModuleCache::Module* ModuleCache::GetModuleForAddress(uintptr_t address) { // TODO(https://crbug.com/1131769): Reintroduce DCHECK(result.second) after // fixing the issue that is causing it to fail. return result.first->get(); +#endif // defined(IS_COBALT_HERMETIC_BUILD) } std::vector ModuleCache::GetModules() const { diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn index e9fc338a7681..ab171fd0edd3 100644 --- a/base/test/BUILD.gn +++ b/base/test/BUILD.gn @@ -172,7 +172,7 @@ static_library("test_support") { if (enable_base_tracing) { public_deps += [ "//third_party/perfetto:perfetto_test_support" ] - if (!is_chromeos) { + if (!is_chromeos && !is_cobalt_hermetic_build) { # TODO(rasikan): Add to ios and chromeos when unblocked by the chromiumos # change to add the shared lib to the chrome-binary-tests directory. public_deps += [ ":test_trace_processor" ] @@ -292,7 +292,7 @@ static_library("test_support") { ] } - if (use_blink) { + if (use_blink && !is_cobalt_hermetic_build) { sources += [ "launcher/test_launcher.cc", "launcher/test_launcher.h", @@ -385,12 +385,14 @@ shared_library("immediate_crash_test_helper") { } } -# This shared library is dynamically loaded by NativeLibrary unittests. -shared_library("test_shared_library") { - testonly = true - sources = [ "test_shared_library.cc" ] +if (!is_starboard) { + # This shared library is dynamically loaded by NativeLibrary unittests. + shared_library("test_shared_library") { + testonly = true + sources = [ "test_shared_library.cc" ] - deps = [ ":native_library_test_utils" ] + deps = [ ":native_library_test_utils" ] + } } if (is_fuchsia || is_linux || is_chromeos) { @@ -484,14 +486,16 @@ if (is_ios) { } } -# Trivial executable which outputs space-delimited argv to stdout, -# used for testing. -executable("test_child_process") { - testonly = true - sources = [ "test_child_process.cc" ] +if (!is_starboard) { + # Trivial executable which outputs space-delimited argv to stdout, + # used for testing. + executable("test_child_process") { + testonly = true + sources = [ "test_child_process.cc" ] + } } -if (enable_base_tracing) { +if (enable_base_tracing && !is_cobalt_hermetic_build) { # We encapsulate the trace processor in a separate shared library to prevent # any duplicate symbol issues. Perfetto symbols are exported by chromium’s # base via a public_dep on libperfetto; libtrace_processor also depends on diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index 6743b440207c..593e9621243a 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -353,7 +353,7 @@ void PlatformThread::Detach(PlatformThreadHandle thread_handle) { // static bool PlatformThread::CanChangeThreadType(ThreadType from, ThreadType to) { -#if BUILDFLAG(IS_NACL) +#if BUILDFLAG(IS_NACL) || defined(IS_COBALT_HERMETIC_BUILD) return false; #else if (from >= to) { diff --git a/third_party/fontconfig/include/config.h b/third_party/fontconfig/include/config.h index 61f8a0c6fe09..fbcf817354b0 100644 --- a/third_party/fontconfig/include/config.h +++ b/third_party/fontconfig/include/config.h @@ -155,8 +155,14 @@ /* Define to 1 if you have the `random' function. */ #define HAVE_RANDOM 1 + +#if defined(IS_COBALT_HERMETIC_BUILD) +/* TODO: (cobalt b/398295440) Add `random_r' support to Evergreen. */ +#define HAVE_RANDOM_R 0 +#else /* Define to 1 if you have the `random_r' function. */ #define HAVE_RANDOM_R 1 +#endif /* Define to 1 if you have the `rand_r' function. */ #define HAVE_RAND_R 1 diff --git a/third_party/libevent/BUILD.gn b/third_party/libevent/BUILD.gn index 61e94cc0cd03..df803a64cb74 100644 --- a/third_party/libevent/BUILD.gn +++ b/third_party/libevent/BUILD.gn @@ -36,7 +36,7 @@ static_library("libevent") { ] defines = [ "HAVE_CONFIG_H" ] - if (is_cronet_build) { + if (is_cronet_build || is_starboard) { include_dirs = [ "compat" ] } else { include_dirs = [] From d9358b0eff172401dc60395aacedfdfe73c3e040 Mon Sep 17 00:00:00 2001 From: Yavor Goulishev Date: Mon, 24 Feb 2025 22:11:25 +0000 Subject: [PATCH 2/5] Re-enable file tests. --- base/BUILD.gn | 3 --- 1 file changed, 3 deletions(-) diff --git a/base/BUILD.gn b/base/BUILD.gn index 81e82a83c5ce..dc102d3223e3 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -3674,7 +3674,6 @@ test("base_unittests") { "debug/proc_maps_linux_unittest.cc", "debug/stack_trace_unittest.cc", "files/file_util_unittest.cc", - "files/scoped_file_linux_unittest.cc", "immediate_crash_unittest.cc", "memory/platform_shared_memory_region_unittest.cc", "metrics/field_trial_unittest.cc", @@ -3734,8 +3733,6 @@ test("base_unittests") { ] if (is_starboard) { sources -= [ - "message_loop/fd_watch_controller_posix_unittest.cc", - "files/file_descriptor_watcher_posix_unittest.cc", "posix/unix_domain_socket_unittest.cc", ] } From 36351fe163baabb5ee389d40a26b484d5f8b77db Mon Sep 17 00:00:00 2001 From: Yavor Goulishev Date: Mon, 24 Feb 2025 22:18:38 +0000 Subject: [PATCH 3/5] Use IS_STARBOARD in partition_allocator. --- .../partition_allocator/partition_alloc_unittest.cc | 4 ++-- ...r_shim_default_dispatch_to_partition_alloc_unittest.cc | 4 ++-- .../partition_allocator/shim/allocator_shim_unittest.cc | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/base/allocator/partition_allocator/partition_alloc_unittest.cc b/base/allocator/partition_allocator/partition_alloc_unittest.cc index dee68b29ea30..540399da2d25 100644 --- a/base/allocator/partition_allocator/partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/partition_alloc_unittest.cc @@ -54,12 +54,12 @@ #endif #if BUILDFLAG(IS_POSIX) -#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) // We need PKEY_DISABLE_WRITE in this file; glibc defines it in sys/mman.h but // it's actually Linux-specific and other Linux libcs define it in linux/mman.h. // We have to include both to be sure we get the definition. #include -#endif // BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) +#endif // BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) #include #include #include diff --git a/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc b/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc index ff388e0c42fd..89b6493e6a6a 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc @@ -25,7 +25,7 @@ namespace allocator_shim::internal { #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) // Platforms on which we override weak libc symbols. -#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) PA_NOINLINE void FreeForTest(void* data) { free(data); @@ -85,7 +85,7 @@ TEST(PartitionAllocAsMalloc, Mallinfo) { #endif } -#endif // BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) diff --git a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc index cb1b689e1cae..26f6e688c5c4 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc +++ b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc @@ -393,14 +393,14 @@ TEST_F(AllocatorShimTest, InterceptLibcSymbols) { ASSERT_GE(aligned_allocs_intercepted_by_alignment[128], 1u); ASSERT_GE(aligned_allocs_intercepted_by_size[53], 1u); -#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_STARBOARD) void* pvalloc_ptr = pvalloc(67); ASSERT_NE(nullptr, pvalloc_ptr); ASSERT_EQ(0u, reinterpret_cast(pvalloc_ptr) % kPageSize); ASSERT_GE(aligned_allocs_intercepted_by_alignment[kPageSize], 1u); // pvalloc rounds the size up to the next page. ASSERT_GE(aligned_allocs_intercepted_by_size[kPageSize], 1u); -#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_STARBOARD) #endif // !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE) @@ -432,10 +432,10 @@ TEST_F(AllocatorShimTest, InterceptLibcSymbols) { free(memalign_ptr); ASSERT_GE(frees_intercepted_by_addr[Hash(memalign_ptr)], 1u); -#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_STARBOARD) free(pvalloc_ptr); ASSERT_GE(frees_intercepted_by_addr[Hash(pvalloc_ptr)], 1u); -#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !defined(IS_COBALT_HERMETIC_BUILD) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_STARBOARD) #endif // !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE) From 9601e0a360076c6ccaefa6e143366cbce0b4d6fe Mon Sep 17 00:00:00 2001 From: Yavor Goulishev Date: Mon, 24 Feb 2025 23:00:52 +0000 Subject: [PATCH 4/5] Use IS_STARBOARD for file. --- base/files/file_util_unittest.cc | 6 +++--- base/files/important_file_writer_cleaner.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc index 59bb6a9b045f..2ab60c3df627 100644 --- a/base/files/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -77,7 +77,7 @@ #include #endif -#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) #include #endif @@ -1912,7 +1912,7 @@ TEST_F(FileUtilTest, DeleteDirRecursiveWithOpenFile) { File::FLAG_CREATE | File::FLAG_READ | File::FLAG_WRITE); ASSERT_TRUE(PathExists(file_name3)); -#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) // On Windows, holding the file open in sufficient to make it un-deletable. // The POSIX code is verifiable on Linux by creating an "immutable" file but // this is best-effort because it's not supported by all file systems. Both @@ -1933,7 +1933,7 @@ TEST_F(FileUtilTest, DeleteDirRecursiveWithOpenFile) { DeletePathRecursively(test_subdir); EXPECT_FALSE(PathExists(file_name2)); -#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) // Make sure that the test can clean up after itself. if (file_attrs_supported) { flags &= ~FS_IMMUTABLE_FL; diff --git a/base/files/important_file_writer_cleaner.cc b/base/files/important_file_writer_cleaner.cc index adb1f3bdba6d..d3776a88a3b2 100644 --- a/base/files/important_file_writer_cleaner.cc +++ b/base/files/important_file_writer_cleaner.cc @@ -25,7 +25,7 @@ namespace base { namespace { base::Time GetUpperBoundTime() { -#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA) || defined(IS_COBALT_HERMETIC_BUILD) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_STARBOARD) // If process creation time is not available then use instance creation // time as the upper-bound for old files. Modification times may be // rounded-down to coarse-grained increments, e.g. FAT has 2s granularity, From 55017af952dfc6a7576d8ceec11f33d61795b147 Mon Sep 17 00:00:00 2001 From: Yavor Goulishev Date: Tue, 25 Feb 2025 00:22:09 +0000 Subject: [PATCH 5/5] Use IS_STARBOARD in memory_unittest --- base/process/memory_unittest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc index bbd1e231b1a7..e64abd179d40 100644 --- a/base/process/memory_unittest.cc +++ b/base/process/memory_unittest.cc @@ -367,7 +367,7 @@ TEST_F(OutOfMemoryDeathTest, SecurityAlignedRealloc) { #endif // BUILDFLAG(IS_WIN) #endif // !BUILDFLAG(IS_MAC) -#if BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) TEST_F(OutOfMemoryDeathTest, Valloc) { ASSERT_OOM_DEATH({ @@ -413,7 +413,7 @@ TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) { value_ = MallocWrapper(test_size_); }); } -#endif // BUILDFLAG(IS_LINUX) && !defined(IS_COBALT_HERMETIC_BUILD) || BUILDFLAG(IS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_STARBOARD) || BUILDFLAG(IS_CHROMEOS) // Android doesn't implement posix_memalign(). #if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)