|
| 1 | +#!/bin/sh -ex |
| 2 | + |
| 3 | +FEATURES="bitcoin_hashes endomorphism global-context lowmemory rand rand-std recovery serde" |
| 4 | + |
| 5 | +# Use toolchain if explicitly specified |
| 6 | +if [ -n "$TOOLCHAIN" ] |
| 7 | +then |
| 8 | + alias cargo="cargo +$TOOLCHAIN" |
| 9 | +fi |
| 10 | + |
| 11 | +cargo --version |
| 12 | +rustc --version |
| 13 | + |
| 14 | +# Defaults / sanity checks |
| 15 | +cargo build --verbose |
| 16 | +cargo test --verbose |
| 17 | + |
| 18 | +if [ "$DO_FEATURE_MATRIX" = true ]; then |
| 19 | + cargo build --verbose --no-default-features |
| 20 | + #This doesn't work but probably should --andrew |
| 21 | + #cargo test --verbose --no-default-features |
| 22 | + |
| 23 | + # All features |
| 24 | + cargo build --verbose --no-default-features --features="$FEATURES" |
| 25 | + cargo test --verbose --features="$FEATURES" |
| 26 | + # Single features |
| 27 | + for feature in ${FEATURES} |
| 28 | + do |
| 29 | + cargo build --verbose --no-default-features --features="$feature" |
| 30 | + cargo test --verbose --features="$feature" |
| 31 | + done |
| 32 | + |
| 33 | + # Other combos |
| 34 | + cargo test --no-run --verbose --features="fuzztarget" |
| 35 | + cargo test --no-run --verbose --features="fuzztarget recovery" |
| 36 | + cargo test --verbose --features="rand rand-std" |
| 37 | + cargo test --verbose --features="rand serde" |
| 38 | + |
| 39 | + # Examples |
| 40 | + cargo run --example sign_verify |
| 41 | + cargo run --example sign_verify_recovery --features=recovery |
| 42 | + cargo run --example generate_keys --features=rand |
| 43 | +fi |
| 44 | + |
| 45 | +# Docs |
| 46 | +if [ "$DO_DOCS" = true ]; then |
| 47 | + cargo doc --verbose --features="$FEATURES" |
| 48 | +fi |
| 49 | + |
| 50 | +# Webassembly stuff |
| 51 | +if [ "$DO_WASM" = true ]; then |
| 52 | + clang --version && |
| 53 | + CARGO_TARGET_DIR=wasm cargo install --verbose --force wasm-pack && |
| 54 | + printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml && |
| 55 | + CC=clang-9 wasm-pack build && |
| 56 | + CC=clang-9 wasm-pack test --node; |
| 57 | +fi |
| 58 | + |
| 59 | +# Address Sanitizer |
| 60 | +if [ "$DO_ASAN" = true ]; then |
| 61 | + cargo clean |
| 62 | + CC='clang -fsanitize=address -fno-omit-frame-pointer' \ |
| 63 | + RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \ |
| 64 | + ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \ |
| 65 | + cargo test --lib --verbose --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu && |
| 66 | + cargo clean && |
| 67 | + CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ |
| 68 | + RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \ |
| 69 | + cargo test --lib --verbose --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu && |
| 70 | + cd no_std_test && cargo run --release | grep -q "Verified Successfully" |
| 71 | +fi |
| 72 | + |
| 73 | +# Bench |
| 74 | +if [ "$DO_BENCH" = true ]; then |
| 75 | + cargo bench --features="unstable" |
| 76 | +fi |
| 77 | + |
0 commit comments