Skip to content

Commit 9cfc0fc

Browse files
committed
fuzz: add contrib/test.sh so we at least 'cargo test' it in CI
1 parent 933ecb1 commit 9cfc0fc

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

contrib/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ex
44

5-
CRATES="bitcoin hashes internals"
5+
CRATES="bitcoin hashes internals fuzz"
66

77
for crate in ${CRATES}
88
do

fuzz/contrib/test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
FEATURES=""
6+
7+
cargo --version
8+
rustc --version
9+
10+
# Make all cargo invocations verbose
11+
export CARGO_TERM_VERBOSE=true
12+
13+
# Pin dependencies as required if we are using MSRV toolchain.
14+
if cargo --version | grep "1\.41"; then
15+
# 1.0.157 uses syn 2.0 which requires edition 2021
16+
cargo update -p serde --precise 1.0.156
17+
# 1.0.108 uses `matches!` macro so does not work with Rust 1.41.1, bad `syn` no biscuit.
18+
cargo update -p syn --precise 1.0.107
19+
# Half 1.8 uses edition 2021 features
20+
cargo update -p half --precise 1.7.1
21+
fi
22+
23+
if [ "$DO_LINT" = true ]
24+
then
25+
cargo clippy --all-features --all-targets -- -D warnings
26+
fi
27+
28+
# Defaults / sanity checks
29+
cargo build
30+
cargo test
31+
32+
# Address Sanitizer
33+
if [ "$DO_ASAN" = true ]; then
34+
cargo clean
35+
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
36+
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
37+
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
38+
cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
39+
cargo clean
40+
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
41+
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
42+
cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
43+
fi
44+

0 commit comments

Comments
 (0)