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

Method SetUp

tests/unit_test/task/fixtures/task_test_harness.cpp:12–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "task_manager.hpp"
11
12void TaskTestHarness::SetUp() {
13 // 1. 初始化环境层(每个测试都有独立实例)
14 env_state_.InitializeCores(num_cores_);
15
16 // 2. 设置当前线程的环境指针(让 Mock 层可以访问)
17 env_state_.SetCurrentThreadEnvironment();
18
19 // 3. 绑定主测试线程到 core 0
20 env_state_.BindThreadToCore(std::this_thread::get_id(), 0);
21
22 // 3. 重置 PerCpu 数据
23 per_cpu::PerCpuArraySingleton::create();
24 auto& per_cpu_array = per_cpu::PerCpuArraySingleton::instance();
25 for (size_t i = 0; i < SIMPLEKERNEL_MAX_CORE_COUNT; ++i) {
26 per_cpu_array[i] = per_cpu::PerCpu(i);
27 }
28
29 // 4. 重置 TaskManager(如果有 ResetForTesting 方法)
30 // 注意:这需要在 TaskManager 中实现
31 // TaskManagerSingleton::instance().ResetForTesting();
32}
33
34void TaskTestHarness::TearDown() {
35 per_cpu::PerCpuArraySingleton::destroy();

Callers

nothing calls this directly

Calls 4

PerCpuClass · 0.85
InitializeCoresMethod · 0.80
BindThreadToCoreMethod · 0.80

Tested by

no test coverage detected