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

Function spinlock_test

tests/system_test/spinlock_test.cpp:350–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348} // namespace
349
350auto spinlock_test() -> bool {
351 bool ret = true;
352 size_t core_id = cpu_io::GetCurrentCoreId();
353
354 // 单元测试仅在核心 0 上运行,以避免日志混乱
355 if (core_id == 0) {
356 klog::Info("Starting spinlock_test");
357 ret = ret && test_basic_lock();
358 ret = ret && test_recursive_lock();
359 ret = ret && test_lock_guard();
360 ret = ret && test_interrupt_restore();
361 }
362
363 // SMP (多核) 测试在所有核心上运行
364 // 使用顺序执行以确保如果前一个测试失败,屏障不会死锁
365 if (!spinlock_smp_test()) ret = false;
366 if (!spinlock_smp_buffer_test()) ret = false;
367 if (!spinlock_smp_string_test()) ret = false;
368
369 if (core_id == 0) {
370 if (ret) {
371 klog::Info("spinlock_test passed");
372 } else {
373 klog::Err("spinlock_test failed");
374 }
375 }
376 return ret;
377}

Callers

nothing calls this directly

Calls 10

GetCurrentCoreIdFunction · 0.85
InfoFunction · 0.85
test_basic_lockFunction · 0.85
test_recursive_lockFunction · 0.85
test_lock_guardFunction · 0.85
test_interrupt_restoreFunction · 0.85
spinlock_smp_testFunction · 0.85
spinlock_smp_buffer_testFunction · 0.85
spinlock_smp_string_testFunction · 0.85
ErrFunction · 0.85

Tested by

no test coverage detected