Skip to content

Extract testable parse methods from FreeBSD and Solaris disk drivers - #3500

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:disk-driver-parse-extractions
Jul 20, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:disk-driver-parse-extractions

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Extract inline command-output parsing into package-private static methods in the FreeBSD and Solaris disk driver classes
  • Enables fixture-based tests that run on every CI platform without requiring the target OS
  • Covers 5 driver files with 7 new parse methods

Test plan

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of FreeBSD and Solaris disk, mount, partition, and device information parsing.
    • Corrected parsing workflows to consistently process command output and handle missing or incomplete data safely.
  • Tests

    • Added comprehensive coverage for typical output, empty results, malformed input, missing fields, filtering, and platform-specific edge cases.

Extract inline command-output parsing into package-private static
methods in the disk driver classes, enabling fixture-based tests that
run on every CI platform.

Extractions:
- GeomDiskList: parseGeomDiskList (geom disk list → model/serial/size)
- Mount: parseMountOutput (mount → partition-to-mountpoint map)
- Iostat: parsePartitionToMountMap (iostat -er/-ern correlation),
  parseDeviceStrings (iostat -Er → model/vendor/product/serial/size)
- Lshal: parseLshal (lshal → disk-to-major map)
- Prtvtoc: parsePrtvtoc (prtvtoc → partition list with tag/flag
  mapping)
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8f051079-8bc1-4f92-8096-8b60d7a82388

📥 Commits

Reviewing files that changed from the base of the PR and between 389f8a9 and 83a454c.

📒 Files selected for processing (10)
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/Mount.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Iostat.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Lshal.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Prtvtoc.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/GeomDiskListTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/MountTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/IostatTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/LshalTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/PrtvtocTest.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 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/driver/common/unix/solaris/disk/Lshal.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Prtvtoc.java
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/Mount.java
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Iostat.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/driver/common/unix/solaris/disk/Lshal.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Prtvtoc.java
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/Mount.java
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Iostat.java
🔇 Additional comments (11)
oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java (1)

34-43: LGTM!

oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/Mount.java (1)

8-8: LGTM!

Also applies to: 34-45

oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/GeomDiskListTest.java (1)

1-78: LGTM!

oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/MountTest.java (1)

1-49: LGTM!

oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Iostat.java (2)

57-70: LGTM!


95-106: LGTM!

oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Lshal.java (1)

33-42: LGTM!

oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Prtvtoc.java (1)

27-56: LGTM!

oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/IostatTest.java (1)

1-117: LGTM!

oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/LshalTest.java (1)

1-49: LGTM!

oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/PrtvtocTest.java (1)

1-163: LGTM!


📝 Walkthrough

Walkthrough

The change separates native command execution from FreeBSD and Solaris disk-output parsing by introducing package-private helpers, then adds JUnit coverage for typical, empty, incomplete, and filtered parser inputs.

Changes

Unix disk parser testability

Layer / File(s) Summary
FreeBSD parser extraction and validation
oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/*, oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/*
Disk geometry and mount queries delegate to parsing helpers, with tests covering normal output, ignored lines, empty input, and default values.
Solaris parser extraction
oshi-common/src/main/java/oshi/driver/common/unix/solaris/disk/Iostat.java, Lshal.java, Prtvtoc.java
Native command execution is kept in query methods while iostat, lshal, and prtvtoc helpers parse supplied output.
Solaris parser validation
oshi-common/src/test/java/oshi/driver/common/unix/solaris/disk/*Test.java
Tests cover metadata extraction, mapping rules, filtering, skipped partitions, incomplete headers, and empty input.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Poem

I’m a rabbit with parsers in sight,
Separating commands just right.
Maps bloom from each line,
Edge cases align,
And tests hop through the night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.43% 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 accurately summarizes the main refactor: extracting testable parsing methods from FreeBSD and Solaris disk drivers.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.39%. Comparing base (389f8a9) to head (83a454c).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3500      +/-   ##
============================================
+ Coverage     76.24%   76.39%   +0.14%     
  Complexity       76       76              
============================================
  Files           591      591              
  Lines         21693    21695       +2     
  Branches       3611     3611              
============================================
+ Hits          16540    16573      +33     
+ Misses         3202     3175      -27     
+ Partials       1951     1947       -4     
Flag Coverage Δ
freebsd 32.15% <63.63%> (+0.54%) ⬆️
linux 36.53% <45.45%> (+0.69%) ⬆️
macos 37.67% <45.45%> (+0.65%) ⬆️
openbsd 31.30% <45.45%> (+0.67%) ⬆️
solaris 32.73% <81.81%> (+0.31%) ⬆️
windows 45.61% <45.45%> (+0.68%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@dbwiddis
dbwiddis merged commit 7697ebc into oshi:master Jul 20, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the disk-driver-parse-extractions branch July 20, 2026 23:56
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