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

Function mutex_test

tests/system_test/mutex_test.cpp:297–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295} // namespace
296
297auto mutex_test() -> bool {
298 klog::Info("=== Mutex System Test Suite ===");
299
300 g_tests_completed = 0;
301 g_tests_failed = 0;
302
303 auto& task_mgr = TaskManagerSingleton::instance();
304
305 auto test1 = kstd::make_unique<TaskControlBlock>(
306 "TestMutexBasic", 10, test_mutex_basic_lock_unlock, nullptr);
307 task_mgr.AddTask(std::move(test1));
308
309 auto test2 = kstd::make_unique<TaskControlBlock>("TestMutexTryLock", 10,
310 test_mutex_trylock, nullptr);
311 task_mgr.AddTask(std::move(test2));
312
313 auto test3 = kstd::make_unique<TaskControlBlock>(
314 "TestMutexContention", 10, test_mutex_contention, nullptr);
315 task_mgr.AddTask(std::move(test3));
316
317 auto test4 = kstd::make_unique<TaskControlBlock>(
318 "TestMutexOrdering", 10, test_mutex_ordering, nullptr);
319 task_mgr.AddTask(std::move(test4));
320
321 constexpr int kExpectedTests = 4;
322 int timeout = 400;
323 while (timeout > 0) {
324 (void)sys_sleep(50);
325 if (g_tests_completed >= kExpectedTests) {
326 break;
327 }
328 timeout--;
329 }
330
331 EXPECT_EQ(g_tests_completed.load(), kExpectedTests,
332 "All mutex tests should complete");
333 EXPECT_EQ(g_tests_failed.load(), 0, "No mutex tests should fail");
334
335 klog::Info("Mutex System Test Suite: COMPLETED");
336 return true;
337}

Callers

nothing calls this directly

Calls 3

InfoFunction · 0.85
sys_sleepFunction · 0.85
AddTaskMethod · 0.80

Tested by

no test coverage detected