C/C++ API Reference
Loading...
Searching...
No Matches

Oveview

Functions

fuzzer::Domain< Request > pw::allocator::test::ArbitraryRequest (size_t max_size)
 
template<size_t kMaxRequests, size_t kMaxSize>
auto pw::allocator::test::ArbitraryRequests ()
 
template<size_t kIndex, typename... Args>
Request pw::allocator::test::MakeRequest (Args... args)
 
auto pw::allocator::test::DefaultArbitraryRequests ()
 

Variables

constexpr size_t pw::allocator::test::kMaxRequests = 256
 
constexpr size_t pw::allocator::test::kMaxSize = 2048
 

Function Documentation

◆ ArbitraryRequest()

fuzzer::Domain< Request > pw::allocator::test::ArbitraryRequest ( size_t  max_size)

Returns a FuzzTest domain for producing arbitrary allocator requests.

This method integrates with FuzzTest to use code coverage to produce guided mutations.

See https://github.com/google/fuzztest/blob/main/doc/domains-reference.md

Parameters
max_sizeSize of the largest allocation that can be requested.

◆ ArbitraryRequests()

template<size_t kMaxRequests, size_t kMaxSize>
auto pw::allocator::test::ArbitraryRequests ( )

Returns a FuzzTest domain for producing sequences of arbitrary allocator requests.

This method can be used to drive an AllocatorTestHarness as part of a fuzz test.

See https://github.com/google/fuzztest/blob/main/doc/domains-reference.md

Parameters
max_sizeSize of the largest allocation that can be requested.

◆ MakeRequest()

template<size_t kIndex, typename... Args>
Request pw::allocator::test::MakeRequest ( Args...  args)

Builds an Request from an index and values.

Unfortunately, the reproducer emitted by FuzzTest for vectors of Requests cannot simply be copied and pasted. To create a reproducer, create a pw::Vector of the appropriate size, and populate it using this method with the correct index.

For example, consider the following sample output:

The test fails with input:
argument 0: {(index=0, value={0, 1}), (index=0, value={1209, 8}),
(index=2, value={9223372036854775807, 2048})}
=================================================================
=== Reproducer test
TEST(MyAllocatorFuzzTest, NeverCrashesU16Regression) {
NeverCrashes(
{{0, 1}, {1209, 8}, {9223372036854775807, 2048},
);
}

A valid reproducer might be:

TEST(MyAllocatorFuzzTest, NeverCrashesU16Regression) {
test::MakeRequest<0>(0u, 1u),
test::MakeRequest<0>(1209u, 8u),
test::MakeRequest<2>(9223372036854775807u, 2048u),
});
NeverCrashes(input);
// }
Definition: vector.h:65