From 7bec31c3a6eb43068f0b28db5f351b079751b2e2 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 17 Mar 2022 10:30:36 +1100 Subject: [PATCH 1/3] test.sh: explicitly return 0 As per UNIX convention a Bash script should exit with status code 0 if it completes successfully. --- contrib/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/test.sh b/contrib/test.sh index a892a78..413115b 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -94,3 +94,4 @@ if [ "$DO_BENCH" = true ]; then cargo bench --all --features="unstable" fi +exit 0 From a3582ff77dec8f4c5855fa38f4b8ff6bef700169 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 17 Mar 2022 10:57:30 +1100 Subject: [PATCH 2/3] test.sh: Use set -e to exit on failure Currently the `test.sh` script is silently failing because we do not exit if a command fails. We can achieve this by using the Bash builtin `set -e`. For some reason I cannot explain a chain of commands that fails does not fail the script. Instead of working out _why_ just remove the chain and run each command on its own. This is functionally the same and, I hazard a guess, is what the original author hoped to achieve with the chaining. --- contrib/test.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/contrib/test.sh b/contrib/test.sh index 413115b..e093e43 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -1,5 +1,7 @@ #!/bin/sh -ex +set -e + # TODO: Add "alloc" once we bump MSRV to past 1.29 FEATURES="bitcoin_hashes global-context lowmemory rand recovery serde std" # These features are typically enabled along with the 'std' feature, so we test @@ -64,11 +66,11 @@ fi # Webassembly stuff if [ "$DO_WASM" = true ]; then - clang --version && - CARGO_TARGET_DIR=wasm cargo install --force wasm-pack && - printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml && - CC=clang-9 wasm-pack build && - CC=clang-9 wasm-pack test --node; + clang --version + CARGO_TARGET_DIR=wasm cargo install --force wasm-pack + 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 @@ -77,11 +79,11 @@ if [ "$DO_ASAN" = true ]; then 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' \ - cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu && - cargo clean && + cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu + cargo clean CC='clang -fsanitize=memory -fno-omit-frame-pointer' \ RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \ - cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu && + 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" cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully" fi From 97dc0ea9acdc308cc2cadc11e4787d07ec9b2c79 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 22 Mar 2022 10:12:30 +1100 Subject: [PATCH 3/3] Run correct clang --version For the test that uses `clang-9` do the sanity call using `clang-9` instead of `clang`. For the test that uses `clang` add a sanity call to `clang --version`. --- contrib/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/test.sh b/contrib/test.sh index e093e43..f5f8363 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -66,7 +66,7 @@ fi # Webassembly stuff if [ "$DO_WASM" = true ]; then - clang --version + clang-9 --version CARGO_TARGET_DIR=wasm cargo install --force wasm-pack printf '\n[lib]\ncrate-type = ["cdylib", "rlib"]\n' >> Cargo.toml CC=clang-9 wasm-pack build @@ -75,6 +75,7 @@ fi # Address Sanitizer if [ "$DO_ASAN" = true ]; then + clang --version cargo clean CC='clang -fsanitize=address -fno-omit-frame-pointer' \ RUSTFLAGS='-Zsanitizer=address -Clinker=clang -Cforce-frame-pointers=yes' \