| 72 | } |
| 73 | |
| 74 | void test_runtime_tracking(void*) { |
| 75 | klog::Info("=== Runtime Tracking Test ==="); |
| 76 | |
| 77 | auto* self = TaskManagerSingleton::instance().GetCurrentTask(); |
| 78 | uint64_t runtime_before = self->sched_info.total_runtime; |
| 79 | |
| 80 | // Busy-wait for at least 5 tick intervals to ensure total_runtime |
| 81 | // is incremented (1ms per tick at SIMPLEKERNEL_TICK=1000) |
| 82 | auto* sched_data = per_cpu::GetCurrentCore().sched_data; |
| 83 | uint64_t start_tick = sched_data->local_tick; |
| 84 | volatile uint64_t sink = 0; |
| 85 | while (sched_data->local_tick - start_tick < 5) { |
| 86 | sink = sink + 1; |
| 87 | } |
| 88 | (void)sink; |
| 89 | |
| 90 | uint64_t runtime_after = self->sched_info.total_runtime; |
| 91 | |
| 92 | if (runtime_after <= runtime_before) { |
| 93 | klog::Err( |
| 94 | "test_runtime_tracking: FAIL -- total_runtime did not increase " |
| 95 | "(before={}, after={})", |
| 96 | runtime_before, runtime_after); |
| 97 | g_tests_failed++; |
| 98 | } else { |
| 99 | klog::Info("Runtime Tracking Test: PASSED (before={}, after={}, delta={})", |
| 100 | runtime_before, runtime_after, runtime_after - runtime_before); |
| 101 | } |
| 102 | |
| 103 | g_tests_completed++; |
| 104 | sys_exit(0); |
| 105 | } |
| 106 | |
| 107 | } // namespace |
| 108 |
nothing calls this directly
no test coverage detected