aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-05-22 16:53:18 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-05-22 16:56:58 +0200
commit217b416c727aaaaad939203b845a96fd638ded1e (patch)
tree9795a4a2f9c5c547daec92baeb3bf9198c2df8aa /src/test
parent65129138304771f2734400e2d7a24e8960dfafef (diff)
parent693247b82bbccada37f7bc61380ddac799100eb8 (diff)
Merge #10415: [tests] Speed up fuzzing by ~200x when using afl-fuzz
693247b [test] Speed up fuzzing by ~200x when using afl-fuzz (practicalswift) Tree-SHA512: 95922fc2616b8cb00dd531ed1140a52bbda4e04292dd8c1c60a8f49dbf6ccb797a18b61180b3fb68d695456b478a1f5ae7fda47e8ecee41dd65555487aef40a3
Diffstat (limited to 'src/test')
-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
+}