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

Function signal_test

tests/system_test/signal_test.cpp:373–432  ·  view source on GitHub ↗

* @brief Signal system test entry point */

Source from the content-addressed store, hash-verified

371 * @brief Signal system test entry point
372 */
373auto signal_test() -> bool {
374 klog::Info("===== Signal System Test Start =====");
375
376 g_tests_completed = 0;
377 g_tests_failed = 0;
378
379 auto& tm = TaskManagerSingleton::instance();
380
381 // Sub-test 1: SIGTERM default action
382 auto t1 = kstd::make_unique<TaskControlBlock>("TestSigtermDefault", 10,
383 test_sigterm_default, nullptr);
384 tm.AddTask(std::move(t1));
385
386 // Sub-test 2: SIGKILL (uncatchable)
387 auto t2 = kstd::make_unique<TaskControlBlock>("TestSigkill", 10, test_sigkill,
388 nullptr);
389 tm.AddTask(std::move(t2));
390
391 // Sub-test 3: Sigaction ignore
392 auto t3 = kstd::make_unique<TaskControlBlock>("TestSigactionIgnore", 10,
393 test_sigaction_ignore, nullptr);
394 tm.AddTask(std::move(t3));
395
396 // Sub-test 4: Sigaction uncatchable
397 auto t4 = kstd::make_unique<TaskControlBlock>(
398 "TestSigactionUncatchable", 10, test_sigaction_uncatchable, nullptr);
399 tm.AddTask(std::move(t4));
400
401 // Sub-test 5: Sigprocmask
402 auto t5 = kstd::make_unique<TaskControlBlock>("TestSigprocmask", 10,
403 test_sigprocmask, nullptr);
404 tm.AddTask(std::move(t5));
405
406 // Sub-test 6: Kill invalid PID
407 auto t6 = kstd::make_unique<TaskControlBlock>("TestKillInvalidPid", 10,
408 test_kill_invalid_pid, nullptr);
409 tm.AddTask(std::move(t6));
410
411 klog::Info("Waiting for all 6 signal sub-tests to complete...");
412
413 // Wait for all sub-tests (timeout: 200 * 50ms = 10s)
414 constexpr int kExpectedTests = 6;
415 int timeout = 200;
416 while (timeout-- > 0) {
417 (void)sys_sleep(50);
418 if (g_tests_completed.load() >= kExpectedTests) {
419 break;
420 }
421 }
422
423 klog::Info("Signal System Test: completed={}, failed={}",
424 g_tests_completed.load(), g_tests_failed.load());
425
426 EXPECT_EQ(g_tests_completed.load(), kExpectedTests,
427 "All 6 signal sub-tests completed");
428 EXPECT_EQ(g_tests_failed.load(), 0, "No signal sub-tests failed");
429
430 klog::Info("===== Signal System Test End =====");

Callers

nothing calls this directly

Calls 3

InfoFunction · 0.85
sys_sleepFunction · 0.85
AddTaskMethod · 0.80

Tested by

no test coverage detected