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

Function test_fifo_ordering

tests/system_test/fifo_scheduler_test.cpp:67–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67auto test_fifo_ordering() -> bool {
68 klog::Info("Running test_fifo_ordering...");
69
70 FifoScheduler scheduler;
71 constexpr size_t kTaskCount = 10;
72 TaskControlBlock* tasks[kTaskCount];
73
74 // 初始化任务
75 for (size_t i = 0; i < kTaskCount; ++i) {
76 tasks[i] = new TaskControlBlock("Task", 10, nullptr, nullptr);
77 tasks[i]->fsm.Receive(MsgSchedule{});
78 scheduler.Enqueue(tasks[i]);
79 }
80
81 EXPECT_EQ(scheduler.GetQueueSize(), kTaskCount,
82 "Queue size should match task count");
83
84 // 验证严格的 FIFO 顺序
85 for (size_t i = 0; i < kTaskCount; ++i) {
86 auto* picked = scheduler.PickNext();
87 EXPECT_NE(picked, nullptr, "Picked task should not be nullptr");
88 EXPECT_EQ(picked, tasks[i], "Task should be picked in FIFO order");
89 }
90
91 EXPECT_TRUE(scheduler.IsEmpty(), "Scheduler should be empty after all picks");
92
93 // 清理内存
94 for (size_t i = 0; i < kTaskCount; ++i) {
95 delete tasks[i];
96 }
97
98 klog::Info("test_fifo_ordering passed");
99 return true;
100}
101
102auto test_fifo_dequeue() -> bool {
103 klog::Info("Running test_fifo_dequeue...");

Callers 1

fifo_scheduler_testFunction · 0.85

Calls 6

InfoFunction · 0.85
ReceiveMethod · 0.80
EnqueueMethod · 0.45
GetQueueSizeMethod · 0.45
PickNextMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected