From 1148f773d1b5a264d7202f9d1d39c90419617e89 Mon Sep 17 00:00:00 2001 From: kdeme Date: Mon, 30 Sep 2019 15:34:11 +0200 Subject: [PATCH] rename to fuzztest & change standalone define --- tests/fuzzing/discovery/fuzz.nim | 2 +- tests/fuzzing/{fuzz_helpers.nim => fuzztest.nim} | 6 +++--- tests/fuzzing/rlp/fuzz.nim | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename tests/fuzzing/{fuzz_helpers.nim => fuzztest.nim} (93%) diff --git a/tests/fuzzing/discovery/fuzz.nim b/tests/fuzzing/discovery/fuzz.nim index ba45379..2ff232c 100644 --- a/tests/fuzzing/discovery/fuzz.nim +++ b/tests/fuzzing/discovery/fuzz.nim @@ -1,6 +1,6 @@ import chronicles, eth/p2p/[discovery, enode], eth/[keys, rlp], - ../../p2p/p2p_test_helper, ../fuzz_helpers + ../../p2p/p2p_test_helper, ../fuzztest const DefaultListeningPort = 30303 var targetNode: DiscoveryProtocol diff --git a/tests/fuzzing/fuzz_helpers.nim b/tests/fuzzing/fuzztest.nim similarity index 93% rename from tests/fuzzing/fuzz_helpers.nim rename to tests/fuzzing/fuzztest.nim index c6ac227..a0f2ba4 100644 --- a/tests/fuzzing/fuzz_helpers.nim +++ b/tests/fuzzing/fuzztest.nim @@ -3,7 +3,7 @@ import streams, posix, strutils, chronicles, macros template fuzz(body) = # For code we want to fuzz, SIGSEGV is needed on unwanted exceptions. # However, this is only needed when fuzzing with afl. - when defined(afl): + when defined(standalone): try: body except Exception as e: @@ -31,7 +31,7 @@ template `+`*[T](p: ptr T, off: int): ptr T = cast[ptr type(p[])](cast[ByteAddress](p) +% off * sizeof(p[])) template test*(body: untyped): untyped = - when defined(afl): + when defined(standalone): var payload {.inject.} = readStdin() fuzz: `body` @@ -48,7 +48,7 @@ template test*(body: untyped): untyped = `body` template init*(body: untyped): untyped = - when defined(afl): + when defined(standalone): fuzz: `body` else: proc fuzzerInit(): cint {.exportc: "LLVMFuzzerInitialize".} = diff --git a/tests/fuzzing/rlp/fuzz.nim b/tests/fuzzing/rlp/fuzz.nim index 861dcf3..64788f7 100644 --- a/tests/fuzzing/rlp/fuzz.nim +++ b/tests/fuzzing/rlp/fuzz.nim @@ -1,4 +1,4 @@ -import chronicles, eth/rlp, ../fuzz_helpers +import chronicles, eth/rlp, ../fuzztest # TODO: have a default init as such init: