From 4b154e56c74137306c884e116b2b8a40638fcfc2 Mon Sep 17 00:00:00 2001 From: kdeme Date: Wed, 9 Oct 2019 21:23:22 +0200 Subject: [PATCH] Fix aflLoop for non afl-clang-fast --- tests/fuzzing/fuzztest.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/fuzzing/fuzztest.nim b/tests/fuzzing/fuzztest.nim index 7e4c557..847a13d 100644 --- a/tests/fuzzing/fuzztest.nim +++ b/tests/fuzzing/fuzztest.nim @@ -88,7 +88,10 @@ when defined(clangfast): ## Test case should be able to handle repeated inputs. No repeated fork() will ## be done. # TODO: Lets use this in the test block when afl-clang-fast is used? - proc aflLoop*(count: cuint): cint {.importc: "__AFL_LOOP", noDecl.} + proc aflLoopImpl(count: cuint): cint {.importc: "__AFL_LOOP", noDecl.} + template aflLoop*(body: untyped): untyped = + while aflLoopImpl(1000) != 0: + `body` else: proc aflInit*() = discard - proc aflLoop*(count: cuint): cint = 0 + template aflLoop*(body: untyped): untyped = `body`