//===-- primary_test.cpp ----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "tests/scudo_unit_test.h" #include "primary32.h" #include "primary64.h" #include "size_class_map.h" #include #include #include #include #include #include #include #include // Note that with small enough regions, the SizeClassAllocator64 also works on // 32-bit architectures. It's not something we want to encourage, but we still // should ensure the tests pass. template struct TestConfig1 { static const bool MaySupportMemoryTagging = false; struct Primary { using SizeClassMap = SizeClassMapT; static const scudo::uptr RegionSizeLog = 18U; static const scudo::uptr GroupSizeLog = 18U; static const scudo::s32 MinReleaseToOsIntervalMs = INT32_MIN; static const scudo::s32 MaxReleaseToOsIntervalMs = INT32_MAX; typedef scudo::uptr CompactPtrT; static const scudo::uptr CompactPtrScale = 0; static const bool EnableRandomOffset = true; static const scudo::uptr MapSizeIncrement = 1UL << 18; }; }; template struct TestConfig2 { static const bool MaySupportMemoryTagging = false; struct Primary { using SizeClassMap = SizeClassMapT; #if defined(__mips__) // Unable to allocate greater size on QEMU-user. static const scudo::uptr RegionSizeLog = 23U; #else static const scudo::uptr RegionSizeLog = 24U; #endif static const scudo::uptr GroupSizeLog = 20U; static const scudo::s32 MinReleaseToOsIntervalMs = INT32_MIN; static const scudo::s32 MaxReleaseToOsIntervalMs = INT32_MAX; typedef scudo::uptr CompactPtrT; static const scudo::uptr CompactPtrScale = 0; static const bool EnableRandomOffset = true; static const scudo::uptr MapSizeIncrement = 1UL << 18; }; }; template struct TestConfig3 { static const bool MaySupportMemoryTagging = true; struct Primary { using SizeClassMap = SizeClassMapT; #if defined(__mips__) // Unable to allocate greater size on QEMU-user. static const scudo::uptr RegionSizeLog = 23U; #else static const scudo::uptr RegionSizeLog = 24U; #endif static const scudo::uptr GroupSizeLog = 20U; static const scudo::s32 MinReleaseToOsIntervalMs = INT32_MIN; static const scudo::s32 MaxReleaseToOsIntervalMs = INT32_MAX; typedef scudo::uptr CompactPtrT; static const scudo::uptr CompactPtrScale = 0; static const bool EnableRandomOffset = true; static const scudo::uptr MapSizeIncrement = 1UL << 18; }; }; template struct TestConfig4 { static const bool MaySupportMemoryTagging = true; struct Primary { using SizeClassMap = SizeClassMapT; #if defined(__mips__) // Unable to allocate greater size on QEMU-user. static const scudo::uptr RegionSizeLog = 23U; #else static const scudo::uptr RegionSizeLog = 24U; #endif static const scudo::s32 MinReleaseToOsIntervalMs = INT32_MIN; static const scudo::s32 MaxReleaseToOsIntervalMs = INT32_MAX; static const scudo::uptr CompactPtrScale = 3U; static const scudo::uptr GroupSizeLog = 20U; typedef scudo::u32 CompactPtrT; static const bool EnableRandomOffset = true; static const scudo::uptr MapSizeIncrement = 1UL << 18; }; }; template