Skip to content

Latest commit

 

History

History
310 lines (273 loc) · 33.2 KB

README.md

File metadata and controls

310 lines (273 loc) · 33.2 KB

RigForge tests

RigForge has a Bash entrypoint and bundled helpers; its tests are layered by how much they exercise for real, from a dependency-free suite that runs anywhere up to a real-hardware gate that actually compiles XMRig and mines. Each layer covers what the one below it has to stub. make test-suite requires the suite-liveness regression, the Bash suite and the Python-dependent contract credential regression, plus access-token readiness, release clone-pin and Dependabot pin-coverage, CodeQL workflow and workflow-contract regressions. The Bash suite also runs the Python thread-profile regression for supported XMRig profiles, caps on both sides of auto-selection, higher tuned values and failed-snapshot recovery. The Bash suite exits nonzero if it aborts before its final rigforge tests: ... passed, ... failed summary, even when the shell would otherwise return zero. Worker proof schema/join and dispatcher regressions also run in make test-suite; see ordered worker proof receipts for the retained phase inventory, binding contract and binding requirements. The kcov container measures the Bash suite only; the credential regression always runs in the GitHub Test suite job, including argument inspection, password rotation and EXIT restoration.

The offline test-coverage-cache.sh regression also runs in make test-suite. Coverage caches only the pinned jq download, keyed by release, Linux architecture and SHA256. Every invocation copies it into private disposable storage and verifies the checksum before use; the container mounts that verified copy read-only. A corrupt entry fails before coverage runs; remove the invalid entry from .coverage-cache and retry. Downloads publish atomically only after verification, and cache hits need no writable cache. Old reports are cleared even when setup fails. Each run records the real checkout commit in coverage/source-commit.txt and input identities in coverage/source-files.sha256 before executing the suite. Each sorted row records type, SHA256 and a shell-escaped relative name; regular files distinguish executable status, symlinks hash the link target plus its terminating newline without following it, and missing tracked files record absent. Tracked and non-ignored untracked inputs are included; generated coverage, download caches and other ignored files are excluded. These identify local edits as well as the commit, not a successful test result. Coverage therefore requires a Git checkout. The jq setup log records hit/miss, total setup seconds and checksum verification seconds; these are whole-second observations, so zero means less than one clock interval, not free work.

No shared hosted cache is enabled. Profile setup misses before adding archive, wheel or image-layer reuse; untrusted pull requests must never publish trusted cache entries. Preserve fresh writable fixtures, exact candidate revisions and every existing per-PR assertion when comparing cold/warm runs. Stock-home installs, real package acquisition, historical negative controls, compilation, donation/release builds and hardware cold starts remain fresh at their current gates. Never reuse a miner, populated build tree, report or previous PASS as proof for another candidate. Before adoption, compare complete assertion/input/platform manifests and collect a week of setup/verification time, CI median/p90, failures and occupied hours; missing evidence leaves acceptance open.

The split exists so CI proves everything it can on a hosted CI machine, while the things it physically can't do (compile XMRig, reserve HugePages, write MSRs, set the governor, hash) are proven once, by hand, on a real rig before tagging a release.

The layers

