Skip to content
Snippets Groups Projects
Commit 4a6bf95f authored by Jorge Aparicio's avatar Jorge Aparicio
Browse files

add tsan test

parent 55f891e6
Branches
No related tags found
No related merge requests found
# false positives from thread::spawn (?)
race:<alloc::arc::Arc<T>>::drop_slow
race:__GI___call_tls_dtors
race:alloc::heap::{{impl}}::dealloc
race:core::ptr::drop_in_place<core::option::Option<core::result::Result<(), alloc::boxed::Box<Any>>>>
race:core::ptr::drop_in_place<core::result::Result<(), alloc::boxed::Box<Any>>>
...@@ -11,7 +11,11 @@ main() { ...@@ -11,7 +11,11 @@ main() {
rustup component list | grep 'rust-src.*installed' || \ rustup component list | grep 'rust-src.*installed' || \
rustup component add rust-src rustup component add rust-src
;; ;;
x86_64-unknown-linux-gnu)
;;
*) *)
# unhandled case
exit 1
;; ;;
esac esac
} }
......
...@@ -5,8 +5,19 @@ main() { ...@@ -5,8 +5,19 @@ main() {
thumb*m-none-eabi) thumb*m-none-eabi)
xargo check --target $TARGET xargo check --target $TARGET
;; ;;
*) x86_64-unknown-linux-gnu)
cargo check --target $TARGET cargo check --target $TARGET
cargo test --target $TARGET
export TSAN_OPTIONS="suppressions=$(pwd)/blacklist.txt"
export RUSTFLAGS="-Z sanitizer=thread"
cargo test --test tsan --target $TARGET
cargo test --test tsan --target $TARGET --release
;;
*)
# unhandled case
exit 1
;; ;;
esac esac
} }
extern crate heapless;
use std::thread;
use heapless::RingBuffer;
#[test]
fn tsan() {
static mut RB: RingBuffer<i32, [i32; 4]> = RingBuffer::new();
unsafe { RB.split() }.0.enqueue(0).unwrap();
thread::spawn(|| {
unsafe { RB.split() }.0.enqueue(1).unwrap();
});
thread::spawn(|| {
unsafe { RB.split() }.1.dequeue().unwrap();
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment