[<prev] [next>] [day] [month] [year] [list]
Message-ID: <176830139101.510.8913819849324905085.tip-bot2@tip-bot2>
Date: Tue, 13 Jan 2026 10:49:51 -0000
From: "tip-bot2 for FUJITA Tomonori" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>, Gary Guo <gary@...yguo.net>,
Boqun Feng <boqun.feng@...il.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: locking/core] rust: sync: atomic: Add atomic bool tests
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 4bac28727a2b3f33e6375aeafdf31df67deff5d0
Gitweb: https://git.kernel.org/tip/4bac28727a2b3f33e6375aeafdf31df67deff5d0
Author: FUJITA Tomonori <fujita.tomonori@...il.com>
AuthorDate: Thu, 01 Jan 2026 12:49:22 +09:00
Committer: Boqun Feng <boqun.feng@...il.com>
CommitterDate: Fri, 09 Jan 2026 19:01:41 +08:00
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@...il.com>
Reviewed-by: Gary Guo <gary@...yguo.net>
Signed-off-by: Boqun Feng <boqun.feng@...il.com>
Link: https://patch.msgid.link/20260101034922.2020334-3-fujita.tomonori@gmail.com
---
rust/kernel/sync/atomic/predefine.rs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/rust/kernel/sync/atomic/predefine.rs b/rust/kernel/sync/atomic/predefine.rs
index 3fc9917..42067c6 100644
--- a/rust/kernel/sync/atomic/predefine.rs
+++ b/rust/kernel/sync/atomic/predefine.rs
@@ -199,4 +199,20 @@ mod tests {
assert_eq!(v + 25, x.load(Relaxed));
});
}
+
+ #[test]
+ fn atomic_bool_tests() {
+ let x = Atomic::new(false);
+
+ assert_eq!(false, x.load(Relaxed));
+ x.store(true, Relaxed);
+ assert_eq!(true, x.load(Relaxed));
+
+ assert_eq!(true, x.xchg(false, Relaxed));
+ assert_eq!(false, x.load(Relaxed));
+
+ assert_eq!(Err(false), x.cmpxchg(true, true, Relaxed));
+ assert_eq!(false, x.load(Relaxed));
+ assert_eq!(Ok(false), x.cmpxchg(false, true, Full));
+ }
}
Powered by blists - more mailing lists