Skip to content

test: cover the edge cases the suite was missing#129

Merged
VijitSingh97 merged 1 commit into
developfrom
claude/silly-liskov-95e9de
Jul 1, 2026
Merged

test: cover the edge cases the suite was missing#129
VijitSingh97 merged 1 commit into
developfrom
claude/silly-liskov-95e9de

Conversation

@VijitSingh97

Copy link
Copy Markdown
Contributor

What this is

A coverage-gap pass over the suite: an audit found behaviours, branches, and degenerate inputs in rigforge.sh that no test exercised, and this fills them. ~58 new assertions, tests/run.sh only — no new files, SHELL_FILES unchanged.

Every addition lands at the layer tests/README.md prescribes: logic / config-gen / command behaviour, driven by PATH stubs, hardware-independent, bash-3.2-safe. Each is the lowest layer that proves the behaviour honestly — nothing here needed a new /etc effect, macOS-native tool, or real hardware beyond what the existing layers already cover. Each test fails if the logic breaks (e.g. the commit-mismatch test asserts the clone directory is gone, not just that the error prints; the reboot-gate test asserts start/restart are absent from the systemctl call log).

Behaviours now covered

Area Gap closed
check_prerequisites The entire jq-bootstrap was untested: apt / dnf / pacman / no-manager / brew / no-brew / already-present
install_dependencies dnf + pacman branches (right command, distro-appropriate package); no-manager warn-not-abort; the apt-cache-present linux-tools-<rel> branch
install_service (#audit A2) Reboot pending → enable but NOT start (would run degraded under Restart=always); restart on rebuild; start on steady state; CPUPOWER_PATH resolved in ExecStartPre
compile_xmrig (#18) Commit mismatch drops the clone (rm -rf xmrig) so the next run starts clean
config-gen Bracketed-IPv6 url round-trips unmangled; single-pool tls:true reaches config.json; empty ACCESS_TOKEN → JSON null
restore Corrupt / config-less archive fails and leaves the existing config.json untouched (no silent clobber)
uninstall Without --yes, answering n aborts cleanly and reverts nothing
macOS mac_start no-worker guard ("run setup first"); mac_stop launchd-owned delegation
tune numerics _median/_stddev/_mean on empty & single sample; _watts_from_energy backwards counter with no wrap-max → empty (not negative); no-power fallback in _accept_better and _autotune_score
kernel/limits compute_build_jobs sub-2GB max<1→1 floor; 1G fstab line on a fresh write; the rest of the xmrig.service hardening block

Residual gaps (deliberately NOT in this PR — the real completeness note)

These are gaps a stub can't honestly close; recording them rather than pretending they're covered:

  • Post-GRUB-reboot autostart — CI now proves the decision (reboot pending → enable, withhold start). That systemd actually starts the miner after the reboot can't be proven by any runner; it's a manual release-gate observation (e2e-real confirms the enabled-but-stopped state; the across-reboot start is a human check).
  • dnf / pacman on real hardware — the new tests prove dispatch (right command, distro-appropriate package). RigForge's real-hardware gate and CI are both Ubuntu, so a package-name drift on Fedora/Arch would be caught by no layer. Acceptable given the documented Ubuntu target, but named, not assumed-covered.
  • Runtime vm.nr_hugepages value wiring — the reserved count is still proven only by proposed-grub.sh's isolated math; the sysctl stub swallows -w. The actual reservation is proven by e2e-real on real hardware. A CI logging-sysctl assert would only re-derive the math without proving anything new, so it's intentionally left to the release gate.
  • tune_kernel /etc/modules MSR fallback content — the primary modules-load.d path is covered in-container; the fallback (systems without modules-load.d) is asserted only via the uninstall pre-seed. Low-value residual gap.

Bugs

None. Every branch exercised behaves correctly — the suite passing against previously-untested paths is itself the evidence. This PR adds coverage, it does not change rigforge.sh.

Verification

  • make lint — clean (shellcheck + shfmt)
  • make test — 666/666 local
  • make coverage91.60% total (rigforge.sh 91.45%, util 96.15%) vs floor 80; kcov ran the full suite (689 checks). Patch-coverage gate is N/A — the change touches only tests/run.sh, so there are zero changed lines in the instrumented rigforge.sh/util.
  • Real hardware: suite passes 689/689 on a live Ubuntu 24.04 / bash 5.2 rig (miner-0) — validation was fully stubbed, so the running miner was never disturbed and the rig was left as found.

🤖 Generated with Claude Code

Adds ~58 assertions for previously-untested branches and degenerate
inputs, all at the run.sh layer (stub-driven, hardware-independent,
bash 3.2-safe) per tests/README.md — no new files, SHELL_FILES unchanged.

Behaviours now covered:
- check_prerequisites: the whole jq-bootstrap (apt/dnf/pacman/none/brew/
  no-brew/already-present) — was entirely untested
- install_dependencies: the dnf and pacman branches + the no-manager
  warn-not-abort path + the apt-cache-present linux-tools branch
- install_service reboot-gate (#audit A2): enable-but-NOT-start when a
  reboot is pending, restart on rebuild, start on steady state, plus
  CPUPOWER_PATH substitution in ExecStartPre
- compile_xmrig drops the clone (rm -rf) on a commit mismatch (#18)
- config-gen round-trips: bracketed IPv6 url, single-pool tls, empty
  ACCESS_TOKEN -> JSON null
- restore of a corrupt / config-less archive: fails AND leaves the
  existing config.json untouched (no silent clobber)
- uninstall without --yes aborts cleanly on 'n' and reverts nothing
- mac_start guard (no built worker -> "run setup first"); mac_stop
  launchd-owned delegation
- numeric degenerate inputs: _median/_stddev/_mean on empty/single
  sample; _watts_from_energy backwards counter w/ no wrap-max; the
  no-power efficiency fallbacks in _accept_better and _autotune_score
- compute_build_jobs sub-2GB floor; the 1G fstab line on a fresh write;
  the rest of the xmrig.service hardening block

Verified: make lint clean; make test 664/664; make coverage 91.34%
(floor 80); suite passes 687/687 on a real Ubuntu 24.04 / bash 5.2 rig.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@VijitSingh97 VijitSingh97 merged commit 04fc17a into develop Jul 1, 2026
9 checks passed
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