Skip to content

Add missing WMI and perfmon driver comparison tests - #3213

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:add-missing-driver-comparison-tests
Apr 29, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:add-missing-driver-comparison-tests

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Add direct JNA vs FFM comparison tests for all Windows drivers that were missing coverage:

WmiComparisonTest:

  • Win32Process: queryCommandLines and queryProcesses (XP)
  • MSFTStorage: StoragePools, PhysicalDisks, VirtualDisks, StoragePoolToPhysicalDisk (added to existing testDiskDrivers)
  • LhmSensor: querySensors and queryGpuHardware
  • OhmSensor/OhmHardware: querySensorValue and queryHwIdentifier

PerfmonComparisonTest:

  • ThreadInformation: filtered queryThreadCounters(name, pid) overload

The OHM/LHM tests will return 0 results on CI (software not installed) but are present so developers can run them on hardware with those tools installed.

What was tested

  • spotless:apply — pass
  • checkstyle:check — 0 violations
  • install (compile + test + package) — pass
  • forbiddenapis:check — pass

Summary by CodeRabbit

  • Tests
    • Expanded comparison tests for system performance and hardware monitoring: added coverage for filtered thread-counter queries, process command-line and PID checks, sensor and GPU discovery, and extended storage subsystem queries (storage pools, physical/virtual disks, and their relationships).
    • Added parity and conditional equality checks across monitoring backends, including explicit COM initialization handling, conditional skips when handlers are unavailable, and helpers to scope queries to the current process.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 580edc15-50e3-4f22-b053-c26f5c3c8e55

📥 Commits

Reviewing files that changed from the base of the PR and between fbf5b54 and b471061.

📒 Files selected for processing (2)
  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:46.416Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:56:46.416Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:46.416Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-18T22:53:56.149Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:56.149Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:52:55.560Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:55.560Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-05T16:15:06.124Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java:95-97
