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

Function balance_test

tests/system_test/balance_test.cpp:216–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214} // namespace
215
216auto balance_test() -> bool {
217 klog::Info("===== Balance System Test Start =====");
218
219 auto core_count = BasicInfoSingleton::instance().core_count;
220 if (core_count < 2) {
221 klog::Info("Skipping balance tests: need >= 2 cores, have {}", core_count);
222 return true;
223 }
224
225 g_tests_completed = 0;
226 g_tests_failed = 0;
227
228 auto& tm = TaskManagerSingleton::instance();
229
230 auto t1 = kstd::make_unique<TaskControlBlock>(
231 "TestBalImbalance", 10, test_balance_imbalanced_load, nullptr);
232 tm.AddTask(std::move(t1));
233
234 auto t2 = kstd::make_unique<TaskControlBlock>(
235 "TestBalAffinity", 10, test_balance_respects_affinity, nullptr);
236 tm.AddTask(std::move(t2));
237
238 constexpr int kExpectedTests = 2;
239 int timeout = 600;
240 while (timeout > 0) {
241 (void)sys_sleep(50);
242 if (g_tests_completed.load() >= kExpectedTests) {
243 break;
244 }
245 timeout--;
246 }
247
248 EXPECT_EQ(g_tests_completed.load(), kExpectedTests,
249 "All balance sub-tests completed");
250 EXPECT_EQ(g_tests_failed.load(), 0, "No balance sub-tests failed");
251
252 klog::Info("===== Balance System Test End =====");
253 return true;
254}

Callers

nothing calls this directly

Calls 3

InfoFunction · 0.85
sys_sleepFunction · 0.85
AddTaskMethod · 0.80

Tested by

no test coverage detected