Skip to content

Improve Linux test coverage in oshi-common - #3188

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:improve-linux-test-coverage
Apr 23, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:improve-linux-test-coverage

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

Description

Improves test coverage for Linux-specific driver and hardware classes in oshi-common. These tests run on the Linux CI runner and exercise real sysfs/procfs paths where possible, with @TempDir-based synthetic file trees for topology parsing.

Changes

SysfsTest — Extended beyond assertDoesNotThrow to verify actual return values (non-null, non-empty) for querySystemVendor, queryProductModel, queryBiosDescription, and queryBiosReleaseDate. On most Linux systems (including CI), these sysfs files are populated.

CpuInfoTest — Added tests for queryBoardInfo (verifies non-null quartet) and queryFeatureFlags (verifies flags are returned on x86 Linux from /proc/cpuinfo).

LinuxCentralProcessorTest — Added topology tests for:

  • NUMA node detection via node* directories
  • Multiple cache types (Instruction + Unified L2) in cache/index*

DmidecodeTest — Added test verifying queryBiosNameRev returns a non-null Pair.

WhoTest (new) — Tests the Who.queryWho() command-line parser. May return empty on headless CI but verifies no exceptions and valid session fields when present.

Testing

All 449 tests pass locally on Linux (Java 25). Spotless, checkstyle, and forbiddenapis all clean.

Summary by CodeRabbit

  • Tests
    • Expanded Linux test coverage: added processor topology and cache recognition checks, BIOS name/revision validation, real sysfs DMI reads, active user-session field validation, and CPU board/feature-flag checks. Tests are Linux-gated where appropriate and assert runtime behavior and non-null/expected results across varied environments.

- SysfsTest: verify actual return values (non-null, non-empty) for
  system vendor, product model, BIOS description, and release date
- CpuInfoTest: verify queryBoardInfo returns non-null quartet, test
  queryFeatureFlags returns flags on x86 Linux
- LinuxCentralProcessorTest: add topology tests for NUMA node detection
  and multiple cache types (Instruction + Unified)
- DmidecodeTest: verify queryBiosNameRev returns non-null pair
- WhoTest: new test for command-line who parser

Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Dan Widdis <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 23, 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: b0f3abab-f205-4c36-93c2-1c9d877c570c

📥 Commits

Reviewing files that changed from the base of the PR and between 0644273 and bd1ed40.

📒 Files selected for processing (4)
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/WhoTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/WhoTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.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, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, 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: Test JDK 11, macos-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.
📚 Learning: 2026-04-19T01:28:43.529Z
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:43.529Z
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-common/src/test/java/oshi/util/driver/linux/SysfsTest.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-common/src/test/java/oshi/util/driver/linux/SysfsTest.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-common/src/test/java/oshi/util/driver/linux/SysfsTest.java
📚 Learning: 2026-04-18T03:18:03.725Z
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:03.725Z
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-common/src/test/java/oshi/util/driver/linux/SysfsTest.java
🔇 Additional comments (1)
oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java (1)

36-46: LGTM.

The aggregate non-null assertion is a sensible strengthening over the prior assertDoesNotThrow-only coverage: it catches blanket regressions while tolerating individual sysfs attributes being absent on a given CI host. The comment clearly conveys intent, and the new is import is used.


📝 Walkthrough

Walkthrough

Adds Linux-only JUnit tests expanding runtime coverage for processor topology (NUMA and cache types), DMI/sysfs queries, CPU info (board and feature flags), and Who session parsing; several tests are gated with @EnabledOnOs(OS.LINUX).

Changes

Cohort / File(s) Summary
Linux Processor / Topology Tests
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
Adds two tests for readTopologyFromSysfs: one asserting LogicalProcessor.numaNode=3 when a non-zero node dir exists, and one asserting caches with types "Instruction" and "Unified" are both recognized.
Linux Driver Query Tests
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java, oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java, oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java
Gates tests to Linux and adds runtime assertions: Dmidecode.queryBiosNameRev() non-null pair, Sysfs real reads must not all be null, CpuInfo board info accessors callable and feature flags non-empty.
Linux Session Driver Tests
oshi-common/src/test/java/oshi/util/driver/linux/WhoTest.java
New Linux-only test class verifying Who.queryWho() returns non-null List<OSSession> and that each session's username and terminal device are non-null when present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

New Linux tests arrive at dawn, 🌅
NUMA nodes counted, caches drawn,
Sysfs and DMI take their cue,
Who reports sessions passing through,
Small asserts, big peace of mind. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% 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 clearly and concisely summarizes the main change: adding and improving Linux-specific test coverage in the oshi-common module.
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

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

@codecov

codecov Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.06%. Comparing base (5964a61) to head (bd1ed40).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3188      +/-   ##
==========================================
+ Coverage   57.91%   58.06%   +0.14%     
==========================================
  Files         421      421              
  Lines       20272    20272              
  Branches     3563     3563              
