297 {
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) {
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}
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
auto sys_sleep(uint64_t ms) -> int
休眠指定毫秒数
#define EXPECT_EQ(val1, val2, msg)