Timestamp: 2026-04-05T16:15:06.124Z
Learning: In `LinuxLogicalVolumeGroupJNA.getLogicalVolumeGroups()` (oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java), `physicalVolumesMap.get(e.getKey())` in the final stream mapping cannot return null: both `logicalVolumesMap` and `physicalVolumesMap` are populated via `computeIfAbsent` inside the same conditional block (`!Util.isBlank(vgName) && !Util.isBlank(lvName)`), so every VG key in `logicalVolumesMap` is guaranteed to have a corresponding entry in `physicalVolumesMap`. Do not flag this `.get()` call as a potential null-return issue. The FFM version uses `getOrDefault` as extra defensiveness, not because null is possible here.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-18T23:21:43.993Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32LogicalDisk.java:44-46
Timestamp: 2026-04-18T23:21:43.993Z
Learning: In OSHI's `Win32LogicalDisk.buildWmiClassNameWithWhere` (oshi-common), the `nameToMatch` parameter is always internally controlled (e.g., a drive name from a prior WMI query result), not arbitrary user input. Do not flag missing WQL escape sequences (backslash, single-quote) as a bug — the project maintainer (dbwiddis) confirmed only the existing double-quote escaping is needed.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-06T22:30:07.083Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3122
File: oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java:215-234
Timestamp: 2026-04-06T22:30:07.083Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java`, the `found` flag in `getControllerIdByLocation` is intentionally set to `true` as soon as either `vendor-id` or `device-id` is found in a matching service's parent. This is a deliberate design choice: a partial match (one of the two IDs) is preferred over continuing to iterate, because iterating further risks pairing IDs from two different and potentially mismatched services. Do not flag this as a bug or suggest splitting into separate `foundVendor`/`foundProduct` flags.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-03-29T20:03:00.830Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3014
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PdhUtilFFM.java:87-89
Timestamp: 2026-03-29T20:03:00.830Z
Learning: In the OSHI FFM codebase (oshi-core-java25), all PDH/Kernel32/COM wrapper methods in classes like PdhFFM, Kernel32FFM, etc. declare `throws Throwable` solely as a compiler artifact of `MethodHandle.invokeExact`. They are native calls and do not throw Java checked exceptions in practice. The enclosing `getOpenFileDescriptors()` method in PdhUtilFFM already has an outer `catch (Throwable t)` that covers the entire method body including any `finally` blocks, so no exception-masking concern exists for cleanup calls like `PdhCloseQuery` in `finally`.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
🔇 Additional comments (5)
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java (1)

178-187: Good stability-focused parity assertion for filtered thread counters.

Using key-set equality plus empty/non-empty parity for instances is the right tradeoff for live perf data and should be much less flaky.

oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (4)

391-411: Nice improvement: PID-scoped Win32_Process comparisons are much more deterministic.

Scoping both JNA and FFM queries to the current PID makes this parity check significantly more reliable.


413-455: COM lifecycle handling in the OHM/LHM comparison tests looks solid.

The guarded init/uninit pattern with try/finally is clean, and count-parity assertions fit optional-driver availability well.


507-528: Great addition of missing MSFTStorage parity coverage.

These checks plug a real gap and integrate cleanly into the existing COM-managed disk-driver test flow.


558-562: Good defensive helper extraction for PID filtering.

Using an assumption before narrowing to int makes the test intent explicit and avoids misleading fallback behavior.


📝 Walkthrough

Walkthrough

Adds new JUnit comparison tests in oshi-benchmark that validate parity between JNA and FFM implementations for Perfmon thread-counter filtering and multiple WMI queries (process command-lines, XP processes, LHM/OHM sensors, GPU/hardware lists, and MSFTStorage datasets).

Changes

Cohort / File(s) Summary
Perfmon tests
oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
Adds testThreadCountersFiltered verifying queryThreadCounters(String, int) returns identical filtered counter-property key sets for JNA vs FFM and that both filtered instance lists are empty for the test inputs.
WMI tests — process & XP
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
Adds tests comparing Win32_Process command-line and XP-style process queries between JNA and FFM; asserts matching row counts and, when present, equality of first-row PID and command-line string.
WMI tests — sensors (LHM/OHM) & GPU
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
Adds LHM sensor list and GPU hardware parity checks (count-only) and OHM sensor/hardware tests that explicitly init/uninit COM, use Assumptions to skip when handlers are unavailable, and assert count parity for values and hardware IDs.
WMI tests — MSFTStorage
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
Extends COM-managed disk driver tests with MSFTStorage dataset comparisons (storage pools, physical disks, virtual disks, pool-to-physical-disk relationships) asserting equal result counts between JNA and FFM.
Helpers
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
Adds a private/static helper to filter queries by current PID with an Assumptions check ensuring PID fits in an int.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

New tests arrive to check the score,
JNA and FFM knock on the door.
Threads and WMI in tidy rows,
COM wakes up, the parity shows.
Green ticks, small cheers — the CI grows! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: adding comparison tests for Windows WMI and perfmon drivers that were previously untested.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.49%. Comparing base (75fdb0f) to head (b471061).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3213      +/-   ##
==========================================
+ Coverage   61.28%   61.49%   +0.21%     
==========================================
  Files         423      423              
  Lines       20371    20371              
  Branches     3572     3572              
==========================================
+ Hits        12484    12528      +44     
+ Misses       6104     6060      -44     
  Partials     1783     1783              
Flag Coverage Δ
linux 25.99% <ø> (-0.01%) ⬇️
macos 29.63% <ø> (+<0.01%) ⬆️
windows 39.65% <ø> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`:
- Line 186: The assertion comparing exact filtered thread instance lists is
flaky because snapshots are live; in PerfmonComparisonTest replace the strict
equality assertion on ffm.getA() vs jna.getA() with a volatility-tolerant check
(e.g., assert that both are empty or both non-empty by comparing
ffm.getA().isEmpty() to jna.getA().isEmpty(), or check only size parity) and
keep the existing key-set assertion on Line 185; update the assertion that
currently uses containsExactlyInAnyOrderElementsOf to a parity-based assertion
using ffm.getA() and jna.getA().

In `@oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`:
- Around line 389-406: The tests testWin32ProcessCommandLines and
testWin32ProcessXP are flaky because they call Win32_Process twice (via
Win32ProcessJNA.queryCommandLines/queryProcesses and
Win32ProcessFFM.queryCommandLines/queryProcesses) with a null filter and then
assume index 0 matches; fix by filtering both queries to the same stable PID
(e.g., current JVM PID) and compare the matching entry rather than index 0: call
Win32ProcessJNA.queryCommandLines(...) and
Win32ProcessFFM.queryCommandLines(...) (and the corresponding queryProcesses
methods) with a filter for the current PID and, when asserting field equality
(e.g., PROCESSID), locate the row for that PID in each WmiResult before
comparing values to avoid ordering/race issues.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e420694-9ef8-4ce0-959e-b1dcf595fafd

📥 Commits

Reviewing files that changed from the base of the PR and between 75fdb0f and 57c1f2a.

📒 Files selected for processing (2)
  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:56:46.416Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:46.416Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-18T22:53:56.149Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:56.149Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
🔇 Additional comments (3)
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (3)

408-421: Good optional-source handling for LHM coverage.