==========================================
+ Hits        11741    11770      +29     
+ Misses       6775     6742      -33     
- Partials     1756     1760       +4     
Flag Coverage Δ
linux 23.44% <ø> (+0.12%) ⬆️
macos 26.54% <ø> (-0.04%) ⬇️
windows 35.48% <ø> (+<0.01%) ⬆️

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

🧹 Nitpick comments (3)
oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java (2)

30-36: Assertion is tautological — consider asserting on the quartet contents instead.

Since queryBoardInfo() always constructs and returns a new Quartet<>(...) (never null), assertThat(info, is(notNullValue())) will always pass regardless of parsing behavior. The comment even acknowledges the fields are typically null on x86, so this test effectively only verifies that the method doesn't throw — which testQueries() already covers.

If you want this test to provide additional signal, consider asserting on the arity/shape you actually care about, e.g. that each getter is reachable without NPE, or drop it in favor of the existing assertDoesNotThrow coverage.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java`
around lines 30 - 36, The current test testQueryBoardInfoReturnsQuartet only
asserts the Quartet returned by CpuInfo.queryBoardInfo() is non-null
(tautological); replace or strengthen it by either removing the test (since
testQueries() already ensures no exception) or assert the quartet shape/arity by
invoking its accessors (e.g., info.getA(), info.getB(), info.getC(),
info.getD()) to ensure getters are reachable without NPE and/or assert expected
nullability patterns for your platform; update the test method name and
assertions accordingly so it verifies meaningful behavior of
CpuInfo.queryBoardInfo() and references Quartet and CpuInfo.queryBoardInfo()
explicitly.

38-43: Minor: queryFeatureFlags() returns whole lines, not individual flags.

Just a heads-up for future readers — queryFeatureFlags() returns the deduplicated full /proc/cpuinfo lines starting with flags/features (typically one entry on SMP x86), not a list of individual feature tokens. The assertion is still correct on x86 Linux CI, but the comment "/proc/cpuinfo should have a 'flags' line" is accurate while the test name hints at per-flag granularity. Consider renaming to something like testQueryFeatureFlagsLinePresent or splitting the line to assert on an individual well-known flag (e.g., fpu) for a stronger check on x86 runners.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java`
around lines 38 - 43, The test name/test intent is misleading because
CpuInfo.queryFeatureFlags() returns deduplicated full "/proc/cpuinfo" lines
(lines starting with "flags"/"features") rather than individual tokens; either
rename the test method testQueryFeatureFlags to testQueryFeatureFlagsLinePresent
(or similar) to reflect that it only verifies presence of a "flags" line, or
keep the name and change the assertion to split the returned line(s) on
whitespace and assert a known token (e.g., "fpu") is present; update references
to the test method name and the assertion logic around
CpuInfo.queryFeatureFlags() accordingly.
oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java (1)

38-70: Assertions are weaker than the PR description suggests.

The PR summary states these tests verify "actual return values (non-null, non-empty)", but each new test only asserts non-empty if the value happens to be non-null. On a CI runner where DMI is populated, a regression that starts returning null would silently pass. Since the Linux CI runner does have these sysfs files populated (as the comment on line 23-24 notes), consider asserting non-null directly for the queries that are reliably present on the CI image — or keep the null-tolerant check but also assert, e.g., that at least one of the four returns non-null, so a blanket regression is caught.

