0b5043a9f3
gates / consistency-and-conventions (push) Successful in 26s
User report after the llamacpp app install: 'installed llama.cpp unknown', valid flags rejected (randomly per run), 'Model not found' for the HF downloader's own layout, and a systemd user-bus failure over SSH. Detective (real b10822 binary, FACT) found four independent causes: - version: llama-server --version prints to STDERR; detect_llama_version's 2>/dev/null swallowed it -> always 'unknown'. Now captures 2>&1 + accepts semver/build tokens (incl. build 1.2.3 edge) - validation: printf|grep -q under pipefail -> SIGPIPE rc=141 race randomly rejected flags present in the 59 KB --help. Now pipe-less grep (no race); 20x determinism regression test - model resolution: resolve_model accepted files only, but the HF downloader creates <models>/<repo>/file.gguf dirs. Now expands a dir with exactly one *.gguf (never silently picks; multi-gguf lists + errs) - port: llama.cpp default 8080 vs tool/adapter 8088; validation reliability means --port is now always pinned in the unit - user bus: headless/SSH sessions lack XDG_RUNTIME_DIR -> ensure_user_bus in lib/common.sh pre-flights all three systemctl --user tools with remediation text; pos ai server --no-unit direct-run escape hatch (pidfile) for boxes with no bus - find_llamacpp narrowed to llama-server/llama-server-cuda (bare 'server' fallback hazard); installer post-install sanity (version+help execute, symlink targets resolve) Architect decisions DQ1-DQ6 recorded. Tester: 4 new regression files (version-from-stderr, 25x flag-validation determinism, model dir expansion, bus pre-flight + E2E) + 3 fixture updates; suite 16 files / 269 checks. Verified: make gen idempotent; make check OK; make lint 0 FAIL, 0 WARN; make test 269/269 (~49s); bash -n clean; git diff --check clean.
tests/ — regression test suite
Zero-dependency Bash regression tests for the Linux_post_install repository.
Run
make test # discover tests/t-*.sh, run everything
./tests/run-tests.sh # same
./tests/run-tests.sh t-telegram-auth.sh # run one file
Exit code is non-zero if any check failed. The suite is designed to be deterministic: tests stub every external dependency they touch (curl, gpg, sudo, systemctl, llama-server, nvidia-smi…) and run against sandbox temp dirs. No network, no sudo, no system changes.
Adding a test
- Create
tests/t-<what>.shwith arun_test()function.set -euo pipefailis already active (the runner re-asserts it);$ROOTis the repo root,$TEST_TMPa per-test temp dir that is cleaned automatically. - Use the helpers in
tests/test-lib.shfor every assertion:check,check_eq,check_rc,check_contains,check_not_contains,check_file_exists,check_file_absent,test_run/test_run_env,mksandbox,tracked_tree_copy,count_token. - If a case cannot run in the current environment (missing binary, missing
analyzer), call
skip_case "<desc>" "<reason>"— never fake a pass and never silently return. - Keep total suite runtime under 90 seconds.
Skip contract (hard)
A test that cannot run must say [SKIP] reason. The runner counts skips in
the summary and a file whose run_test() produced zero checks and zero skips
is reported as FAIL ("no assertions") — a broken harness can never pass
silently.
Suite contents
| File | What it verifies |
|---|---|
t-ai-server-flags.sh |
pos-ai-server ExecStart flag set: defaults, CLI, config, dedupe, one-token-per-flag |
t-ai-hf-download.sh |
pos ai hf download success + failure honesty (no .hf-meta on partial failure, rc != 0) |
t-ai-llama-detect.sh |
pos ai-server status version detection, "unknown", missing-binary failure |
t-unsupported-flags.sh |
unsupported-option handling: CLI/config/env hard errors, dropped defaults, word-boundary match |
t-systemd-unit.sh |
generated unit: one ExecStart, quoted paths, systemd-analyze verify |
t-telegram-auth.sh |
Telegram listener chat+owner gate and owner-unset fail-closed |
t-matrix-auth.sh |
Matrix listener room+owner gate and room-unset fail-closed |
t-gpg-password.sh |
backup passphrase on fd 3 (never argv), plaintext/corrupt cleanup |
t-config-precedence.sh |
load_env_file contract + CLI > env > file > defaults across tools |
t-uninstall-manifest.sh |
install.sh ↔ POS_LIBS symmetry, user-unit discovery, marker-driven plugin removal |
t-gen-docs-drift.sh |
make gen idempotence on a pristine tracked tree (CI drift gate) |
t-lint-gate.sh |
make lint green on the real tree; planted violations are caught and named |