Repository navigation
NetBSD/OpenBSD: extract testable parse methods from command readers - #3496
Conversation
Extract inline command-output parsing into package-private static methods that accept List<String>, mirroring the pattern from #3494 (Linux) and #3495 (FreeBSD). This allows fixture-based tests to exercise the parse logic on every CI platform without requiring the target OS. Extractions: - BsdCentralProcessor: parseTopology, parseDmesgModelsAndCaches, parseCacheStr (shared by NetBSD + OpenBSD) - BsdGraphicsCard: parsePciDump (pcidump -v) - BsdSoundCard: parseDmesg (dmesg audio/pci) - BsdUsbDevice: parseUsbDevices (usbdevs -v) - NetBsdCentralProcessor: parseVmStats, parseFamilyModelStepping, parseCpTime - NetBsdFirmware: parseDmesg (bios0 vendor line) - OpenBsdCentralProcessor: parseVmStats, cpuidToFamilyModelStepping - OpenBsdFirmware: parseDmesg (bios0 vendor line)
|
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 (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📜 Recent review details⏰ Context from checks skipped due to timeout. (14)
📝 WalkthroughWalkthroughBSD hardware, processor, and firmware implementations now separate command execution from parsing helpers. Processor parsing reuses collected ChangesBSD parser refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 Additional details and impacted files@@ Coverage Diff @@
## master #3496 +/- ##
============================================
+ Coverage 75.77% 75.88% +0.10%
Complexity 76 76
============================================
Files 591 591
Lines 21651 21675 +24
Branches 3613 3614 +1
============================================
+ Hits 16406 16447 +41
+ Misses 3279 3265 -14
+ Partials 1966 1963 -3
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:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java (1)
42-77: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winVendor extraction truncates multi-word BIOS vendor names.
afterVendor.split("\\s+")[0]only keeps the first token aftervendor, so multi-word vendors (e.g."American Megatrends Inc.") would be truncated to just"American". Existing test fixtures only cover single-word vendors (LENOVO), masking this.See the consolidated comment (anchored on
OpenBsdFirmware.java) for a proposed shared fix covering both files.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java` around lines 42 - 77, Update parseDmesg in NetBsdFirmware so vendor extraction preserves the complete multi-word BIOS vendor name instead of taking only the first whitespace-delimited token. Reuse the shared extraction approach proposed for OpenBsdFirmware, while keeping version and release-date parsing unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.java`:
- Around line 42-77: Update parseDmesg in NetBsdFirmware so vendor extraction
preserves the complete multi-word BIOS vendor name instead of taking only the
first whitespace-delimited token. Reuse the shared extraction approach proposed
for OpenBsdFirmware, while keeping version and release-date parsing unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: dff280c1-9cbb-4f72-a608-7276a9756a67
📒 Files selected for processing (16)
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdFirmware.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdGraphicsCardTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdSoundCardTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdUsbDeviceTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmwareTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessorTest.javaoshi-common/src/test/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdFirmwareTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (10)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
- GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
- GitHub Check: Test JDK 26, macos-latest
- GitHub Check: Test JDK 26, windows-latest
- GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
- GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
- GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
- GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
- GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmware.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java
📚 Learning: 2026-04-12T19:34:56.879Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:34:56.879Z
Learning: In OSHI’s Java platform implementations, `PhysicalProcessor.getEfficiency()` / `EfficiencyClass` follow the same convention as Windows `PROCESSOR_RELATIONSHIP.EfficiencyClass`: a *higher* numeric efficiency class value represents *greater performance* and *less efficiency* (typically P-cores higher than E-cores). When reviewing, do not treat cases where P-cores are assigned higher efficiency/class values as a bug—this is intentional cross-platform consistency.
Applied to files:
oshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.javaoshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java
🔇 Additional comments (15)
oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdGraphicsCard.java (1)
39-48: LGTM!oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdGraphicsCardTest.java (1)
1-107: LGTM!oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdSoundCard.java (1)
42-52: LGTM!oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdSoundCardTest.java (1)
1-73: LGTM!oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdUsbDevice.java (1)
34-44: LGTM!Also applies to: 55-55
oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdUsbDeviceTest.java (1)
1-61: LGTM!oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdCentralProcessor.java (1)
56-166: LGTM!oshi-common/src/test/java/oshi/hardware/common/platform/unix/BsdCentralProcessorTest.java (1)
1-151: LGTM!oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessor.java (1)
37-65: LGTM!Also applies to: 79-123, 175-175
oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdCentralProcessorTest.java (1)
1-111: LGTM!oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdFirmwareTest.java (1)
1-54: LGTM!oshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessor.java (1)
90-98: LGTM!Also applies to: 108-130
oshi-common/src/test/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdCentralProcessorTest.java (1)
11-19: LGTM!Also applies to: 96-145
oshi-common/src/test/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdFirmwareTest.java (1)
22-33: LGTM! (assertion on line 30 will need updating once the vendor-parsing bug flagged onOpenBsdFirmware.javais fixed)oshi-common/src/main/java/oshi/hardware/common/platform/unix/openbsd/OpenBsdFirmware.java (1)
42-73: 🎯 Functional CorrectnessAdd tests to pin the expected vendor parsing behavior.
OpenBsdFirmware.java#L42-L73keeps the fullvendor ... version ... date ...tail, whileNetBsdFirmware.java#L42-L77truncates multi-word vendors to the first token. Lock down the intendeddmesgformat before changing the shared parsing logic.
Both NetBsd and OpenBsd parsers now extract the vendor substring between the "vendor" keyword and the " version " delimiter, correctly handling multi-word vendors like "American Megatrends Inc." or "Phoenix Technologies LTD". Falls back to first-token extraction if no " version " delimiter is present.
* Solaris: extract testable parse methods from command readers Extract inline command-output parsing into package-private static methods that accept List<String> (or String), mirroring the pattern from #3494 (Linux), #3495 (FreeBSD), and #3496 (NetBSD/OpenBSD). This allows fixture-based tests to exercise the parse logic on every CI platform without requiring Solaris/OpenIndiana. Extractions: - SolarisCentralProcessor: parseDmesgCpuInfo (dmesg), parseNumaNodes (lgrpinfo -c leaves), parseIsainfoFlags (isainfo -v), sumKstatLong (kstat -p cpu_stat) - SolarisComputerSystem: parseSmbios (smbios), parseSerialFromPrtconf (prtconf -pv chassis-sn) - SolarisGraphicsCard: parsePrtconf (prtconf -pv display class) - SolarisSoundCard: parseLshal (lshal audio810 driver) - SolarisVirtualMemory: parseSwapInfo (swap -lk), sumKstatLong (kstat -p cpu_stat:::pgswapin/pgswapout) - SolarisInternetProtocolStats: parseTcpStats and parseUdpStats (netstat -s -P tcp/udp/ip), splitOnPrefix made package-private * Use split("=", 2) in netstat parsers for mixed-prefix lines When tcpInErr is paired with a non-tcp stat on the same line (e.g. udpNoPorts), splitOnPrefix finds only one "tcp" occurrence, leaving the full remainder including a second "=" sign. Limiting split to 2 parts ensures the length check passes and getFirstIntValue extracts the correct value from the leading portion.
Summary
List<String>, mirroring the pattern from Extract testable parse methods from Linux /proc and command readers #3494 (Linux) and FreeBSD: quiet dmesg.boot read and extract testable command parsers #3495 (FreeBSD)Test plan
./mvnw clean install— 1137 tests, 0 failures)@EnabledOnOsgating on parse tests — they run on every platformSummary by CodeRabbit