SimpleKernel 1.17.0
Loading...
Searching...
No Matches
wait_system_test.cpp File Reference
#include <cpu_io.h>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include "arch.h"
#include "basic_info.hpp"
#include "kernel.h"
#include "kstd_cstring"
#include "kstd_libcxx.h"
#include "kstd_memory"
#include "sk_stdlib.h"
#include "syscall.hpp"
#include "system_test.h"
#include "task_control_block.hpp"
#include "task_manager.hpp"
Include dependency graph for wait_system_test.cpp:

Go to the source code of this file.

Functions

auto wait_system_test () -> bool
 Wait 系统测试入口
 

Function Documentation

◆ wait_system_test()

auto wait_system_test ( ) -> bool

Wait 系统测试入口

Definition at line 326 of file wait_system_test.cpp.

326 {
327 klog::Info("=== Wait System Test Suite ===");
328
329 g_tests_completed = 0;
330 g_tests_failed = 0;
331
332 auto& task_mgr = TaskManagerSingleton::instance();
333
334 // 测试 1: 基本 wait 功能
335 auto test1 = kstd::make_unique<TaskControlBlock>("TestWaitBasic", 10,
336 test_wait_basic, nullptr);
337 task_mgr.AddTask(std::move(test1));
338
339 // 测试 2: 等待任意子进程
340 auto test2 = kstd::make_unique<TaskControlBlock>(
341 "TestWaitAnyChild", 10, test_wait_any_child, nullptr);
342 task_mgr.AddTask(std::move(test2));
343
344 // 测试 3: 非阻塞 wait
345 auto test3 = kstd::make_unique<TaskControlBlock>("TestWaitNoHang", 10,
346 test_wait_no_hang, nullptr);
347 task_mgr.AddTask(std::move(test3));
348
349 // 测试 4: 进程组 wait
350 auto test4 = kstd::make_unique<TaskControlBlock>(
351 "TestWaitProcessGroup", 10, test_wait_process_group, nullptr);
352 task_mgr.AddTask(std::move(test4));
353
354 // 测试 5: 僵尸进程回收
355 auto test5 = kstd::make_unique<TaskControlBlock>(
356 "TestWaitZombieReap", 10, test_wait_zombie_reap, nullptr);
357 task_mgr.AddTask(std::move(test5));
358
359 // 同步等待所有测试完成
360 constexpr int kExpectedTests = 5;
361 int timeout = 400;
362 while (timeout > 0) {
363 (void)sys_sleep(50);
364 if (g_tests_completed >= kExpectedTests) {
365 break;
366 }
367 timeout--;
368 }
369
370 EXPECT_EQ(g_tests_completed.load(), kExpectedTests,
371 "All wait tests should complete");
372 EXPECT_EQ(g_tests_failed.load(), 0, "No wait tests should fail");
373
374 klog::Info("Wait System Test Suite: COMPLETED");
375 return true;
376}
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
auto sys_sleep(uint64_t ms) -> int
休眠指定毫秒数
Definition syscall.cpp:90
#define EXPECT_EQ(val1, val2, msg)
Here is the call graph for this function: