forked from OffchainLabs/nitro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuzz.bash
executable file
·84 lines (77 loc) · 2.01 KB
/
fuzz.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
set -e
mydir=`dirname $0`
cd "$mydir"
function printusage {
echo Usage: $0 --build \[--binary-path PATH\]
echo " " $0 \<fuzzer-name\> \[--binary-path PATH\] \[--fuzzcache-path PATH\]
echo
echo fuzzer names:
echo " " FuzzPrecompiles
echo " " FuzzInboxMultiplexer
echo " " FuzzStateTransition
}
if [[ $# -eq 0 ]]; then
printusage
exit
fi
fuzz_executable=./target/bin/system_test.fuzz
binpath=./target/bin/
fuzzcachepath=./target/var/fuzz-cache
run_build=false
test_group=""
while [[ $# -gt 0 ]]; do
case $1 in
--binary-path)
binpath="$2"/
if [[ ! -d "$binpath" ]]; then
echo must supply valid path for binary-path
exit 1
fi
shift
shift
;;
--fuzzcache-path)
fuzzcachepath="$2"
if [[ ! -d "$binpath" ]]; then
echo must supply valid path for fuzzcache-path
exit 1
fi
shift
shift
;;
--build)
run_build=true
shift
;;
FuzzPrecompiles | FuzzStateTransition)
if [[ ! -z "$test_name" ]]; then
echo can only run one fuzzer at a time
exit 1
fi
test_group=system_tests
test_name=$1
shift
;;
FuzzInboxMultiplexer)
if [[ ! -z "$test_name" ]]; then
echo can only run one fuzzer at a time
exit 1
fi
test_group=arbstate
test_name=$1
shift
;;
*)
printusage
exit
esac
done
if $run_build; then
for build_group in system_tests arbstate; do
go test -c ./$build_group -fuzz Fuzz -o "$binpath"/${build_group}.fuzz
done
fi
if [[ ! -z $test_group ]]; then
"$binpath"/${test_group}.fuzz -test.run "^$" -test.fuzzcachedir "$fuzzcachepath" -test.fuzz $test_name
fi