Repository navigation
Test the Windows legacy GetSystemTimes system-CPU-tick path (JNA and FFM) - #3464
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
📜 Recent review details⏰ Context from checks skipped due to timeout. (15)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-07-06T19:25:59.225ZApplied to files:
🔇 Additional comments (2)
📝 WalkthroughWalkthroughWindows CPU processor implementations now use an overridable legacy-counter selection method. JNA and FFM classes support subclassing, and Windows-only tests validate legacy tick values and totals against modern counters. ChangesWindows counter selection
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (40.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #3464 +/- ##
=============================================
- Coverage 74.95% 62.25% -12.71%
Complexity 76 76
=============================================
Files 587 587
Lines 21603 21604 +1
Branches 3611 3611
=============================================
- Hits 16192 13449 -2743
- Misses 3432 6524 +3092
+ Partials 1979 1631 -348
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…FFM) The USE_LEGACY_SYSTEM_COUNTERS=true path in querySystemCpuLoadTicks() reads idle/kernel/user times via GetSystemTimes (Kernel32 for JNA, Kernel32FFM for FFM) and was not exercised by any test. The IRQ/DPC half (querySystemCounters) is already compared JNA==FFM; this covers the remaining GetSystemTimes half. Because the flag is a static-final capture and the junit-platform plugin runs tests in-process (no per-class fork), a @BeforeAll config flip can't reliably force the path. Instead, follow the WindowsGlobalMemoryLegacyTest seam pattern: add an overridable useLegacySystemCounters() gate (returning the static flag), switch both twins to call it, and de-final the twins so a test can subclass and force the legacy path against the real system. Add one @EnabledOnOs(WINDOWS) test per backend that forces the legacy path and asserts the ticks are sane (non-negative, non-zero idle and user time) and that the legacy total is within a generous tolerance of the modern per-processor sum (both measure cumulative CPU time since boot). A rotted native GetSystemTimes or FILETIME read surfaces as all-zero ticks or a wildly inconsistent total rather than as a mere coverage number.
8488049 to
e04e300
Compare
Closes the last coverage gap from the CentralProcessor dedup arc: the Windows
USE_LEGACY_SYSTEM_COUNTERS=truepath.What
querySystemCpuLoadTicks()has a legacy branch that reads idle/kernel/user times viaGetSystemTimes(Kernel32for JNA,Kernel32FFMfor FFM). The IRQ/DPC half of that path (querySystemCounters) is already compared JNA==FFM, but theGetSystemTimeshalf — including how each backend interprets the rawFILETIME— had no test.The flag is a
static finalcapture, and the junit-platform plugin runs tests in-process (<executor>JAVA</executor>, no per-class fork), so a@BeforeAllconfig flip can't reliably force the path before the class loads. This follows the existingWindowsGlobalMemoryLegacyTestseam pattern instead:useLegacySystemCounters()gate (returns the static flag); both twins call it instead of the raw field.WindowsCentralProcessorJNA/FFMso a test can subclass and force the gate.@EnabledOnOs(WINDOWS)test per backend forces the legacy path and asserts the ticks are sane (non-negative, non-zero idle and user time) and that the legacy total is within a generous tolerance of the modern per-processor sum — both measure cumulative CPU time since boot. A rotted nativeGetSystemTimesor FILETIME read surfaces as all-zero ticks or a wildly inconsistent total.Running both backends closes the JNA==FFM parity transitively (each legacy ≈ its own modern, and the moderns are already compared equal).
Notes
No CHANGELOG — test-only plus an internal overridable seam; no behavior change. The assertions only run on the Windows CI runners; tolerances are kept generous since they can't be smoke-tested off-Windows.
Summary by CodeRabbit