| 107 | } // namespace |
| 108 | |
| 109 | auto tick_test() -> bool { |
| 110 | klog::Info("=== Tick System Test Suite ==="); |
| 111 | |
| 112 | g_tests_completed = 0; |
| 113 | g_tests_failed = 0; |
| 114 | |
| 115 | auto& task_mgr = TaskManagerSingleton::instance(); |
| 116 | |
| 117 | auto test1 = kstd::make_unique<TaskControlBlock>( |
| 118 | "TestTickIncrements", 10, test_tick_increments, nullptr); |
| 119 | task_mgr.AddTask(std::move(test1)); |
| 120 | |
| 121 | auto test2 = kstd::make_unique<TaskControlBlock>("TestSleepTiming", 10, |
| 122 | test_sleep_timing, nullptr); |
| 123 | task_mgr.AddTask(std::move(test2)); |
| 124 | |
| 125 | auto test3 = kstd::make_unique<TaskControlBlock>( |
| 126 | "TestRuntimeTracking", 10, test_runtime_tracking, nullptr); |
| 127 | task_mgr.AddTask(std::move(test3)); |
| 128 | |
| 129 | constexpr int kExpectedTests = 3; |
| 130 | int timeout = 400; |
| 131 | while (timeout > 0) { |
| 132 | (void)sys_sleep(50); |
| 133 | if (g_tests_completed >= kExpectedTests) { |
| 134 | break; |
| 135 | } |
| 136 | timeout--; |
| 137 | } |
| 138 | |
| 139 | EXPECT_EQ(g_tests_completed.load(), kExpectedTests, |
| 140 | "All tick tests should complete"); |
| 141 | EXPECT_EQ(g_tests_failed.load(), 0, "No tick tests should fail"); |
| 142 | |
| 143 | klog::Info("Tick System Test Suite: COMPLETED"); |
| 144 | return true; |
| 145 | } |