SimpleKernel 1.17.0
Loading...
Searching...
No Matches
thread_group_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 thread_group_system_test.cpp:

Go to the source code of this file.

Functions

auto thread_group_system_test () -> bool
 线程组系统测试入口
 

Function Documentation

◆ thread_group_system_test()

auto thread_group_system_test ( ) -> bool

线程组系统测试入口

Definition at line 243 of file thread_group_system_test.cpp.

243 {
244 klog::Info("=== Thread Group System Test Suite ===");
245
246 g_tests_completed = 0;
247 g_tests_failed = 0;
248
249 // 测试 1: 基本线程组功能
250 auto test1 = kstd::make_unique<TaskControlBlock>(
251 "TestThreadGroupBasic", 10, test_thread_group_basic, nullptr);
252 TaskManagerSingleton::instance().AddTask(std::move(test1));
253
254 // 测试 2: 动态加入和离开
255 auto test2 = kstd::make_unique<TaskControlBlock>(
256 "TestThreadGroupDynamic", 10, test_thread_group_dynamic, nullptr);
257 TaskManagerSingleton::instance().AddTask(std::move(test2));
258
259 // 测试 3: 并发退出
260 auto test3 = kstd::make_unique<TaskControlBlock>(
261 "TestThreadGroupConcurrentExit", 10, test_thread_group_concurrent_exit,
262 nullptr);
263 TaskManagerSingleton::instance().AddTask(std::move(test3));
264
265 // 同步等待所有测试完成
266 constexpr int kExpectedTests = 3;
267 int timeout = 400;
268 while (timeout > 0) {
269 (void)sys_sleep(50);
270 if (g_tests_completed >= kExpectedTests) {
271 break;
272 }
273 timeout--;
274 }
275
276 EXPECT_EQ(g_tests_completed.load(), kExpectedTests,
277 "All thread group tests should complete");
278 EXPECT_EQ(g_tests_failed.load(), 0, "No thread group tests should fail");
279
280 klog::Info("Thread Group System Test Suite: COMPLETED");
281 return true;
282}
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: