forked from rust-fuzz/honggfuzz-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·56 lines (44 loc) · 1.46 KB
/
test.sh
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
#!/bin/sh -vex
export RUST_BACKTRACE=full
git submodule update --init --recursive
cargo uninstall honggfuzz 2>/dev/null || true
cargo clean
cargo update
# build and set command env var
version=`rustc --version`
if [ -n "${version##*1.47*}" ] ;then
cargo build --release --verbose
else
cargo build --release --verbose --no-default-features
fi
export CARGO_HFUZZ="$(pwd)/target/release/cargo-hfuzz hfuzz" # force examples' tests to use this version
$CARGO_HFUZZ version # record version for logs
cd example
if [ -n "${version##*1.47*}" ] ;then
# run test.sh without sanitizers with the `arbitrary` crate
HFUZZ_BUILD_ARGS="--features arbitrary" ./test.sh
fi
# run test.sh without sanitizers without the `arbitrary` crate
HFUZZ_BUILD_ARGS="--no-default-features" RUSTFLAGS="" ./test.sh
# run test.sh with sanitizers only on nightly
if [ -z "${version##*nightly*}" ] ;then
if [ "`uname`" = "Linux" ] ;then
RUSTFLAGS="-Z sanitizer=address" ./test.sh # not working on macos
RUSTFLAGS="-Z sanitizer=thread" ./test.sh # not working on macos
RUSTFLAGS="-Z sanitizer=leak" ./test.sh # the leak sanitizer is only available on Linux
fi
# RUSTFLAGS="-Z sanitizer=memory" ./test.sh # not working, see: https://github.com/rust-lang/rust/issues/39610
fi
# go back to root crate
cd ..
if [ -n "${version##*1.47*}" ] ;then
# try to generate doc
cargo doc
# run unit tests
cargo test
else
cargo doc --no-default-features
# run unit tests
cargo test --no-default-features
fi
cargo clean