|
3 | 3 | set -ex |
4 | 4 |
|
5 | 5 | REPO_DIR=$(git rev-parse --show-toplevel) |
6 | | -FEATURES="bitcoin-hashes global-context lowmemory rand recovery serde std alloc bitcoin-hashes-std rand-std" |
7 | 6 |
|
8 | | -cargo --version |
9 | | -rustc --version |
10 | | - |
11 | | -# Work out if we are using a nightly toolchain. |
12 | | -NIGHTLY=false |
13 | | -if cargo --version | grep nightly; then |
14 | | - NIGHTLY=true |
15 | | -fi |
16 | | - |
17 | | -# Pin dependencies as required if we are using MSRV toolchain. |
18 | | -if cargo --version | grep "1\.48"; then |
19 | | - cargo update -p wasm-bindgen-test --precise 0.3.34 |
20 | | - cargo update -p serde_test --precise 1.0.175 |
21 | | -fi |
22 | | - |
23 | | -# Test if panic in C code aborts the process (either with a real panic or with SIGILL) |
24 | | -cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 \ |
25 | | - | tee /dev/stderr \ |
26 | | - | grep "SIGILL\\|\[libsecp256k1] illegal argument. !rustsecp256k1_v0_._._fe_is_zero(&ge->x)" |
27 | | - |
28 | | -# Make all cargo invocations verbose |
29 | | -export CARGO_TERM_VERBOSE=true |
30 | | - |
31 | | -# Defaults / sanity checks |
32 | | -cargo build --all |
33 | | -cargo test --all |
34 | | - |
35 | | -if [ "$DO_FEATURE_MATRIX" = true ]; then |
36 | | - cargo build --all --no-default-features |
37 | | - cargo test --all --no-default-features |
38 | | - |
39 | | - # All features |
40 | | - cargo build --all --no-default-features --features="$FEATURES" |
41 | | - cargo test --all --no-default-features --features="$FEATURES" |
42 | | - # Single features |
43 | | - for feature in ${FEATURES} |
44 | | - do |
45 | | - cargo build --all --no-default-features --features="$feature" |
46 | | - cargo test --all --no-default-features --features="$feature" |
47 | | - done |
48 | | - # Features tested with 'std' feature enabled. |
49 | | - for feature in ${FEATURES} |
50 | | - do |
51 | | - cargo build --all --no-default-features --features="std,$feature" |
52 | | - cargo test --all --no-default-features --features="std,$feature" |
53 | | - done |
54 | | - # Other combos |
55 | | - RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all |
56 | | - RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --features="$FEATURES" |
57 | | - cargo test --all --features="rand serde" |
58 | | - |
59 | | - if [ "$NIGHTLY" = true ]; then |
60 | | - cargo test --all --all-features |
61 | | - RUSTFLAGS='--cfg=secp256k1_fuzz' RUSTDOCFLAGS='--cfg=secp256k1_fuzz' cargo test --all --all-features |
62 | | - fi |
63 | | - |
64 | | - # Examples |
65 | | - cargo run --example sign_verify --features=bitcoin-hashes-std |
66 | | - cargo run --example sign_verify_recovery --features=recovery,bitcoin-hashes-std |
67 | | - cargo run --example generate_keys --features=rand-std |
68 | | -fi |
69 | | - |
70 | | -if [ "$DO_LINT" = true ] |
71 | | -then |
72 | | - cargo clippy --all-features --all-targets -- -D warnings |
73 | | - cargo clippy --example sign_verify --features=bitcoin-hashes-std -- -D warnings |
74 | | - cargo clippy --example sign_verify_recovery --features=recovery,bitcoin-hashes-std -- -D warnings |
75 | | - cargo clippy --example generate_keys --features=rand-std -- -D warnings |
76 | | -fi |
77 | | - |
78 | | -# Build the docs if told to (this only works with the nightly toolchain) |
79 | | -if [ "$DO_DOCSRS" = true ]; then |
80 | | - RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features |
81 | | -fi |
82 | | - |
83 | | -# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command |
84 | | -# above this checks that we feature guarded docs imports correctly. |
85 | | -if [ "$DO_DOCS" = true ]; then |
86 | | - RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features |
87 | | -fi |
88 | | - |
89 | | -# Webassembly stuff |
90 | | -if [ "$DO_WASM" = true ]; then |
91 | | - clang --version |
92 | | - CARGO_TARGET_DIR=wasm cargo install --force wasm-pack |
93 | | - printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml |
94 | | - CC=clang wasm-pack build |
95 | | - CC=clang wasm-pack test --node |
96 | | -fi |
97 | | - |
98 | | -# Address Sanitizer |
99 | | -if [ "$DO_ASAN" = true ]; then |
100 | | - clang --version |
101 | | - cargo clean |
102 | | - CC='clang -fsanitize=address -fno-omit-frame-pointer' \ |
103 | | - RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \ |
104 | | - ASAN_OPTIONS='detect_leaks=1 detect_invalid_pointer_pairs=1 detect_stack_use_after_return=1' \ |
105 | | - cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu |
106 | | - cargo clean |
107 | | - # The -Cllvm-args=-msan-eager-checks=0 flag was added to overcome this issue: |
108 | | - # https://github.com/rust-bitcoin/rust-secp256k1/pull/573#issuecomment-1399465995 |
109 | | - CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ |
110 | | - RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \ |
111 | | - cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu |
112 | | - |
113 | | - pushd "$REPO_DIR/no_std_test" > /dev/null || exit 1 |
114 | | - # See https://github.com/rust-bitcoin/rust-secp256k1/pull/641#issuecomment-1671598914 |
115 | | - cargo update -p cc --precise 1.0.79 |
116 | | - popd > /dev/null || exit 1 |
117 | | - |
118 | | - cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully" |
119 | | - cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully" |
120 | | -fi |
121 | | - |
122 | | -# Run formatter if told to. |
123 | | -if [ "$DO_FMT" = true ]; then |
124 | | - if [ "$NIGHTLY" = false ]; then |
125 | | - echo "DO_FMT requires a nightly toolchain (consider using RUSTUP_TOOLCHAIN)" |
126 | | - exit 1 |
127 | | - fi |
128 | | - rustup component add rustfmt |
129 | | - cargo fmt --check || exit 1 |
130 | | -fi |
131 | | - |
132 | | -# Bench if told to, only works with non-stable toolchain (nightly, beta). |
133 | | -if [ "$DO_BENCH" = true ] |
134 | | -then |
135 | | - RUSTFLAGS='--cfg=bench' cargo bench --features=recovery,rand-std |
136 | | -fi |
137 | | - |
138 | | -exit 0 |
| 7 | +$REPO_DIR/contrib/_test.sh |
0 commit comments