Not a blocker — happy to defer if the headless-CI variability is broader than I'm assuming.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java` around lines
38 - 70, The tests use conditional assertions that skip checks when the value is
null, so regressions returning null can pass on CI; update the tests for
Sysfs.querySystemVendor, Sysfs.queryProductModel, Sysfs.queryBiosDescription,
and Sysfs.queryBiosReleaseDate to assert non-null (and non-empty) directly on
the CI image, or alternatively keep per-method null-tolerant checks but add a
single aggregated assertion that at least one of the four query results is
non-null to catch blanket regressions; modify the existing test methods
(testQuerySystemVendorReturnsValue, testQueryProductModelReturnsValue,
testQueryBiosDescriptionReturnsValue, testQueryBiosReleaseDateFormat)
accordingly so they fail if expected sysfs values become null.
🤖 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-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java`:
- Around line 294-308: The test testReadTopologyFromSysfsWithNumaNode is
ineffective because getLogicalProcessorFromSyspath defaults nodeId to 0; change
the created NUMA directory from node0 to a non-zero id (e.g., node3) so
readTopologyFromSysfs actually parses a non-default value, then update the
assertion on result.getA().get(0).getNumaNode() to expect that non-zero id;
reference LinuxCentralProcessor.readTopologyFromSysfs and
getLogicalProcessorFromSyspath to locate the parsing logic and getNumaNode on
the LogicalProcessor to validate the parsed value.

In `@oshi-common/src/test/java/oshi/util/driver/linux/WhoTest.java`:
- Around line 23-33: Remove the tautological assertion in testQueryWho: the
assertion assertThat(sessions.size(), is(greaterThanOrEqualTo(0))) is always
true and redundant after asserting sessions is not null. Edit the testQueryWho
method to delete that size check and keep the null check and the loop assertions
over OSSession.getUserName() and OSSession.getTerminalDevice(); leave
Who.queryWho() usage unchanged.

---

Nitpick comments:
In `@oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java`:
- Around line 30-36: The current test testQueryBoardInfoReturnsQuartet only
asserts the Quartet returned by CpuInfo.queryBoardInfo() is non-null
(tautological); replace or strengthen it by either removing the test (since
testQueries() already ensures no exception) or assert the quartet shape/arity by
invoking its accessors (e.g., info.getA(), info.getB(), info.getC(),
info.getD()) to ensure getters are reachable without NPE and/or assert expected
nullability patterns for your platform; update the test method name and
assertions accordingly so it verifies meaningful behavior of
CpuInfo.queryBoardInfo() and references Quartet and CpuInfo.queryBoardInfo()
explicitly.
- Around line 38-43: The test name/test intent is misleading because
CpuInfo.queryFeatureFlags() returns deduplicated full "/proc/cpuinfo" lines
(lines starting with "flags"/"features") rather than individual tokens; either
rename the test method testQueryFeatureFlags to testQueryFeatureFlagsLinePresent
(or similar) to reflect that it only verifies presence of a "flags" line, or
keep the name and change the assertion to split the returned line(s) on
whitespace and assert a known token (e.g., "fpu") is present; update references
to the test method name and the assertion logic around
CpuInfo.queryFeatureFlags() accordingly.

In `@oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java`:
- Around line 38-70: The tests use conditional assertions that skip checks when
the value is null, so regressions returning null can pass on CI; update the
tests for Sysfs.querySystemVendor, Sysfs.queryProductModel,
Sysfs.queryBiosDescription, and Sysfs.queryBiosReleaseDate to assert non-null
(and non-empty) directly on the CI image, or alternatively keep per-method
null-tolerant checks but add a single aggregated assertion that at least one of
the four query results is non-null to catch blanket regressions; modify the
existing test methods (testQuerySystemVendorReturnsValue,
testQueryProductModelReturnsValue, testQueryBiosDescriptionReturnsValue,
testQueryBiosReleaseDateFormat) accordingly so they fail if expected sysfs
values become null.
🪄 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: 38996417-a411-4e32-872b-0d9a3eda0ce9

📥 Commits

Reviewing files that changed from the base of the PR and between 5964a61 and 0644273.

📒 Files selected for processing (5)
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/WhoTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.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). (11)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, ubuntu-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2026-04-18T03:18:03.725Z
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:03.725Z
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-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
📚 Learning: 2026-04-14T23:28:18.252Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3160
File: oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxSensorsTest.java:34-40
Timestamp: 2026-04-14T23:28:18.252Z
Learning: In oshi/oshi, `vcgencmd` (used in `LinuxSensors.queryCpuTemperatureFromVcGenCmd()` and related methods) is a Raspberry Pi-specific binary. It will never be present on standard x86/amd64 CI runners or developer machines. Tests that pass `isPi=true` to `LinuxSensors` and assert 0/empty returns are deterministic in practice; do not flag them as potentially flaky due to `vcgencmd` availability.

Applied to files:

  • oshi-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java
📚 Learning: 2026-04-19T01:28:43.529Z
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:43.529Z
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-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
  • oshi-common/src/test/java/oshi/util/driver/linux/SysfsTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.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-common/src/test/java/oshi/util/driver/linux/proc/CpuInfoTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java
📚 Learning: 2026-04-06T04:45:51.516Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:51.516Z
Learning: In the oshi/oshi project, the public API is strictly limited to interfaces and classes in the `oshi`, `oshi.hardware`, and `oshi.software.os` packages. All platform-specific code under subpackages like `oshi.software.os.linux`, `oshi.hardware.platform.linux`, etc., is considered implementation detail — not public API. Do not flag changes to platform-specific classes (e.g., making `LinuxOperatingSystem` abstract, narrowing constructor visibility, adding abstract methods) as public API breaks.

Applied to files:

  • oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java
🔇 Additional comments (2)
oshi-common/src/test/java/oshi/util/driver/linux/DmidecodeTest.java (1)

33-39: LGTM.

Explicit non-null assertion on the returned Pair is a nice complement to the assertDoesNotThrow check above; matches the documented contract in Dmidecode.queryBiosNameRev().

oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxCentralProcessorTest.java (1)

310-338: LGTM.

Nice coverage for the Instruction + Unified cache types exercising parseCacheType and ensuring distinct ProcessorCache entries are produced.

- Use non-zero NUMA node (node3) to verify parsing, not default
- Remove tautological size >= 0 assertion from WhoTest
- Strengthen CpuInfoTest: call quartet accessors, rename feature flags test
- Replace null-tolerant Sysfs tests with aggregate non-null assertion

Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Dan Widdis <[email protected]>
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