aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/fuzz.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/fuzz/fuzz.h')
-rw-r--r--src/test/fuzz/fuzz.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/fuzz/fuzz.h b/src/test/fuzz/fuzz.h
index 2bad77bdc1..c91c33da67 100644
--- a/src/test/fuzz/fuzz.h
+++ b/src/test/fuzz/fuzz.h
@@ -11,6 +11,13 @@
#include <functional>
#include <string_view>
+/**
+ * Can be used to limit a theoretically unbounded loop. This caps the runtime
+ * to avoid timeouts or OOMs.
+ */
+#define LIMITED_WHILE(condition, limit) \
+ for (unsigned _count{limit}; (condition) && _count; --_count)
+
using FuzzBufferType = Span<const uint8_t>;
using TypeTestOneInput = std::function<void(FuzzBufferType)>;