|
Pigweed
|
#include <test_harness.h>
Classes | |
| struct | Allocation |
Associates a pointer to memory with the Layout used to allocate it. More... | |
Public Member Functions | |
| virtual | ~TestHarnessGeneric ()=default |
| void | GenerateRequests (random::RandomGenerator &prng, size_t max_size, size_t num_requests) |
| void | GenerateRequest (random::RandomGenerator &prng, size_t max_size) |
| void | HandleRequests (const Vector< Request > &requests) |
| void | HandleRequest (const Request &request) |
| void | Reset () |
| Deallocates any pointers stored in the vector of allocated pointers. | |
Protected Member Functions | |
| constexpr | TestHarnessGeneric (Vector< Allocation > &allocations) |
Associates an Allocator with a vector to store allocated pointers.
This class facilitates performing allocations from generated Requests, enabling the creation of performance, stress, and fuzz tests for various allocators.
This class lacks a public constructor, and so cannot be used directly. Instead callers should use WithAllocations, which is templated on the size of the vector used to store allocated pointers.
|
virtualdefault |
Since this object has references passed to it that are typically owned by an object of a derived type, the destructor MUST NOT touch those references. Instead, it is the callers and/or the derived classes responsibility to call Reset before the object is destroyed, if desired.
| void pw::allocator::test::TestHarnessGeneric::GenerateRequest | ( | random::RandomGenerator & | prng, |
| size_t | max_size | ||
| ) |
Generate and handle an allocation requests.
This method will use the given PRNG to generate an allocation request and pass it to HandleRequest. Callers MUST call Reset when no more requests remain to be generated.
| void pw::allocator::test::TestHarnessGeneric::GenerateRequests | ( | random::RandomGenerator & | prng, |
| size_t | max_size, | ||
| size_t | num_requests | ||
| ) |
Generates and handles a sequence of allocation requests.
This method will use the given PRNG to generate num_requests allocation requests and pass each in turn to HandleRequest. It will call Reset before returning.
| void pw::allocator::test::TestHarnessGeneric::HandleRequest | ( | const Request & | request | ) |
Handles an allocator request.
This method is stateful, and modifies the vector of allocated pointers. It will call Init if it has not yet been called.
If the request is an allocation request:
If the request is a deallocation request:
If the request is a reallocation request:
nullptr.| void pw::allocator::test::TestHarnessGeneric::HandleRequests | ( | const Vector< Request > & | requests | ) |
Handles a sequence of allocation requests.
This method is useful for processing externally generated requests, e.g. from FuzzTest. It will call Reset before returning.