Line 410’s intent and the count-parity assertions in these two tests are a good fit for environments where LHM is absent or intermittently available.


423-450: Nice COM lifecycle hygiene in the OHM comparison test.

The explicit handler setup plus finally uninitialization keeps this test robust and avoids COM state leakage across tests.


502-523: Great addition of missing MSFTStorage parity checks.

These new assertions close the driver-comparison gap for storage pools/disks/relationships and align well with the existing count-based comparison style in this suite.

@dbwiddis
dbwiddis force-pushed the add-missing-driver-comparison-tests branch from 57c1f2a to fbf5b54 Compare April 29, 2026 00:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (1)

407-410: ⚠️ Potential issue | 🟠 Major

Keep the XP comparison on the same stable PID filter.

This still compares two live Win32_Process snapshots with null, so the result count can drift independently of driver correctness. Reuse the filtered current-PID path here as well.

🔧 Suggested fix
-        WmiResult<ProcessXPProperty> jna = Win32ProcessJNA.queryProcesses(null);
-        WbemcliUtilFFM.WmiResult<ProcessXPProperty> ffm = Win32ProcessFFM.queryProcesses(null);
-        assertWithinRatio(ffm.getResultCount(), jna.getResultCount(), 0.1, "Win32Process XP count");
+        long pid = ProcessHandle.current().pid();
+        Assumptions.assumeTrue(pid <= Integer.MAX_VALUE, "Current PID does not fit in the query filter");
+        Set<Integer> currentPid = Collections.singleton((int) pid);
+        WmiResult<ProcessXPProperty> jna = Win32ProcessJNA.queryProcesses(currentPid);
+        WbemcliUtilFFM.WmiResult<ProcessXPProperty> ffm = Win32ProcessFFM.queryProcesses(currentPid);
+        assertThat(ffm.getResultCount()).as("Win32Process XP count").isEqualTo(jna.getResultCount());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java` around
lines 407 - 410, The test testWin32ProcessXP currently queries live snapshots
with null filters causing result drift; change both
Win32ProcessJNA.queryProcesses(null) and Win32ProcessFFM.queryProcesses(null) to
use the same current-PID filter used elsewhere in this file (the filtered
current-PID path your other tests use) so both queries use an identical stable
PID filter instead of null; update the two calls in testWin32ProcessXP to pass
that filter object (the same variable or helper method used by the other
Win32Process tests).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`:
- Around line 393-395: Replace the silent fallback to PID 0 with a JUnit
assumption: in WmiComparisonTest, check the current process ID returned by
ProcessHandle.current().pid() with Assumptions.assumeTrue(pid <=
Integer.MAX_VALUE, "PID too large to fit in int") so the test is skipped when
the PID overflows; then build currentPid using (int) pid and pass it to
Win32ProcessJNA.queryCommandLines(...) instead of using 0. Ensure you import
org.junit.jupiter.api.Assumptions and update the currentPid construction
accordingly.

---

Duplicate comments:
In `@oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`:
- Around line 407-410: The test testWin32ProcessXP currently queries live
snapshots with null filters causing result drift; change both
Win32ProcessJNA.queryProcesses(null) and Win32ProcessFFM.queryProcesses(null) to
use the same current-PID filter used elsewhere in this file (the filtered
current-PID path your other tests use) so both queries use an identical stable
PID filter instead of null; update the two calls in testWin32ProcessXP to pass
that filter object (the same variable or helper method used by the other
Win32Process tests).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2c26ffe-5ab6-4c24-9dad-030f06079b41

📥 Commits

Reviewing files that changed from the base of the PR and between 57c1f2a and fbf5b54.

📒 Files selected for processing (2)
  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).
