MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / test_recursive_lock

Function test_recursive_lock

tests/system_test/spinlock_test.cpp:37–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37auto test_recursive_lock() -> bool {
38 klog::Info("Running test_recursive_lock...");
39 TestSpinLock lock("recursive");
40 EXPECT_TRUE(lock.Lock(), "Lock failed in recursive test");
41 // Lock() 如果已经被当前核心锁定则返回 false
42 if (lock.Lock()) {
43 klog::Err("FAIL: Recursive lock should return false");
44 (void)lock.UnLock(); // 尝试恢复
45 (void)lock.UnLock();
46 return false;
47 }
48
49 EXPECT_TRUE(lock.UnLock(), "Unlock failed in recursive test");
50 // 再次解锁应该失败
51 if (lock.UnLock()) {
52 klog::Err("FAIL: Double unlock should return false");
53 return false;
54 }
55 klog::Info("test_recursive_lock passed");
56 return true;
57}
58
59auto test_lock_guard() -> bool {
60 klog::Info("Running test_lock_guard...");

Callers 1

spinlock_testFunction · 0.85

Calls 4

InfoFunction · 0.85
ErrFunction · 0.85
LockMethod · 0.45
UnLockMethod · 0.45

Tested by

no test coverage detected