Layer File Runs What it proves How to run
Unit + black-box suite run.sh + test-contract-credentials.sh Any host (macOS/Linux), no Docker; credential regression needs Python 3. In CI. Config parsing, the XMRig-config generation matrix (every CPU/OS profile, simulated via PATH stubs), GRUB/HugePages math, the command surface, tune search, doctor: everything that doesn't need a real /etc or real hardware. The bulk of coverage. make test (lint + suite) or make test-suite
Linux container e2e e2e/linux.sh → e2e/in-container.sh Disposable Ubuntu container, needs Docker. In CI. The genuine Linux deploy path against a real (throwaway) /etc with real GNU tools (sed -i, tee, envsubst) + idempotency on re-run. Only the heavy/privileged bits (compile, package install, systemctl/mount) are stubbed. A second pass re-runs the container with RIGFORGE_APPLIANCE=1 (#348) and proves the appliance contracts on that real /etc: units land in /run/systemd/system, no package installs, no fstab/limits.conf/logrotate writes, every enable carries --runtime. A third script, e2e/isolation.sh (#668), puts the rig on a Docker --internal network whose only reachable peer is a SOCKS5 proxy fronting a stand-in GitHub (a TLS git smart-HTTP server plus the releases API). With tor_socks5 set it runs upgrade --check, setup, a local upgrade with an XMRig pin change and the control-upgrade oneshot in its own empty environment, and proves from the proxy's log that every connection named a hostname. It also proves the block is real (a direct connection and a keyless upgrade --check fail), that an unreachable proxy fails closed without reaching the upstream, and that the live build survives the failed upgrade. make test-e2e
Native macOS e2e e2e/macos.sh A real Mac, manual, local only. Not in CI (macOS is best effort). The macOS deploy path with genuine BSD tools the Linux CI can only stub: BSD sed, the macOS config profile, mac_* process control (real nohup + PID file), the launchd login agent, backup/restore. make test-e2e-macos
Coverage gate coverage.sh kcov in Docker. In CI. Line coverage of rigforge.sh and its shell helpers by running run.sh under kcov; enforces the committed floor (coverage-floor.txt) plus a patch-coverage gate (diff-cover) on changed lines. make coverage
Package upgrade test-package-upgrade.sh Any host, no Docker. In CI (make test-suite). ../packaging/debian/postinst creates the state dir, reloads systemd and prints the first-run step on a first install, and queues only on a greater version with a config, never failing dpkg; prerm stops and disables only the units the package rendered, on remove only and postrm accepts every dpkg action and on purge deletes config, state, control state, every rendered unit, timer and path, the firewall rules and logrotate rule, and keeps an xmrig.service the package did not render; package-upgrade re-renders units and clears the marker on success, and on failure keeps it, records it for status/doctor and does not restart. bash tests/test-package-upgrade.sh
Debian package build test-build-deb.sh Linux with dpkg-deb, no Docker. In CI (make test-suite). ../scripts/build-deb.sh builds a byte-reproducible .deb from the release bundle with the marker where util/package-mode.sh reads it, the packaging/debian maintainer scripts and upgrade unit, the full Depends, and no apt keyring. bash tests/test-build-deb.sh
Debian package install test-deb-install.sh Clean ubuntu:24.04 container, needs Docker. In CI (make test-e2e). apt install of the built .deb, rigforge --version, doctor, an upgrade to the next version, with config in /var/lib/rigforge and nothing written under /usr/lib/rigforge, a direct rigforge.sh run using the package layout, an upgrade that queues the package upgrade, then remove keeps config, state and units and purge removes them. bash tests/test-deb-install.sh
APT feed test-apt-feed.sh Ubuntu 24.04, root, no Docker (needs apt-utils). In CI. (ci.yml job) ../scripts/build-apt.sh end to end with throwaway keys: refusal of missing/bad fingerprints and keyrings without the secret key; a signed flat feed that apt-get update and download accept from file://; refusal of tampered Release/InRelease/.deb and of a feed signed by another key. CI only (sudo bash tests/test-apt-feed.sh)
Release smoke (quick) smoke.sh Real Linux rig, manual. Not in CI. The compiled binary actually starts and hashes (xmrig --bench, fully offline). Fast pre-tag confidence that the worker we ship runs. make smoke
Release e2e (full) e2e-real.sh Real Linux rig, manual, root. Not in CI. The real thing end to end: build + tune + kernel tuning + service + a real hash, the writable control path (#236) against real systemd (control phase), the remote-upgrade chain with real git as the root oneshot (upgrade phase, #322), then a clean uninstall. The release gate. make e2e-real (see RELEASING.md)
Release e2e (worker↔stack) e2e-pithead.sh (control phase, access-tokens phase, selftest phase, xmrig overlay rows) Real rig + a live Pithead stack, manual, root. Not in CI. The integration contract: the network phase first waits up to 30 s (wall clock, logged as summary-settle) for the sister API's cached snapshot (refreshed every 15 s) to leave its xmrig_api: unreachable fallback after the restarts its config changes cause (#563), then records fixed boolean summary diagnostics (network-summary) before enforcing metadata and the XMRig key superset, without logging response bodies or key names; network-sequence reproduces the nightly connect → worker-api → api-impact → network prefix in one process/snapshot and stops there (separate phase submissions restore between phases); mining round-trip against the stack, the xmrig config overlay merged into the generated config by an apply that restarts the unit, the mining feed carrying the overlay and removal restoring the config (#526), the :8080 API posture (open/token/restricted), the writable control path's DONATION apply round trip (#344/#509), a named ACCESS_TOKENS entry authenticating :8081/:8082 while staying refused on :8080 and after revocation (#516); setup/revocation wait up to 30 s per listener for a bearer-free GET to return HTTP 401, recording elapsed time or sanitized curl/HTTP/unit diagnostics (#573), then separately require the revoked bearer to receive HTTP 401, stratum auth accept/reject + rotation against only PITHEAD_URL (a temporary plain-Stratum pool preserves the primary user, replaces endpoint-specific settings and removes all fallbacks; URL/password enter jq through stdin with constant programs; EXIT restores the original config bytes and runtime even on failure; explicit stratum-auth fails with a sanitized missing diagnostic when E2E_STRATUM_PASS is absent; all retains its optional skip), dashboard visibility/drop-off, a missing-minimum-marker upgrade that compiles the candidate miner, verifies fresh compiler/linker output, its zero compiled minimum and reported donation, then proves reductions 1 → 0 and 5 → 2 preserve that new binary; the phase restores the original build, markers, configs and service state even on failure; thread-profile observes XMRig’s actual /2/backends CPU thread array with no cap, a cap below and above auto-selection, and tuned values above and below auto-selection, requiring at least two auto-selected threads and restoring the original tuning overrides and config on exit, and the sister-API hashrate-impact guard (#99 must not shave H/s under polling load). The explicit selftest phase, outside all, runs the real bench and requires a verified RandomX hash and record, then runs stress --minutes ${E2E_STRESS_MINUTES:-1} and requires a pass with the miner and timer states unchanged (#533). The explicit config-ownership phase (not in all) regenerates and restarts the miner, then requires the generated config to stay byte-identical while mining, a hand edit of it to keep the same PID and donate_level until a restart loads it, and setup on an already-built worker to restart the miner with a changed pool keepalive and an unchanged binary (#529); E2E_LIVE_TIMEOUT, E2E_AUTOSAVE_WINDOW and E2E_RELOAD_WINDOW (default 180, 30 and 20 s) bound its waits. PITHEAD_URL=host:3333 sudo -E make e2e-pithead (see RELEASING.md)

The opt-in shared-host phase of e2e-pithead.sh is not part of all; docs/shared-host.md describes what it checks and restores.

tests/test-randomx-mode.sh, registered in tests/run.sh, covers the RandomX overlay, light-mode reservation sizing, tuning candidates, setup preview, and doctor memory warnings with isolated fixtures.

tests/test-sister-reconcile.sh, registered in tests/run.sh, checks startup failures, bounded listener probes (including IPv6 and failed transports), and apply's failure result while retaining later reconciles. The Stock home setup tests run historical and current revisions on separate fresh hosts. Each invokes the documented sudo ./rigforge.sh setup as the existing non-root account beneath a private 0750 HOME. Setup installs real dependencies, compiles pinned XMRig, performs ordinary kernel/service provisioning and installs the real miner unit; there is no prebuilt worker, fake unit, appliance mode or command stub. A closed loopback pool, donation zero and one configured mining thread leave it without mining jobs; the real miner is stopped after setup. The historical case requires setup to complete while its denied sister entrypoint leaves port 8081 unavailable. The current case requires an active DynamicUser service and authenticated port 8081 before any apply, then tests failed apply and recovery. HOME permissions remain 0750. Both tests uninstall through the real CLI on exit. Reboot persistence, a live pool and hardware performance are outside this proof. The real-rig control contract phase covers both network services against the coordinator. The existing real-e2e checkout traversability preflight remains a harness placement requirement. The control phase uses the shared bounded unauthenticated readiness probe before its first POST; a delayed listener receives no write until it returns HTTP 401, and an unavailable listener fails without a POST. Hardware-free cases cover delayed and unavailable listeners with config restoration. A failed readiness probe or initial control POST emits only allowlisted service states and fixed startup-error markers; raw journal entries and credentials are excluded.

The unit + black-box suite, the Linux container e2e, and the coverage gate run automatically on every push/PR (see .github/workflows/ci.yml). The native macOS e2e is manual and local-only — macOS is best effort, so it never runs in CI. The last two are deliberately kept out of hosted CI because they mine against live pools and exercise hardware performance on reserved rigs. The hosted stock-home setup has no mining jobs and does not replace those manual pre-tag release gates. The control phase also instruments real timer-driven API refreshes around a thermal control apply (#546). A temporary runtime drop-in replaces only the refresh service's command with e2e-api-refresh-profile.sh; its priority, timeout, timer and live feed remain in use. The profiler logs fixed helper names, begin/end timestamps and nanosecond durations, plus full-pass CPU ticks (the shell and waited-for children), clock ticks per second, nice level and the shell's cumulative scheduler wait in nanoseconds. CPU-time deltas distinguish computation from elapsed waiting; scheduler wait excludes children and can be zero when kernel scheduler statistics are disabled, so zero does not prove absence of contention. Missing/malformed accounting or a journal without a successful refresh and CPU begin/end from the same process fails diagnostics. No arguments, process names or payloads are exported. Five-second observations record timer/service state and the direct feed for five minutes around the apply; the changed ceiling must still appear within 90 seconds. Control and access-token requests pass bearer tokens through curl's stdin configuration. Control setup, access-token setup and stratum password setup/rotation use stdin with constant jq programs; the derived read bearer uses Python's standard-library HMAC with its key on stdin. These paths keep credentials out of process arguments and logs; the EXIT trap restores the original config. A failed control revocation request records only curl's numeric exit status and control-service activity; a failed wrong-password gate reuses fixed-schema XMRig state and classified log counts. These diagnostics preserve the failing verdict and never export config, log text or credentials. Each POST uses its own securely allocated response file, removed after reading the change identifier. The drop-in is written in a private staging file and published atomically with link only after the write succeeds. A partial write fails setup and cleanup removes the staging file. Publication refuses an existing or competing destination, including symlinks, without claiming or removing it. Cleanup quiesces the timer and instrumented pass, emits only measurement records from the journal, removes the owned drop-in, reloads systemd and restores the timer’s prior active state before config/runtime restoration. The job fails if journal collection or measurement export fails, no profiled refresh completes successfully, or cleanup fails. Begin events from unfinished helpers are retained to locate stalled operations, including a pass stopped by cleanup. The ordinary phases=["connect","control"] run proves mining and profiles a bounded thermal apply on an eligible worker; it does not recreate the historical sequence. For #540's separate thermal and pools replay cases, run one declaring phase per run with the control-replay-thermal or control-replay-pools scope. The harness supplies the operator pools probe, context and named reservation. The run verifies that reservation, bypasses only its own competing flock, and leaves the lock holder marker and release alone. The hardware-free test-control-replay.sh uses Bash builtins for its apply fixture and checks that refusal before config changes and the unchanged ordinary locking; on failure it prints each synthetic case log's final 20 lines before removing its sandbox, preserving the failed exit status. Both cases establish real jobs and an accepted share, retain thread/tuning and payout identity, set recorded scalars (thermal 100, DONATION 0, watchdog interval 5), and replay thermal 101 → 100, DONATION 1 → 0, watchdog interval 6 → 5, then the private pools probe. The thermal case verifies a 100 baseline, then applies direct 102 and requires a newer feed carrying that cutoff and this exact terminal change ID within 90 seconds. The separate pools case requires this exact change ID to reach applied in the enriched feed within the same bound, not a later change's outcome. Both continue five-minute observations for diagnostics and preserve the original pass/fail deadline even if a read crosses it. Full applies can stop/restart the miner; observations record its active state rather than aborting during that expected transition. Status and summary GETs consume JSON only after a successful transport; failed-read bytes are discarded and a fixed transport-failure marker is emitted. Valid JSON followed by a nonzero transport exit cannot satisfy settlement or publication. Each apply settlement emits only elapsed seconds and its validated status. Mining-precondition failures emit fixed-schema systemd state plus counts of jobs, shares and classified XMRig errors; unknown service values fail the diagnostic, and no journal text, endpoint or config value is printed. Requests use secured scratch payloads, never credential-bearing arguments or logs. The current probe and borrowed worker form an equivalent fixture: historical starting config/checkout, original pool payload, threads/affinity/tuning and precise inter-apply timing remain unknown in the harness context. No guessed delays or hardware differences are substituted. Do not invoke any replay or profiler against a worker yourself; the harness owns reservation, restoration and baseline verification. Short passes or an injected delay do not attribute the historical stale-feed failure; #540's fix acceptance requires evidence of the same failure mechanism. Profiling adds clock-read overhead and the source remains the submitted RigForge head; no alternative production implementation is installed by this diagnostic.

Both stop at a failed mutation prerequisite and make restoration failure fail the process; recovery snapshots remain on disk when cleanup cannot prove the original config bytes and runtime were restored.

Documentation replay on a disposable VM

make e2e-docs-replay is the VM job entry point for the documented installation and uninstall lifecycle. Run it on a Linux KVM controller with Python 3 and virsh access to the local system libvirt instance. The job requires these environment variables:

Variable Required value
E2E_DOCS_DISPOSABLE 1, acknowledging that setup, uninstall and two reboots will mutate the guest.
E2E_DOCS_VM_UUID UUID of a running, transient, disposable Ubuntu cloud VM with AVX2 exposed. Persistent domains are refused.
E2E_DOCS_CONFIG Path to the prepared configuration for this run, kept outside the checkout.

The VM owner supplies and disposes the guest and a throwaway plain-Stratum endpoint that issues RandomX jobs and accepts low-difficulty shares. Provision only the test transport and observation tools beforehand: QEMU guest agent with guest execution enabled, Git, sudo, jq, curl, nftables and iproute2. The guest needs systemd, a stock Ubuntu GRUB installation and enough memory for RandomX; it must have no prior RigForge installation or reserved HugePages. No live rig is a valid fixture. The prepared config must contain one pool, donation zero and a nonempty api_allow_from. Use docs-replay as the pool user and an empty password or x; do not supply a wallet, production endpoint or credential. Leave ACCESS_TOKEN and control disabled and use the default worker location. Only pools, DONATION, api_allow_from, HOME_DIR and optional threads are accepted; pool objects accept only url, user and pass. The guest must be able to download the documented release and its build dependencies.

The driver extracts the marked Bash blocks from the README and walkthrough, checks their quick-start commands agree, and executes them unchanged through the guest agent. It inserts the prepared config before the documented dry run and setup. This deliberately tests the release pinned by the documentation; it does not silently replace that release with the candidate branch. Marker and command agreement lint runs in tests/run.sh without Python. The host-driver regression and guest-check negative controls run under make test-suite.

The job snapshots the system changes before dry run, checks autostart after a new boot ID, donation zero, the configured pool as the only miner peer, increasing accepted shares with no rejects, and a refused base-API write. After uninstall and a second new boot ID it checks units, processes, listeners, pool sockets, the nft table, 2 MiB HugePages and GRUB restoration. A stopped or unreachable guest after reboot is a platform failure (exit 2), never an autostart failure. Other failed assertions exit 1. The controller emits only fixed progress messages; raw guest output stays out of public evidence. Always discard the fixture after success, failure or timeout; the driver never deletes a caller-owned VM.

The existing worker-to-stack network phase also makes a bounded request from a temporary network namespace, bracketed by successful requests from the allowed source. It requires the API drop counter to increase and the miner to keep hashing, then removes its namespace and veth. The production rule now includes that counter. Local negative controls cover an admitted namespace and an uninstall that leaves the nft table. The real AVX2 reboot/mining job and reserved-worker network phase remain required evidence beyond the hardware-free tests and container checks.

The namespace probe also has an isolated Linux kernel test, using a small HTTP server and a fixed test hashrate instead of a miner. It proves filtering and cleanup, including the admitted-source and unchanged-counter negative controls. The e2e CI job runs it with:

docker build -q -t rigforge-allowlist tests/docker
docker run --rm --privileged -v "$PWD:/src:ro" rigforge-allowlist bash /src/tests/test-api-allowlist-linux.sh

The image — alpine pinned by tag and digest, with the nftables probe's packages baked in — lives in docker/Dockerfile; Dependabot bumps the pin.

Running the worker-to-stack phases directly

Each phase of e2e-pithead.sh runs on its own as sudo -E bash tests/e2e-pithead.sh <phase> on a dedicated, uncontended rig with a live stack at PITHEAD_URL=host:3333. all runs connect, worker-api, api-impact, network, stratum-auth, dashboard, dev-fee, control and access-tokens in that order and stops at the first failure. Only stratum-auth and dashboard skip cleanly when their input is absent; every other phase runs or fails.

Phase What it does Optional inputs
connect, worker-api, api-impact, network Mining round trip, the worker API posture, the hashrate-impact guard under polling load, and the network summary and key contract. E2E_SHARE_TIMEOUT, E2E_API_IMPACT_TOLERANCE_PCT, E2E_API_LATENCY_S; network always runs the API allowlist probe on an auto-selected link-local subnet; E2E_ALLOWLIST_HOST_CIDR and E2E_ALLOWLIST_NS_CIDR override it, must be set together, and setting only one fails the phase
network-sequence Outside all: the first four in one process and one snapshot. as above
stratum-auth Stratum auth accept/reject and rotation against a temporary plain-Stratum pool. E2E_STRATUM_PASS: all skips without it, the explicit phase fails
dashboard Dashboard visibility and drop-off. E2E_DASH_URL (skipped without it), E2E_DASH_AUTH, E2E_DROPOFF_TIMEOUT (default 300)
dev-fee Legacy build migration and runtime donation reductions. none
control The writable control path's DONATION apply round trip. E2E_APPLIANCE_POLICY_DROPIN
access-tokens A named ACCESS_TOKENS entry authenticates and is refused after revocation. none
thread-profile Outside all: XMRig thread profiles against the actual /2/backends threads. none
config-ownership Outside all: the generated config stays byte-identical while mining and a hand edit waits for a restart. E2E_LIVE_TIMEOUT, E2E_AUTOSAVE_WINDOW, E2E_RELOAD_WINDOW
selftest Outside all: the real bench and stress. E2E_STRESS_MINUTES (default 1)
shared-host Outside all: shared-host behaviour. E2E_SHARED_SHARE_TIMEOUT (default 600)
control-replay-thermal, control-replay-pools Outside all: replay of the thermal and pools control sequences. Exits 2 unless the replay inputs are supplied. required: E2E_PITHEAD_CONTROL_FIXTURE=pithead-control, E2E_PITHEAD_CONTROL_CONTEXT, IT_RIG_POOLS_PROBE, and E2E_RIG_LOCK_UNIT naming an active systemd unit that matches bench-ci-riglock-<name>-<n>; a clean clone cannot satisfy the last two until #734/#735 land

The rig lock

Release gates and the stack's own e2e tests must not run on one rig at the same time: the gates mutate the rig, the stack's tests assume a steadily-hashing miner. Both take a kernel flock on /var/lock/rig-e2e.lock at entry; a second arrival exits 75 naming the holder (set RIG_LOCK_WAIT=1 to queue instead). RIG_LOCK_FILE and RIG_LOCK_HOLDER relocate the lock and its holder file (#183).

Where does my test go?

  • New logic, config-gen behaviour, a CPU/OS profile, or command behaviour → run.sh. It's the default home for almost everything; hardware and OS are simulated with PATH stubs, so it stays hardware-independent and runs the same on any machine.
  • A new real-/etc system effect (fstab, memlock limits, an MSR/modules edit, a mount) → assert it in e2e/in-container.sh, which runs against a throwaway filesystem.
  • macOS-specific behaviour (BSD tools, launchd, the mac process control) → e2e/macos.sh.
  • Something only provable on real hardware (it actually hashes, MSRs really applied, HugePages really reserved) → e2e-real.sh.
  • A change to the sister-API feed or the control /status wire shape (a new field, a new status string) → update the fixture in contract/v1/ in the same PR; run.sh's == contract guard == section byte-compares against it and fails otherwise (#351).

Conventions

  • run.sh is dependency-free: no bats, no frameworks. Tiny assert_* helpers, and every external or privileged command is faked in a stub dir placed first on PATH. Keep it that way: a contributor must be able to run bash tests/run.sh on a stock machine.
  • It's hardware-independent on purpose: all hardware-probe env hooks are pointed at non-existent paths up top, so the same run exercises EPYC / Ryzen-X3D / macOS inputs back to back and gives the same result on any host. Don't read real /sys or /proc; drive behaviour through the stubs.
  • The suite should still pass under Apple's bash 3.2, not just modern bash — that's no longer CI- enforced (macOS is best effort and no CI job runs /bin/bash tests/run.sh anymore), just a courtesy for the best-effort Darwin path. Avoid bash-4-only syntax. bash tests/test-suite-liveness.sh runs the actual timer-refresh fixtures and checks premature exit handling without running the host-dependent black-box suite; use /bin/bash on macOS to exercise the native Bash 3.2 runtime parser as well as the completion guard.
  • Lint everything: make lint (shellcheck + shfmt). The file list lives in the Makefile's SHELL_FILES so CI and local stay in sync — add new tests/*.sh there.

Performance testing (standardized)

Three standardized measurements, each owned by exactly one layer, so a release can't regress performance unnoticed:

Measurement Where Standard Knobs
Absolute hashrate e2e-real.sh perf phase (runs inside all) Offline xmrig --bench=1M on the idle machine. The phase prints one JSON line keyed by hardware class and perf id ({"<class>":{"bench_1m_hs":<H/s>}}) and reads its history from the caller (E2E_PERF_HISTORY, JSON lines of earlier results). E2E_PERF_MODE is report (default, never fails) or gate: gate fails when the result leaves the median of the class's last 5 results ± 3×MAD and reports insufficient history below 5 results. The legacy per-host files in perf-baselines/ still back the report and the recording judge when no history is passed. E2E_PERF_CLASS (default: the CPU model, slugified); E2E_PERF_MODE (report default, gate; legacy E2E_PERF_GATE=1); E2E_PERF_HISTORY; E2E_PERF_TOLERANCE_PCT (default 5, legacy report/recording paths); legacy E2E_PERF_RECORD=1.
Hashrate under API load e2e-pithead.sh api-impact phase Live 10s-window hashrate, 6×5s samples, baseline vs 4 clients hammering the sister API back-to-back. The handler unit's Nice=19/IOSchedulingClass=idle is the mechanism; this proves it. E2E_API_IMPACT_TOLERANCE_PCT (default 3).
Tune improvement e2e-real.sh verify phase (existing) The short real tune must produce a winner that beats or ties the baseline candidate (#62–#64 machinery: sustained-clock sampling, variance-aware acceptance, live A/B confirm). TUNE_BENCH, TUNE_ITERS (see the phase comments).

Results are keyed by hardware class on purpose: hashrate is hardware. Keep the history outside the repo (the caller appends each emitted JSON line to its own store), so a run never dirties the checkout.

XMRig self-test regressions

bash tests/test-benchmark-verification.sh covers verified, mismatched and missing verdicts, opt-in submission followed by verification, and rejection of incorrect offline tuning candidates. bash tests/test-benchmark-support.sh checks the bundle's field allowlist and invalid-record handling. bash tests/test-stress.sh uses isolated XMRig and service stubs to cover stop/run/restore, interrupt cleanup and the watchdog thermal cutoff. bash tests/test-perf-submission.sh checks that opt-in submission IDs reach both release perf records. These run in make test.

The real stress window and temperature behavior still require a reserved hardware run. Stub tests cannot prove physical stability, thermal sensor accuracy or upstream submission service availability. Record that hardware proof before merging a self-test control change.