minor
This commit is contained in:
parent
449162b1b8
commit
6992d6819c
|
@ -1,6 +1,6 @@
|
|||
# WARNING: This benchmark does not run a complete fuzzing iteration, just the mutator.
|
||||
# As such it doesn't account for LibFuzzer's overhead or the efficiency of the cache.
|
||||
# Compile with: nim c -d:danger bench_graph.nim
|
||||
# Compile with: nim c --mm:arc -d:danger bench_graph.nim
|
||||
# Then run: perf record -e cycles:pp --call-graph dwarf ./bench_graph
|
||||
include examples/fuzz_graph
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--cc: clang
|
||||
--define: useMalloc
|
||||
--passC: "-fsanitize=address,undefined"
|
||||
--passL: "-fsanitize=address,undefined"
|
||||
#--passC: "-fsanitize=address,undefined"
|
||||
#--passL: "-fsanitize=address,undefined"
|
||||
#--define: release
|
||||
--debugger: native
|
||||
--path: "../"
|
||||
|
|
|
@ -8,7 +8,7 @@ when (NimMajor, NimMinor, NimPatch) < (1, 7, 1):
|
|||
elif T is bool:
|
||||
result = cast[int64](r.next) < 0
|
||||
else:
|
||||
result = cast[T](r.next shr (sizeof(uint64)*8 - sizeof(T)*8))
|
||||
result = cast[T](r.next shr (sizeof(uint64) - sizeof(T))*8)
|
||||
|
||||
when not defined(fuzzerStandalone):
|
||||
proc LLVMFuzzerInitialize(): cint {.exportc.} =
|
||||
|
@ -118,7 +118,7 @@ when defined(fuzzerStandalone):
|
|||
else:
|
||||
flipBit(cast[ptr UncheckedArray[uint8]](addr result[0]), result.len, r)
|
||||
|
||||
proc mutateByteSizedSeq*[T: ByteSized and not range](value: sink seq[T]; userMax, sizeIncreaseHint: int;
|
||||
proc mutateByteSizedSeq*[T: ByteSized](value: sink seq[T]; userMax, sizeIncreaseHint: int;
|
||||
r: var Rand): seq[T] =
|
||||
result = value
|
||||
while result.len != 0 and r.rand(bool):
|
||||
|
@ -139,7 +139,7 @@ when defined(fuzzerStandalone):
|
|||
elif T is range:
|
||||
for i in 0..<result.len: result[i] = clamp(result[i], low(T), high(T))
|
||||
else:
|
||||
proc mutateByteSizedSeq*[T: ByteSized and not range](value: sink seq[T]; userMax, sizeIncreaseHint: int;
|
||||
proc mutateByteSizedSeq*[T: ByteSized](value: sink seq[T]; userMax, sizeIncreaseHint: int;
|
||||
r: var Rand): seq[T] =
|
||||
if r.rand(0..20) == 0:
|
||||
result = @[]
|
||||
|
@ -590,8 +590,7 @@ template mutatorImpl(target, mutator, typ: untyped) =
|
|||
testOneInputImpl(x, toOpenArray(data, 0, len-1))
|
||||
|
||||
proc LLVMFuzzerCustomMutator(data: ptr UncheckedArray[byte], len, maxLen: int,
|
||||
seed: int64): int {.
|
||||
exportc.} =
|
||||
seed: int64): int {.exportc.} =
|
||||
var r = initRand(seed)
|
||||
var x: typ
|
||||
customMutatorImpl(x, toOpenArray(data, 0, len-1), maxLen, r)
|
||||
|
|
Loading…
Reference in New Issue