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

Function test_rr_hooks

tests/system_test/rr_scheduler_test.cpp:334–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334auto test_rr_hooks() -> bool {
335 klog::Info("Running test_rr_hooks...");
336
337 RoundRobinScheduler scheduler;
338
339 TaskControlBlock task1("Task1", 1, nullptr, nullptr);
340 task1.fsm.Receive(MsgSchedule{});
341 task1.sched_info.priority = 5;
342
343 // 测试各种钩子函数不会崩溃
344 scheduler.OnScheduled(&task1);
345 scheduler.OnPreempted(&task1);
346 scheduler.BoostPriority(&task1, 10);
347 scheduler.RestorePriority(&task1);
348
349 // OnTick 应返回 false(RR 使用时间片而非 tick 计数)
350 bool need_resched = scheduler.OnTick(&task1);
351 EXPECT_EQ(need_resched, false, "OnTick should return false for RR");
352
353 // OnTimeSliceExpired 应返回 true(需要重新入队)
354 bool need_requeue = scheduler.OnTimeSliceExpired(&task1);
355 EXPECT_EQ(need_requeue, true, "OnTimeSliceExpired should return true for RR");
356
357 // 验证调度器仍正常工作
358 scheduler.Enqueue(&task1);
359 auto* picked = scheduler.PickNext();
360 EXPECT_EQ(picked, &task1, "Scheduler should still work after hook calls");
361
362 klog::Info("test_rr_hooks passed");
363 return true;
364}
365
366auto test_rr_robustness() -> bool {
367 klog::Info("Running test_rr_robustness...");

Callers 1

rr_scheduler_testFunction · 0.85

Calls 10

InfoFunction · 0.85
ReceiveMethod · 0.80
BoostPriorityMethod · 0.80
RestorePriorityMethod · 0.80
OnScheduledMethod · 0.45
OnPreemptedMethod · 0.45
OnTickMethod · 0.45
OnTimeSliceExpiredMethod · 0.45
EnqueueMethod · 0.45
PickNextMethod · 0.45

Tested by

no test coverage detected