Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: sync: atomic: Add atomic bool tests

Add tests for Atomic<bool> operations.

Atomic<bool> does not fit into the existing u8/16/32/64 tests so
introduce a dedicated test for it.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20260101034922.2020334-3-fujita.tomonori@gmail.com

authored by

FUJITA Tomonori and committed by
Boqun Feng
4bac2872 06bd0e52

+16
+16
rust/kernel/sync/atomic/predefine.rs
··· 199 199 assert_eq!(v + 25, x.load(Relaxed)); 200 200 }); 201 201 } 202 + 203 + #[test] 204 + fn atomic_bool_tests() { 205 + let x = Atomic::new(false); 206 + 207 + assert_eq!(false, x.load(Relaxed)); 208 + x.store(true, Relaxed); 209 + assert_eq!(true, x.load(Relaxed)); 210 + 211 + assert_eq!(true, x.xchg(false, Relaxed)); 212 + assert_eq!(false, x.load(Relaxed)); 213 + 214 + assert_eq!(Err(false), x.cmpxchg(true, true, Relaxed)); 215 + assert_eq!(false, x.load(Relaxed)); 216 + assert_eq!(Ok(false), x.cmpxchg(false, true, Full)); 217 + } 202 218 }