fuzz: Use std::span in FuzzBufferType

This commit is contained in:
MarcoFalke 2024-06-05 14:52:26 +02:00
parent 5ee6b76c69
commit faa41e29d5
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View File

@ -12,8 +12,8 @@
namespace { namespace {
/** Pop the first byte from a Span<const uint8_t>, and return it. */ /** Pop the first byte from a byte-span, and return it. */
uint8_t ReadByte(Span<const uint8_t>& buffer) uint8_t ReadByte(FuzzBufferType& buffer)
{ {
if (buffer.empty()) return 0; if (buffer.empty()) return 0;
uint8_t ret = buffer.front(); uint8_t ret = buffer.front();
@ -23,7 +23,7 @@ uint8_t ReadByte(Span<const uint8_t>& buffer)
/** Perform a simulation fuzz test on BitSet type S. */ /** Perform a simulation fuzz test on BitSet type S. */
template<typename S> template<typename S>
void TestType(Span<const uint8_t> buffer) void TestType(FuzzBufferType buffer)
{ {
/** This fuzz test's design is based on the assumption that the actual bits stored in the /** This fuzz test's design is based on the assumption that the actual bits stored in the
* bitsets and their simulations do not matter for the purpose of detecting edge cases, thus * bitsets and their simulations do not matter for the purpose of detecting edge cases, thus

View File

@ -5,10 +5,9 @@
#ifndef BITCOIN_TEST_FUZZ_FUZZ_H #ifndef BITCOIN_TEST_FUZZ_FUZZ_H
#define BITCOIN_TEST_FUZZ_FUZZ_H #define BITCOIN_TEST_FUZZ_FUZZ_H
#include <span.h>
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <span>
#include <string_view> #include <string_view>
/** /**
@ -23,7 +22,7 @@
#define LIMITED_WHILE(condition, limit) \ #define LIMITED_WHILE(condition, limit) \
for (unsigned _count{limit}; (condition) && _count; --_count) for (unsigned _count{limit}; (condition) && _count; --_count)
using FuzzBufferType = Span<const uint8_t>; using FuzzBufferType = std::span<const uint8_t>;
using TypeTestOneInput = std::function<void(FuzzBufferType)>; using TypeTestOneInput = std::function<void(FuzzBufferType)>;
struct FuzzTargetOptions { struct FuzzTargetOptions {