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

Function stress_test

tests/system_test/stress_test.cpp:210–253  ·  view source on GitHub ↗

* @brief Stress system test entry point */

Source from the content-addressed store, hash-verified

208 * @brief Stress system test entry point
209 */
210auto stress_test() -> bool {
211 klog::Info("===== Stress System Test Start =====");
212
213 g_tests_completed = 0;
214 g_tests_failed = 0;
215
216 auto& tm = TaskManagerSingleton::instance();
217
218 // Sub-test 1: Many tasks
219 auto t1 = kstd::make_unique<TaskControlBlock>("TestManyTasks", 10,
220 test_many_tasks, nullptr);
221 tm.AddTask(std::move(t1));
222
223 // Sub-test 2: Wait non-child
224 auto t2 = kstd::make_unique<TaskControlBlock>("TestWaitNonChild", 10,
225 test_wait_non_child, nullptr);
226 tm.AddTask(std::move(t2));
227
228 // Sub-test 3: Rapid create/exit
229 auto t3 = kstd::make_unique<TaskControlBlock>(
230 "TestRapidCreateExit", 10, test_rapid_create_exit, nullptr);
231 tm.AddTask(std::move(t3));
232
233 // Wait for all 3 sub-tests to complete (timeout: 400 * 50ms = 20s)
234 constexpr int kExpectedTests = 3;
235 int timeout = 400;
236 while (timeout > 0) {
237 (void)sys_sleep(50);
238 if (g_tests_completed.load() >= kExpectedTests) {
239 break;
240 }
241 timeout--;
242 }
243
244 klog::Info("Stress System Test: completed={}, failed={}",
245 g_tests_completed.load(), g_tests_failed.load());
246
247 EXPECT_EQ(g_tests_completed.load(), kExpectedTests,
248 "All 3 stress sub-tests completed");
249 EXPECT_EQ(g_tests_failed.load(), 0, "No stress sub-tests failed");
250
251 klog::Info("===== Stress System Test End =====");
252 return true;
253}

Callers

nothing calls this directly

Calls 3

InfoFunction · 0.85
sys_sleepFunction · 0.85
AddTaskMethod · 0.80

Tested by

no test coverage detected