📚 Learning: 2026-04-18T03:18:06.205Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3170
File: oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java:177-183
Timestamp: 2026-04-18T03:18:06.205Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java`, GPU engine PDH instance counts (from `GpuInformationJNA.queryGpuEngineCounters()` / `GpuInformationFFM.queryGpuEngineCounters()`) are highly volatile — counts can differ dramatically (e.g., 53 vs 40) even between queries taken milliseconds apart. Do not assert instance count equality or exact instance list matching between JNA and FFM results. The only reliable assertion is that both are empty or both are non-empty (`assertThat(ffm.getA().isEmpty()).isEqualTo(jna.getA().isEmpty())`).

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-19T01:28:47.155Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3174
File: oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java:237-257
Timestamp: 2026-04-19T01:28:47.155Z
Learning: In `oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java`, the WMI comparison tests (e.g., `testProcessor`) intentionally validate only index 0 and a few representative fields per WMI data type (String, uint16, uint32, uint64). Exhaustive row-by-row comparison is deliberately avoided for numerically heavy multi-row tables. The design rationale is: matching row counts + a few selected fields covering each data type is sufficient to verify JNA vs FFM driver parity. Do not suggest looping over all rows for these tests.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:56:46.416Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java:287-298
Timestamp: 2026-04-17T23:56:46.416Z
Learning: In `oshi-core-java25/src/main/java/oshi/util/platform/windows/PerfDataUtilFFM.java`, the `queryWildcardCounters` method intentionally aborts and returns an empty Pair when any `addEnglishCounter` call fails. This is by design: the returned `Pair<List<String>, Map<T, List<Long>>>` requires strict parallel alignment between the instance list and each per-property value list. Aborting on failure preserves this alignment contract. This is different from `queryCounters` (non-wildcard), which gracefully skips individual failed counters since it returns a flat `Map<T, Long>` with no alignment constraint.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-15T04:56:18.352Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3163
File: oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java:97-103
Timestamp: 2026-04-15T04:56:18.352Z
Learning: In CoreFoundationTest.java (oshi-core-java25/src/test/java/oshi/ffm/mac/CoreFoundationTest.java), asserting exact CFGetRetainCount deltas (+1 after retain, -1 after release) is intentional and considered reliable for freshly created CF objects (e.g., CFStringRef via CFStringRef.createCFString) where the test holds sole ownership. Do not flag these assertions as flaky — the Apple "avoid CFGetRetainCount" advisory applies to shared/framework-managed objects, not exclusively owned objects in unit tests.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-17T23:52:55.560Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3168
File: oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java:47-58
Timestamp: 2026-04-17T23:52:55.560Z
Learning: In `oshi-common/src/main/java/oshi/driver/common/windows/perfmon/LoadAverage.java`, the `stopDaemon()` / `startDaemon()` lifecycle pattern (both `public synchronized` instance methods on the same monitor) is intentionally safe: `stopDaemon()` sets `loadAvgThread = null` immediately after `interrupt()`, and `startDaemon()` checks `loadAvgThread != null` under the same lock. Since both methods are synchronized on `this`, they cannot run concurrently, so no double-sampler race is possible. Do not flag this pattern as a race condition.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-18T22:53:56.149Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-core-java25/src/main/java/oshi/util/platform/windows/WmiQueryHandlerFFM.java:107-193
Timestamp: 2026-04-18T22:53:56.149Z
Learning: In OSHI's `WmiQueryHandlerFFM` (oshi-core-java25) and the JNA `WmiQueryHandler` (oshi-core), the `failedWmiClassNames` cache intentionally keys failures by WMI class name only (not namespace). This is a pre-existing, accepted pattern shared between both implementations. Do not flag this as a bug in future reviews — the project maintainer (dbwiddis) confirmed it does not impact callers and the added complexity of a composite namespace+class key is not warranted.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-05T05:39:21.126Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:39:21.126Z
Learning: In OSHI's Linux FFM/JNA udev code, a null guard on `udev_enumerate_new()` is unnecessary if `udev_new()` has already been guarded: per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` implies `udev_enumerate_new()` will succeed as well. Do not flag missing null checks on `udev_enumerate_new()` as an issue.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-05T16:15:06.124Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java:95-97
Timestamp: 2026-04-05T16:15:06.124Z
Learning: In `LinuxLogicalVolumeGroupJNA.getLogicalVolumeGroups()` (oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupJNA.java), `physicalVolumesMap.get(e.getKey())` in the final stream mapping cannot return null: both `logicalVolumesMap` and `physicalVolumesMap` are populated via `computeIfAbsent` inside the same conditional block (`!Util.isBlank(vgName) && !Util.isBlank(lvName)`), so every VG key in `logicalVolumesMap` is guaranteed to have a corresponding entry in `physicalVolumesMap`. Do not flag this `.get()` call as a potential null-return issue. The FFM version uses `getOrDefault` as extra defensiveness, not because null is possible here.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-05T05:40:45.797Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3117
File: oshi-core-java25/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java:62-65
Timestamp: 2026-04-05T05:40:45.797Z
Learning: In OSHI's Linux FFM and JNA udev code, a null guard on `udev_enumerate_new()` is intentionally absent and should not be flagged. This is consistent across all four FFM classes (LinuxPowerSourceFFM, LinuxHWDiskStoreFFM, LinuxLogicalVolumeGroupFFM, LinuxUsbDeviceFFM) and the JNA implementation (which also does not guard `enumerateNew()` for null). Per libudev semantics, `udev_enumerate_new()` only returns NULL when udev itself is broken (e.g. OOM), so a successful `udev_new()` (which is guarded) implies `udev_enumerate_new()` will succeed. Adding a null guard would be both redundant and inconsistent with the established pattern.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-10T22:44:36.786Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3136
File: oshi-core-java25/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java:46-53
Timestamp: 2026-04-10T22:44:36.786Z
Learning: In OSHI's `AuxvFFM.queryAuxv()` (oshi-core-java25/src/main/java/oshi/driver/linux/proc/AuxvFFM.java), the do-while loop is safe even when `/proc/self/auxv` cannot be read: `FileUtil.readAllBytesAsBuffer` returns an empty ByteBuffer on failure, and `FileUtil.readLongFromBuffer`/`readIntFromBuffer` return 0L when reading past the buffer limit. This 0L equals AT_NULL, causing the loop to exit immediately with an empty map, which triggers the `getconf`/hardcoded-default fallback in callers like `LinuxOperatingSystemFFM`. Do not flag this do-while loop or the static initializer that calls `AuxvFFM.queryAuxv()` as unsafe.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java
📚 Learning: 2026-04-18T23:21:43.993Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3173
File: oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32LogicalDisk.java:44-46
Timestamp: 2026-04-18T23:21:43.993Z
Learning: In OSHI's `Win32LogicalDisk.buildWmiClassNameWithWhere` (oshi-common), the `nameToMatch` parameter is always internally controlled (e.g., a drive name from a prior WMI query result), not arbitrary user input. Do not flag missing WQL escape sequences (backslash, single-quote) as a bug — the project maintainer (dbwiddis) confirmed only the existing double-quote escaping is needed.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-08T00:58:10.736Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3125
File: oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java:131-133
Timestamp: 2026-04-08T00:58:10.736Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceJNA.java` and `oshi-core-java25/src/main/java/oshi/hardware/platform/windows/WindowsPowerSourceFFM.java`, the `getPowerSources()` method intentionally returns a singleton list wrapping a single `getPowerSource("System Battery")` call, and the enumeration loop short-circuits after the first eligible battery pack. This matches the longstanding JNA behavior and is not a bug. A broader refactor to support zero-or-more batteries across both implementations is planned for a later date. Do not flag this as an issue.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
📚 Learning: 2026-04-06T22:30:07.083Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3122
File: oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java:215-234
Timestamp: 2026-04-06T22:30:07.083Z
Learning: In `oshi-core/src/main/java/oshi/hardware/platform/mac/MacUsbDeviceJNA.java`, the `found` flag in `getControllerIdByLocation` is intentionally set to `true` as soon as either `vendor-id` or `device-id` is found in a matching service's parent. This is a deliberate design choice: a partial match (one of the two IDs) is preferred over continuing to iterate, because iterating further risks pairing IDs from two different and potentially mismatched services. Do not flag this as a bug or suggest splitting into separate `foundVendor`/`foundProduct` flags.

Applied to files:

  • oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java
🔇 Additional comments (4)
oshi-benchmark/src/test/java/oshi/comparison/WmiComparisonTest.java (3)

413-426: LGTM — these optional-driver checks are scoped well.

Count parity is the right level here for LHM, since the software may simply not be installed on CI.


429-455: LGTM — COM lifetime is handled cleanly here.

The explicit finally cleanup keeps the handler state from leaking across the OHM queries.


475-528: LGTM — the MSFTStorage parity coverage fits the existing COM-managed block.

The new pool, disk, and association comparisons extend the current JNA/FFM pattern without adding extra lifecycle risk.

oshi-benchmark/src/test/java/oshi/comparison/PerfmonComparisonTest.java (1)

178-187: LGTM — this keeps the filtered thread test volatility-tolerant.

Key-set equality plus empty/non-empty parity avoids brittle instance matching while still checking JNA vs FFM shape.

- Win32Process: queryCommandLines and queryProcesses (XP)
- MSFTStorage: StoragePools, PhysicalDisks, VirtualDisks,
  StoragePoolToPhysicalDisk (added to existing testDiskDrivers)
- LhmSensor: querySensors and queryGpuHardware
- OhmSensor/OhmHardware: querySensorValue and queryHwIdentifier
- ThreadInformation: filtered queryThreadCounters overload
@dbwiddis
dbwiddis force-pushed the add-missing-driver-comparison-tests branch from fbf5b54 to b471061 Compare April 29, 2026 01:12
@dbwiddis
dbwiddis merged commit d29f225 into oshi:master Apr 29, 2026
15 of 16 checks passed
@dbwiddis
dbwiddis deleted the add-missing-driver-comparison-tests branch April 29, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant