#include "base/memory/platform_shared_memory_region.h"
#include <tuple>
#include "base/check.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/process/process_metrics.h"
#include "base/ranges/algorithm.h"
#include "base/system/sys_info.h"
#include "base/test/gtest_util.h"
#include "base/test/test_shared_memory_util.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_APPLE)
#include <mach/vm_map.h>
#include <sys/mman.h>
#elif BUILDFLAG(IS_POSIX)
#include <sys/mman.h>
#include "base/debug/proc_maps_linux.h"
#elif BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/logging.h"
#elif BUILDFLAG(IS_FUCHSIA)
#include <lib/zx/object.h>
#include <lib/zx/process.h>
#include "base/fuchsia/fuchsia_logging.h"
#endif
namespace base {
namespace subtle {
const size_t kRegionSize = …;
class PlatformSharedMemoryRegionTest : public ::testing::Test { … };
TEST_F(PlatformSharedMemoryRegionTest, DefaultConstructedRegionIsInvalid) { … }
TEST_F(PlatformSharedMemoryRegionTest, CreateRegionOfZeroSizeIsInvalid) { … }
TEST_F(PlatformSharedMemoryRegionTest, CreateTooLargeRegionIsInvalid) { … }
TEST_F(PlatformSharedMemoryRegionTest, CreateMaxSizeRegionIsInvalid) { … }
TEST_F(PlatformSharedMemoryRegionTest, ReportedSizeIsRequestedSize) { … }
TEST_F(PlatformSharedMemoryRegionTest, ConvertWritableToReadOnly) { … }
TEST_F(PlatformSharedMemoryRegionTest, ConvertWritableToUnsafe) { … }
TEST_F(PlatformSharedMemoryRegionTest, ReadOnlyHandleIsNotWritable) { … }
TEST_F(PlatformSharedMemoryRegionTest, InvalidAfterPass) { … }
TEST_F(PlatformSharedMemoryRegionTest, InvalidAfterMove) { … }
TEST_F(PlatformSharedMemoryRegionTest, TakeRegionOfZeroSizeIsInvalid) { … }
TEST_F(PlatformSharedMemoryRegionTest, TakeTooLargeRegionIsInvalid) { … }
TEST_F(PlatformSharedMemoryRegionTest, MapAtZeroBytesTest) { … }
TEST_F(PlatformSharedMemoryRegionTest, MapAtOutOfTheRegionLimitsTest) { … }
TEST_F(PlatformSharedMemoryRegionTest, MapAtWithOverflowTest) { … }
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_APPLE)
TEST_F(PlatformSharedMemoryRegionTest,
ConvertToReadOnlyInvalidatesSecondHandle) { … }
TEST_F(PlatformSharedMemoryRegionTest, ConvertToUnsafeInvalidatesSecondHandle) { … }
#endif
void CheckReadOnlyMapProtection(void* addr) { … }
bool TryToRestoreWritablePermissions(void* addr, size_t len) { … }
TEST_F(PlatformSharedMemoryRegionTest, MappingProtectionSetCorrectly) { … }
TEST_F(PlatformSharedMemoryRegionTest,
CheckPlatformHandlePermissionsCorrespondToMode) { … }
TEST_F(PlatformSharedMemoryRegionTest, CreateReadOnlyRegionDeathTest) { … }
TEST_F(PlatformSharedMemoryRegionTest, DuplicateWritableRegionDeathTest) { … }
TEST_F(PlatformSharedMemoryRegionTest, UnsafeRegionConvertToReadOnlyDeathTest) { … }
TEST_F(PlatformSharedMemoryRegionTest,
ReadOnlyRegionConvertToReadOnlyDeathTest) { … }
TEST_F(PlatformSharedMemoryRegionTest, ReadOnlyRegionConvertToUnsafeDeathTest) { … }
TEST_F(PlatformSharedMemoryRegionTest, UnsafeRegionConvertToUnsafeDeathTest) { … }
}
}