aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_bitcoin_fuzzy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_bitcoin_fuzzy.cpp')
-rw-r--r--src/test/test_bitcoin_fuzzy.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/test/test_bitcoin_fuzzy.cpp b/src/test/test_bitcoin_fuzzy.cpp
index c4983f6f5c..e11e46bb02 100644
--- a/src/test/test_bitcoin_fuzzy.cpp
+++ b/src/test/test_bitcoin_fuzzy.cpp
@@ -59,9 +59,8 @@ bool read_stdin(std::vector<char> &data) {
return length==0;
}
-int main(int argc, char **argv)
+int do_fuzz()
{
- ECCVerifyHandle globalVerifyHandle;
std::vector<char> buffer;
if (!read_stdin(buffer)) return 0;
@@ -256,3 +255,23 @@ int main(int argc, char **argv)
return 0;
}
+int main(int argc, char **argv)
+{
+ ECCVerifyHandle globalVerifyHandle;
+#ifdef __AFL_INIT
+ // Enable AFL deferred forkserver mode. Requires compilation using
+ // afl-clang-fast++. See fuzzing.md for details.
+ __AFL_INIT();
+#endif
+
+#ifdef __AFL_LOOP
+ // Enable AFL persistent mode. Requires compilation using afl-clang-fast++.
+ // See fuzzing.md for details.
+ while (__AFL_LOOP(1000)) {
+ do_fuzz();
+ }
+ return 0;
+#else
+ return do_fuzz();
+#endif
+}