452 {
453 klog::Info(
"===== Exit System Test Start =====");
454
455
456 g_tests_completed = 0;
457 g_tests_failed = 0;
458 g_exit_test_counter = 0;
459
460 auto& task_mgr = TaskManagerSingleton::instance();
461
462
463 auto test1 = kstd::make_unique<TaskControlBlock>("TestExitNormal", 10,
464 test_exit_normal, nullptr);
465 task_mgr.AddTask(std::move(test1));
466
467
468 auto test2 = kstd::make_unique<TaskControlBlock>(
469 "TestExitWithError", 10, test_exit_with_error, nullptr);
470 task_mgr.AddTask(std::move(test2));
471
472
473 auto test3 = kstd::make_unique<TaskControlBlock>("TestThreadExit", 10,
474 test_thread_exit, nullptr);
475 task_mgr.AddTask(std::move(test3));
476
477
478 auto test4 = kstd::make_unique<TaskControlBlock>("TestOrphanExit", 10,
479 test_orphan_exit, nullptr);
480 task_mgr.AddTask(std::move(test4));
481
482
483 auto test5 = kstd::make_unique<TaskControlBlock>(
484 "TestZombieProcess", 10, test_zombie_process, nullptr);
485 task_mgr.AddTask(std::move(test5));
486
487 klog::Info(
"Waiting for all 5 sub-tests to complete...");
488
489
490
491 int timeout = 200;
492 while (timeout > 0) {
494 if (g_tests_completed.load() >= 5) {
495 break;
496 }
497 timeout--;
498 }
499
500 klog::Info(
"Exit System Test: completed={}, failed={}",
501 g_tests_completed.load(), g_tests_failed.load());
502
503 EXPECT_EQ(g_tests_completed, 5,
"All 5 sub-tests completed");
504 EXPECT_EQ(g_tests_failed, 0,
"No sub-tests failed");
505
506 klog::Info(
"===== Exit System Test End =====");
507 return true;
508}
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
auto sys_sleep(uint64_t ms) -> int
休眠指定毫秒数
#define EXPECT_EQ(val1, val2, msg)