diff --git a/.gitignore b/.gitignore index 800ae845..e8a5296c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ setup.* .ignore _opam *.exe +fuzz-*-input +fuzz-*-output diff --git a/fuzz/ccsexp_parse_string_does_not_crash.ml b/fuzz/ccsexp_parse_string_does_not_crash.ml new file mode 100644 index 00000000..358968c2 --- /dev/null +++ b/fuzz/ccsexp_parse_string_does_not_crash.ml @@ -0,0 +1,3 @@ +let () = + Crowbar.add_test ~name:"ccsexp_parse_string_does_not_crash" [ Crowbar.bytes ] + (fun s -> CCSexp.parse_string s |> ignore) diff --git a/fuzz/dune b/fuzz/dune new file mode 100644 index 00000000..dc5d9758 --- /dev/null +++ b/fuzz/dune @@ -0,0 +1,8 @@ +(executables + (flags (-w "+a-4-9-29-37-40-42-44-48-50-32" -g)) + (names ccsexp_parse_string_does_not_crash + ) + (libraries crowbar + containers + ) +) diff --git a/fuzz/list.sh b/fuzz/list.sh new file mode 100755 index 00000000..eafc9162 --- /dev/null +++ b/fuzz/list.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +script_dir=$(dirname $(readlink -f "$0")) + +echo "Building" + +dune build @all + +echo "" + +echo "Fuzzing tests available:" + +for file in "$script_dir"/../_build/default/fuzz/*.exe; do + echo "- "$(basename $file | sed 's/\.exe$//') +done diff --git a/fuzz/run.sh b/fuzz/run.sh new file mode 100755 index 00000000..967e34d8 --- /dev/null +++ b/fuzz/run.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +script_dir=$(dirname $(readlink -f "$0")) + +echo "Building" + +dune build @all + +if [[ "$1" == "" ]]; then + echo "Please enter a fuzzing test to run" + exit 1 +fi + +name=$(echo "$1" | sed 's/\.exe$//') + +echo "Creating input directory" + +input_dir="fuzz-""$name""-input" + +output_dir="fuzz-""$name""-output" + +mkdir -p "$input_dir" + +echo "abcd" > "$input_dir"/dummy + +mkdir -p "$output_dir" + +afl-fuzz -t 1000 -i "$input_dir" -o "$output_dir" "$script_dir"/../_build/default/fuzz/"$name".exe @@