mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-28 21:10:28 +00:00
add tsan test
This commit is contained in:
parent
55f891e64f
commit
4a6bf95f19
6
blacklist.txt
Normal file
6
blacklist.txt
Normal file
@ -0,0 +1,6 @@
|
||||
# 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() {
|
||||
rustup component list | grep 'rust-src.*installed' || \
|
||||
rustup component add rust-src
|
||||
;;
|
||||
x86_64-unknown-linux-gnu)
|
||||
;;
|
||||
*)
|
||||
# unhandled case
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
13
ci/script.sh
13
ci/script.sh
@ -5,8 +5,19 @@ main() {
|
||||
thumb*m-none-eabi)
|
||||
xargo check --target $TARGET
|
||||
;;
|
||||
*)
|
||||
x86_64-unknown-linux-gnu)
|
||||
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
|
||||
}
|
||||
|
20
tests/tsan.rs
Normal file
20
tests/tsan.rs
Normal file
@ -0,0 +1,20 @@
|
||||
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();
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user