Upgrade rust-bitcoin to 0.31
[rust-lightning] / fuzz / ci-fuzz.sh
1 #!/bin/bash
2 set -e
3 set -x
4
5 pushd src/msg_targets
6 rm msg_*.rs
7 ./gen_target.sh
8 [ "$(git diff)" != "" ] && exit 1
9 popd
10 pushd src/bin
11 rm *_target.rs
12 ./gen_target.sh
13 [ "$(git diff)" != "" ] && exit 1
14 popd
15
16 cargo install --color always --force honggfuzz --no-default-features
17 sed -i 's/lto = true//' Cargo.toml
18
19 export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz"
20 export HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz"
21
22 cargo --color always hfuzz build
23 for TARGET in src/bin/*.rs; do
24         FILENAME=$(basename $TARGET)
25         FILE="${FILENAME%.*}"
26         HFUZZ_RUN_ARGS="--exit_upon_crash -v -n2"
27         if [ "$FILE" = "chanmon_consistency_target" ]; then
28                 HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -F 64 -N100000"
29         elif [ "$FILE" = "full_stack_target" ]; then
30                 HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -t0 -N1000000"
31         else
32                 HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N1000000"
33         fi
34         export HFUZZ_RUN_ARGS
35         cargo --color always hfuzz run $FILE
36         if [ -f hfuzz_workspace/$FILE/HONGGFUZZ.REPORT.TXT ]; then
37                 cat hfuzz_workspace/$FILE/HONGGFUZZ.REPORT.TXT
38                 for CASE in hfuzz_workspace/$FILE/SIG*; do
39                         cat $CASE | xxd -p
40                 done
41                 exit 1
42         fi
43 done