testsAndMisc/linux_configuration/tests
Krzysztof kuhy Rudnicki 63a5124920 session_autopsy: test the hooks, the untested half of the analyzer
a83b5ab took the analyzer package to 100% branch coverage but stopped at the
package boundary. Its only production entry points are two shell hooks in
~/.claude/hooks, and those were untracked, unlinted and untested -- the same
"untracked meant unlinted" shape that commit's own message describes, one
directory over. Both run on every session on this machine.

Both hooks end in an unconditional exit 0 by design: an autopsy failure must
never surface into the session lifecycle. That makes exit status a constant, so
a test asserting it passes against a hook whose body has been deleted. Every
assertion here is on a side effect instead. For SessionEnd a setsid shim on PATH
records the launch argv rather than spawning an ingest, so the tests can pin the
command, transcript path, --quiet, PYTHONPATH and timeout on the happy path, and
pin no-launch-at-all for a missing key, an empty path, a nonexistent file and
malformed JSON.

SessionStart asserts stderr as well as stdout. Under set -u, (( count > 0 )) on
a non-numeric count raises an arithmetic error to stderr while stdout stays
silent, so a stdout-only assertion would miss a hook injecting bash noise into
every session start. That gap was found by mutation, not by inspection.

A pytest file rather than a test_*.sh, deliberately: only .py under
linux_configuration/tests is collected by pytest_changed_packages.py, so this
lands in the local pre-commit gate, whereas the .sh tests there are gated by the
shell-tests workflow alone. It imports nothing from python_pkg, so the
100%-on-python_pkg gate is untouched -- 977 pass at 100% branch.

Verified by a per-guard mutation matrix rather than one whole-body gutting:
gutting alone kills only the three positive tests and would have falsely branded
the nine negative ones vacuous. Dropping each guard in turn, widening > 0 to
>= 0, and announcing unconditionally kills all twelve. The matrix also showed
that the start hook's [[ ! -r "$STATE" ]] guard is redundant -- deleting it kills
nothing, since jq's stderr is suppressed and an empty count already fails the
arithmetic. Left in place as defence in depth; the hooks are unmodified.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 17:27:30 +02:00
..
__init__.py Harden runtime script deployment and enforce installer safety 2026-05-08 17:44:22 +02:00
conftest.py refactor: extract all inline Python from shell scripts into proper .py files 2026-06-06 10:31:48 +02:00
test_android_guardian_post_fs_data.sh refactor(linux_configuration/scripts): split all scripts into single_use/ and periodic_background/ 2026-05-15 00:32:35 +02:00
test_android_guardian_service.sh Run shell tests in CI and repair three broken by a reorg 2026-07-19 19:06:23 +02:00
test_fast_count.py refactor: extract all inline Python from shell scripts into proper .py files 2026-06-06 10:31:48 +02:00
test_hosts_file_monitor.sh Run Arch-only shell tests in a container; harden worktree stubbing 2026-07-19 19:27:36 +02:00
test_hosts_guard_pacman_integration.sh Run all 14 shell tests in CI 2026-07-19 19:39:28 +02:00
test_i3blocks_efficiency.sh feat(digital-wellbeing): time-boxed shutdown overrides + drift-proof i3blocks deploy 2026-07-10 21:57:05 +02:00
test_i3blocks_persist_common.sh feat(digital-wellbeing): time-boxed shutdown overrides + drift-proof i3blocks deploy 2026-07-10 21:57:05 +02:00
test_makepkg_capped.sh Run Arch-only shell tests in a container; harden worktree stubbing 2026-07-19 19:27:36 +02:00
test_makepkg_wrapper.sh fix(pacman): wrap makepkg so an orphaned db.lck can't hang makepkg -i 2026-07-17 07:46:31 +02:00
test_monitor_report.py refactor: extract all inline Python from shell scripts into proper .py files 2026-06-06 10:31:48 +02:00
test_music_parallelism.sh Run Arch-only shell tests in a container; harden worktree stubbing 2026-07-19 19:27:36 +02:00
test_network_diagnostics.bats Add network diagnostics: duty-cycle and line-speed probes 2026-07-19 18:46:18 +02:00
test_pacman_wrapper_security.sh fix(pacman): wrap makepkg so an orphaned db.lck can't hang makepkg -i 2026-07-17 07:46:31 +02:00
test_security_hardening.sh security-hardening: recognise the guard-lib shutdown guard 2026-07-19 20:09:24 +02:00
test_session_autopsy_hooks.py session_autopsy: test the hooks, the untested half of the analyzer 2026-07-25 17:27:30 +02:00
test_setup_dns_blocker.sh feat: add Pi-hole-like LAN DNS blocking served from the PC (dnsmasq) 2026-07-10 19:02:46 +02:00
test_shutdown_timer_monitor.sh Run Arch-only shell tests in a container; harden worktree stubbing 2026-07-19 19:27:36 +02:00
test_strip_workout_hosts.py refactor: extract all inline Python from shell scripts into proper .py files 2026-06-06 10:31:48 +02:00
test_usage_monitoring_installer_efficiency.sh Repair two stale shell tests; CI now runs all six 2026-07-19 19:13:51 +02:00
test_usage_report_pmon_names.py feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
test_usage_report_since.py feat: split oversized modules for 500-line limit, fix kasa coverage gap 2026-06-14 07:19:37 +02:00
test_validate_contract.py refactor: extract all inline Python from shell scripts into proper .py files 2026-06-06 10:31:48 +02:00
test_validate_evidence.py refactor: extract all inline Python from shell scripts into proper .py files 2026-06-06 10:31:48 +02:00