CI: Add sanitizer script
As we did for the wasm job. In preparation for using the `run_task` script from maintainer tools we want to have all the things that are particular to `rust-bitcoin` out of the current `run_task` script. The address/memory sanitizer test is specific to `hashes`. Add a script in `hashes/contrib` and call it from the ASAN job. No test coverage change.
This commit is contained in:
parent
3407257936
commit
44cb2255d3
|
@ -232,8 +232,8 @@ jobs:
|
|||
run: rustup component add rust-src
|
||||
- name: "Set dependencies"
|
||||
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
|
||||
- name: "Run test script"
|
||||
run: ./contrib/run_task.sh asan
|
||||
- name: "Run sanitizer script"
|
||||
run: cd ./hashes && ./contrib/sanitizer.sh
|
||||
|
||||
WASM: # hashes crate only.
|
||||
name: WASM - stable toolchain
|
||||
|
|
|
@ -90,11 +90,6 @@ main() {
|
|||
do_bench
|
||||
;;
|
||||
|
||||
asan)
|
||||
# hashes crate only - hashes/contrib/test_vars.sh is sourced in this function.
|
||||
do_asan
|
||||
;;
|
||||
|
||||
*)
|
||||
err "Error: unknown task $task"
|
||||
;;
|
||||
|
@ -254,27 +249,6 @@ do_bench() {
|
|||
done
|
||||
}
|
||||
|
||||
do_asan() {
|
||||
pushd "$REPO_DIR/hashes" > /dev/null
|
||||
|
||||
# Set ASAN_FEATURES
|
||||
. contrib/test_vars.sh || exit 1
|
||||
|
||||
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' \
|
||||
cargo test --lib --no-default-features --features="$ASAN_FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
|
||||
# There is currently a bug in the MemorySanitizer (MSAN) - disable the job for now.
|
||||
#
|
||||
# cargo clean
|
||||
# CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
|
||||
# RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
|
||||
# cargo test --lib --no-default-features --features="$ASAN_FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
|
||||
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
# Check all the commands we use are present in the current environment.
|
||||
check_required_commands() {
|
||||
need_cmd cargo
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run the Address/Memory Sanitizer tests.
|
||||
|
||||
set -euox pipefail
|
||||
|
||||
# Run the sanitizer with these features.
|
||||
FEATURES="std io serde"
|
||||
|
||||
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' \
|
||||
cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
|
||||
|
||||
# There is currently a bug in the MemorySanitizer (MSAN) - disable the job for now.
|
||||
#
|
||||
# cargo clean
|
||||
# CC='clang -fsanitize=memory -fno-omit-frame-pointer' \
|
||||
# RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes' \
|
||||
# cargo test --lib --no-default-features --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu
|
|
@ -6,8 +6,5 @@ FEATURES_WITH_STD="io serde small-hash schemars"
|
|||
# Test all these features without "std" enabled.
|
||||
FEATURES_WITHOUT_STD="alloc serde small-hash"
|
||||
|
||||
# Run address sanitizer with these features.
|
||||
ASAN_FEATURES="std io serde"
|
||||
|
||||
# Run these examples.
|
||||
EXAMPLES=""
|
||||
|
|
Loading…
Reference in New Issue