Skip to content

AIX: extract testable parse methods from command readers - #3501

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:aix-parse-coverage
Jul 21, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:aix-parse-coverage

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Continues the parse-seam testability effort (after Linux #3494, FreeBSD #3495, NetBSD/OpenBSD #3496, Solaris #3497/#3498, FileSystem #3499, disk drivers #3500) with the AIX command readers. Each acquire-and-parse method keeps its acquisition and delegates to a package-private/static parse method taking the already-read input, so the parsing is unit-testable with synthetic fixtures instead of only on a live AIX host:

  • Uptime.parseUpTime(String), Who.parseBootTime(String)
  • Ls.parseDeviceMajorMinor(List<String>), Lssrad.parseNodesPackages(List<String>) (the latter no longer mutates its input to drop the header)
  • AixNetworkParams.parseDefaultGateway(List<String>)
  • AixComputerSystem.parseLsattr(lsattr, lsmcode) → LsattrStrings (now package-private with accessors)

Fixtures are grounded in the real uptime, who -b, ls -l /dev, lssrad -av, netstat -rnf inet, lsattr -El sys0, and lsmcode -c output documented in each source. The new parse tests run on every platform; the existing AIX-only live smoke tests keep their coverage via per-method @EnabledOnOs(OS.AIX).

Note on coverage

The AIX package is still JaCoCo-excluded (**/unix/aix/**), the same as NetBSD in #3496, so this lands as testability / regression-safety groundwork rather than an immediate coverage bump — un-excluding AIX is a separate follow-up (it needs its native/JNA paths measured, which the current CI aggregation doesn't do).

Testing

  • oshi-common full gate green: spotless, checkstyle, install + forbiddenapis, javadoc; clean full-reactor install green.
  • All six AIX test classes pass; parse tests exercise each extracted method on the local (macOS) run.

No CHANGELOG entry — test/coverage refactor with no user-observable behavior change.

Summary by CodeRabbit

  • Bug Fixes

    • Improved AIX hardware, network, device, processor-topology, uptime, and boot-time data parsing.
    • Increased resilience when command output is empty, incomplete, or formatted unexpectedly.
    • Improved detection of default network gateways and system identification details.
  • Tests

    • Added broader coverage for AIX parsing scenarios, including empty and malformed inputs.
    • Expanded validation of device identifiers, boot times, hardware metadata, processor ranges, and gateway detection.

Split data acquisition from parsing in the AIX drivers and HAL so the parsing
logic can be unit-tested with synthetic fixtures instead of only on a live AIX
host. Each public method keeps its acquisition (runNative/getFirstAnswer) and
delegates to a parse method taking the already-read input:

- driver Uptime.parseUpTime(String), Who.parseBootTime(String)
- driver Ls.parseDeviceMajorMinor(List), Lssrad.parseNodesPackages(List)
  (Lssrad no longer mutates the input list to drop the header)
- AixNetworkParams.parseDefaultGateway(List)
- AixComputerSystem.parseLsattr(lsattr, lsmcode) -> LsattrStrings (now
  package-private with accessors)

Fixtures are grounded in the real uptime, who -b, ls -l /dev, lssrad -av,
netstat -rnf, lsattr -El sys0, and lsmcode -c output. The parse tests run on
every platform; the existing AIX-only live smoke tests keep their coverage via
per-method @EnabledOnOs(AIX). Note the AIX package is still JaCoCo-excluded, so
this is testability groundwork ahead of a future coverage-exclusion revisit.
@coderabbitai

coderabbitai Bot commented Jul 21, 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: cd4672b6-9ddd-4a09-b678-b69396fcbbe7

📥 Commits

Reviewing files that changed from the base of the PR and between 7697ebc and 28d4db3.

📒 Files selected for processing (11)
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Ls.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Lssrad.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Uptime.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixComputerSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixNetworkParams.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/LsDevicesTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/LssradTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/aix/AixComputerSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixNetworkParamsTest.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (13)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
🧰 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/software/common/os/unix/aix/AixNetworkParams.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Lssrad.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Ls.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Uptime.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixComputerSystem.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/software/common/os/unix/aix/AixNetworkParams.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Lssrad.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Ls.java
  • oshi-common/src/main/java/oshi/driver/common/unix/aix/Uptime.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixComputerSystem.java
🔇 Additional comments (11)
oshi-common/src/main/java/oshi/driver/common/unix/aix/Ls.java (1)

8-8: LGTM!

Also applies to: 31-48

oshi-common/src/test/java/oshi/driver/common/unix/aix/LsDevicesTest.java (1)

10-17: LGTM!

Also applies to: 29-52

oshi-common/src/main/java/oshi/driver/common/unix/aix/Lssrad.java (1)

44-45: LGTM!

Also applies to: 53-63

oshi-common/src/test/java/oshi/driver/common/unix/aix/LssradTest.java (1)

9-13: LGTM!

Also applies to: 22-57

oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixComputerSystem.java (1)

66-136: LGTM!

Also applies to: 138-138, 159-186

oshi-common/src/test/java/oshi/hardware/common/platform/unix/aix/AixComputerSystemTest.java (1)

1-58: LGTM!

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixNetworkParams.java (1)

7-8: LGTM!

Also applies to: 36-46

oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixNetworkParamsTest.java (1)

1-43: LGTM!

oshi-common/src/main/java/oshi/driver/common/unix/aix/Uptime.java (1)

39-47: LGTM!

Also applies to: 49-56

oshi-common/src/main/java/oshi/driver/common/unix/aix/Who.java (1)

43-52: LGTM!

oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java (1)

10-23: LGTM!

Also applies to: 25-35, 37-50, 52-53


📝 Walkthrough

Walkthrough

AIX command parsers now accept captured command output, while query methods execute commands and delegate parsing. SRAD header handling, boot-time parsing, accessible computer-system fields, and direct parser tests were added or expanded.

Changes

AIX parser refactor

Layer / File(s) Summary
Device and topology parser inputs
oshi-common/src/main/java/oshi/driver/common/unix/aix/Ls.java, .../Lssrad.java, oshi-common/src/test/java/oshi/driver/common/unix/aix/*Test.java
Device and SRAD parsers consume supplied output lists, with SRAD header handling and expanded empty, continuation, and value assertions.
System and network parser inputs
oshi-common/src/main/java/oshi/hardware/common/platform/unix/aix/AixComputerSystem.java, oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixNetworkParams.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/aix/AixComputerSystemTest.java, oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixNetworkParamsTest.java
Computer-system and gateway parsing consume provided command output; parsed system fields are exposed through package accessors and covered with fixture and fallback tests.
Uptime and boot-time parser entry points
oshi-common/src/main/java/oshi/driver/common/unix/aix/Uptime.java, .../Who.java, oshi-common/src/test/java/oshi/driver/common/unix/aix/UptimeAndBootTimeTest.java
Boot-time parsing is delegated to a dedicated parser, uptime structure is adjusted without logic changes, and direct parsing tests cover valid and invalid inputs.

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

Poem

I’m a rabbit with a parser’s ear,
Catching command lines crisp and clear.
Headers hop, gateways gleam,
Boot times bloom from a tested stream.
Tests nibble bugs away—
AIX paths are neat today!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% 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 summarizes the core change: extracting testable parse methods from AIX command readers.
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 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.42%. Comparing base (7697ebc) to head (28d4db3).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3501      +/-   ##
============================================
+ Coverage     71.83%   76.42%   +4.58%     
  Complexity       76       76              
============================================
  Files           591      591              
  Lines         21695    21695              
  Branches       3611     3611              
============================================
+ Hits          15585    16580     +995     
+ Misses         4314     3170    -1144     
- Partials       1796     1945     +149     
Flag Coverage Δ
freebsd 32.16% <ø> (+<0.01%) ⬆️
linux 36.53% <ø> (ø)
macos 37.67% <ø> (-0.05%) ⬇️
openbsd 31.31% <ø> (-0.01%) ⬇️
solaris 32.75% <ø> (?)
windows 45.61% <ø> (-0.02%) ⬇️

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 85d7b98 into oshi:master Jul 21, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the aix-parse-coverage branch July 21, 2026 01:11
dbwiddis added a commit that referenced this pull request Jul 21, 2026
* Extract more testable parse methods from AIX command readers

Second batch of AIX parse-seam extractions (after #3501), splitting acquisition
from parsing so the parsing is unit-testable with synthetic fixtures:

- Lspv: parsePpSize(List) + parsePartitions(List, ppSize, majMinMap), splitting
  the two-command computeLogicalVolumes
- Lscfg.parseModelSerial(List, device)
- AixCentralProcessor: parseProcessorId(prtconf) -> Quartet, parseCurrentFreq
  (pmcycles), parseSbits(proc.h), cachesForPowerVersion(version, cores)
- AixOperatingSystem.parseServices(lssrc) (no longer mutates the input list to
  drop the header)
- AixFileSystem.parseOpenFileDescriptors(lsof) + parseMaxFileDescriptorsPerProcess

Fixtures are grounded in the real lspv -L/-p, lscfg -vl, prtconf, pmcycles -m,
proc.h, lssrc -a, lsof -nl, and /etc/security/limits output. As with #3501 the
AIX package is still JaCoCo-excluded, so this is testability groundwork; the
existing @EnabledOnOs(AIX) live smoke tests are unaffected.

* Guard AIX prtconf and lscfg parsers against short/empty splits

Address CodeRabbit review on the AIX parse extraction:

- AixCentralProcessor.parseProcessorId: replace split(marker)[1] with
  substring(marker.length()) after the existing startsWith checks, so a bare
  marker line with no value (e.g. "Processor Type:") no longer throws
  ArrayIndexOutOfBounds.
- Lscfg.parseModelSerial: check the split length before indexing [1], so a line
  ending in the device name (which splits to a single element) skips the
  description fallback instead of throwing.

Both paths are covered by new fixture tests. Behavior is otherwise unchanged.

* Locate the lscfg device name literally instead of via split

Follow-up to the earlier split-length guard: use indexOf/substring with the
literal device name in Lscfg.parseModelSerial. split(device) treats the device
as a regex and needs a length guard for a trailing-token line; indexOf/substring
is clearer and handles the end-of-line case directly (empty remainder -> no
model). Behavior is unchanged; covered by the existing fixture tests.
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