diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/rust/audio-mixer/run_sanitizers.sh | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/audio-mixer/run_sanitizers.sh')
-rwxr-xr-x | third_party/rust/audio-mixer/run_sanitizers.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/third_party/rust/audio-mixer/run_sanitizers.sh b/third_party/rust/audio-mixer/run_sanitizers.sh new file mode 100755 index 0000000000..7f73c2b9a0 --- /dev/null +++ b/third_party/rust/audio-mixer/run_sanitizers.sh @@ -0,0 +1,53 @@ +# The option `Z` is only accepted on the nightly compiler +# so changing to nightly toolchain by `rustup default nightly` is required. + +# See: https://github.com/rust-lang/rust/issues/39699 for more sanitizer support. + +toolchain="$(rustup default)" +echo -e "\nUse Rust toolchain: $toolchain" + +NIGHTLY_PREFIX="nightly" +if [ ! -z "${toolchain##$NIGHTLY_PREFIX*}" ]; then + echo -e "The sanitizer is only available on Rust Nightly only. Skip." + exit +fi + +if [ -z "${toolchain##*windows*}" ]; then + echo -e "The sanitizer doesn't work on Windows platform yet" + exit +fi + +# Display verbose backtrace for debugging if backtrace is unset +if [ -z "${RUST_BACKTRACE}" ]; then + export RUST_BACKTRACE=1 +fi +echo -e "RUST_BACKTRACE is set to ${RUST_BACKTRACE}\n" + +# {Address, Thread}Sanitizer cannot build with `criterion` crate, so `criterion` will be removed +# from the `Cargo.toml` temporarily during the sanitizer tests. +ORIGINAL_MANIFEST="Cargo_ori.toml" +mv Cargo.toml $ORIGINAL_MANIFEST +# Delete lines that contain a `criterion` from Cargo.toml. +sed '/criterion/d' $ORIGINAL_MANIFEST > Cargo.toml + +sanitizers=("address" "leak" "memory" "thread") +for san in "${sanitizers[@]}" +do + San="$(tr '[:lower:]' '[:upper:]' <<< ${san:0:1})${san:1}" + echo -e "\n\nRun ${San}Sanitizer\n------------------------------" + if [ $san = "leak" ]; then + echo -e "Skip the test that panics. Leaking memory when the program drops out abnormally is ok." + options="-- --Z unstable-options --exclude-should-panic" + fi + if [ $san = "memory" ]; then + if [ -z "${toolchain##*darwin*}" ]; then + echo -e "Skip the MemorySanitizer on Mac OS since it doesn't works with $toolchain" + else + echo -e "Skip the MemorySanitizer since it fails to run custom build command for bitflags crate" + fi + continue + fi + RUSTFLAGS="-Z sanitizer=${san}" cargo test $options +done + +mv $ORIGINAL_MANIFEST Cargo.toml
\ No newline at end of file |