Test utilities for allocator implementers.
These facilitate writing unit tests and fuzz tests for both concrete and forwarding allocator implementations. They are not intended to be used by module consumers.
Submodules | |
| FuzzTest support | |
Classes | |
| class | pw::allocator::test::FaultInjectingAllocator |
| struct | pw::allocator::test::AllocationRequest |
| Represents a request to allocate some memory. More... | |
| struct | pw::allocator::test::DeallocationRequest |
| Represents a request to free some allocated memory. More... | |
| struct | pw::allocator::test::ReallocationRequest |
| Represents a request to reallocate allocated memory with a new size. More... | |
| class | pw::allocator::test::TestHarness |
| class | pw::allocator::test::AllocatorForTest< kBufferSize, BlockType_, MetricsType_ > |
| A configurable allocator that can be used in unit tests. More... | |
Macros | |
| #define | PW_ALLOCATOR_FIA_FOREACH(fn) |
| Applies the given macro to each pair of names. | |
| #define | PW_ALLOCATOR_ABSORB_SEMICOLON() static_assert(true) |
| #define | PW_ALLOCATOR_FIA_ACCESSOR(snake, Camel) |
| #define | PW_ALLOCATOR_FIA_SET_TRUE(snake, Camel) can_##snake##_ = true |
| #define | PW_ALLOCATOR_FIA_SET_FALSE(snake, Camel) can_##snake##_ = false |
| #define | PW_ALLOCATOR_FIA_ENABLE(snake, Camel) |
| #define | PW_ALLOCATOR_FIA_DISABLE(snake, Camel) |
| #define | PW_ALLOCATOR_FIA_FIELD(snake, Camel) bool PW_ALLOCATOR_FIA_SET_TRUE(snake, Camel) |
Typedefs | |
| using | pw::allocator::test::Request = std::variant< AllocationRequest, DeallocationRequest, ReallocationRequest > |
Functions | |
| size_t | pw::allocator::test::AlignmentFromLShift (size_t lshift, size_t size) |
| template<typename BlockType > | |
| void | pw::allocator::test::FreeAll (typename BlockType::Range range) |
| Free all the blocks reachable by the given block. Useful for test cleanup. | |
Variables | |
| constexpr pw::tokenizer::Token | pw::allocator::test::kToken = PW_TOKENIZE_STRING("test") |
| #define PW_ALLOCATOR_FIA_ACCESSOR | ( | snake, | |
| Camel | |||
| ) |
For a name pair like (foo_bar, FooBar), creates an accessor like: [[nodiscard]] constexpr bool can_foo_bar() const { return can_foo_bar_; }
| #define PW_ALLOCATOR_FIA_DISABLE | ( | snake, | |
| Camel | |||
| ) |
For a name pair like (foo_bar, FooBar), creates a method like void DisableFooBar() { can_foo_bar_ = false; }
| #define PW_ALLOCATOR_FIA_ENABLE | ( | snake, | |
| Camel | |||
| ) |
For a name pair like (foo_bar, FooBar), creates a method like void EnableFooBar() { can_foo_bar_ = true; }
| #define PW_ALLOCATOR_FIA_FIELD | ( | snake, | |
| Camel | |||
| ) | bool PW_ALLOCATOR_FIA_SET_TRUE(snake, Camel) |
For a name pair like (foo_bar, FooBar), creates a field like bool can_foo_bar_ = true
| #define PW_ALLOCATOR_FIA_FOREACH | ( | fn | ) |
Applies the given macro to each pair of names.
| #define PW_ALLOCATOR_FIA_SET_FALSE | ( | snake, | |
| Camel | |||
| ) | can_##snake##_ = false |
For a name pair like (foo_bar, FooBar) and a boolean value, creates statement like can_foo_bar_ = false
| #define PW_ALLOCATOR_FIA_SET_TRUE | ( | snake, | |
| Camel | |||
| ) | can_##snake##_ = true |
For a name pair like (foo_bar, FooBar) and a boolean value, creates statement like can_foo_bar_ = true;
| size_t pw::allocator::test::AlignmentFromLShift | ( | size_t | lshift, |
| size_t | size | ||
| ) |
Helper function to produce a valid alignment for a given size from an arbitrary left shift amount.