2020-11-10 23:36:07 +00:00
|
|
|
#!/bin/sh -ex
|
|
|
|
|
|
|
|
FEATURES="bitcoin_hashes endomorphism global-context lowmemory rand rand-std recovery serde"
|
|
|
|
|
|
|
|
# Use toolchain if explicitly specified
|
|
|
|
if [ -n "$TOOLCHAIN" ]
|
|
|
|
then
|
|
|
|
alias cargo="cargo +$TOOLCHAIN"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cargo --version
|
|
|
|
rustc --version
|
|
|
|
|
2020-12-18 12:08:52 +00:00
|
|
|
# Make all cargo invocations verbose
|
|
|
|
export CARGO_TERM_VERBOSE=true
|
|
|
|
|
2020-11-10 23:36:07 +00:00
|
|
|
# Defaults / sanity checks
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo build --all
|
|
|
|
cargo test --all
|
2020-11-10 23:36:07 +00:00
|
|
|
|
|
|
|
if [ "$DO_FEATURE_MATRIX" = true ]; then
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo build --all --no-default-features
|
2020-11-10 23:36:07 +00:00
|
|
|
#This doesn't work but probably should --andrew
|
2020-12-18 12:08:52 +00:00
|
|
|
#cargo test --all --no-default-features
|
2020-11-10 23:36:07 +00:00
|
|
|
|
|
|
|
# All features
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo build --all --no-default-features --features="$FEATURES"
|
|
|
|
cargo test --all --features="$FEATURES"
|
2020-11-10 23:36:07 +00:00
|
|
|
# Single features
|
|
|
|
for feature in ${FEATURES}
|
|
|
|
do
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo build --all --no-default-features --features="$feature"
|
|
|
|
cargo test --all --features="$feature"
|
2020-11-10 23:36:07 +00:00
|
|
|
done
|
|
|
|
|
2020-12-23 18:00:34 +00:00
|
|
|
# Other combos
|
|
|
|
RUSTFLAGS='--cfg=rust_secp_fuzz' cargo test --all
|
|
|
|
RUSTFLAGS='--cfg=rust_secp_fuzz' cargo test --all --features="$FEATURES"
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo test --all --features="rand rand-std"
|
|
|
|
cargo test --all --features="rand serde"
|
2020-11-10 23:36:07 +00:00
|
|
|
|
2020-12-23 18:00:34 +00:00
|
|
|
if [ "$DO_BENCH" = true ]; then # proxy for us having a nightly compiler
|
|
|
|
cargo test --all --all-features
|
|
|
|
RUSTFLAGS='--cfg=rust_secp_fuzz' RUSTDOCFLAGS='--cfg=rust_secp_fuzz' cargo test --all --all-features
|
|
|
|
fi
|
|
|
|
|
2020-11-10 23:36:07 +00:00
|
|
|
# Examples
|
|
|
|
cargo run --example sign_verify
|
|
|
|
cargo run --example sign_verify_recovery --features=recovery
|
|
|
|
cargo run --example generate_keys --features=rand
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Docs
|
|
|
|
if [ "$DO_DOCS" = true ]; then
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo doc --all --features="$FEATURES"
|
2020-11-10 23:36:07 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Webassembly stuff
|
|
|
|
if [ "$DO_WASM" = true ]; then
|
|
|
|
clang --version &&
|
2020-12-18 12:08:52 +00:00
|
|
|
CARGO_TARGET_DIR=wasm cargo install --force wasm-pack &&
|
2020-11-10 23:36:07 +00:00
|
|
|
printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml &&
|
|
|
|
CC=clang-9 wasm-pack build &&
|
|
|
|
CC=clang-9 wasm-pack test --node;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Address Sanitizer
|
|
|
|
if [ "$DO_ASAN" = true ]; then
|
|
|
|
cargo clean
|
|
|
|
CC='clang -fsanitize=address -fno-omit-frame-pointer' \
|
|
|
|
RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \
|
|
|
|
ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
|
2020-11-10 23:36:07 +00:00
|
|
|
cargo clean &&
|
|
|
|
CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
|
|
|
|
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu &&
|
|
|
|
cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully"
|
2020-11-10 23:36:07 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Bench
|
|
|
|
if [ "$DO_BENCH" = true ]; then
|
2020-12-18 12:08:52 +00:00
|
|
|
cargo bench --all --features="unstable"
|
2020-11-10 23:36:07 +00:00
|
|
|
fi
|
|
|
|
|