mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 19:54:01 +01:00
Location/curfew goes to daemon_location.sh, the derived state files to daemon_state.sh, the app layer to daemon_apps.sh. All 23 functions moved verbatim -- nothing restructured, which matters more here than anywhere else in this session. focus_daemon.sh has five `while IFS= read -r pkg; do ... done <file` loops and EVERY body calls pm. Piping any of them in lets pm inherit and drain the loop's stdin, so it would process one package instead of all of them -- measured elsewhere in this repo as 1 of 54. That audit ran BEFORE the extraction, not after coverage came back short, and all five moved untouched with a note above them saying why. CURRENT_MODE and _CURFEW_TICK_CACHED are each written in both the entry script and a library, so both stay declared with main, same call as NET_BUILT in the curfew split. 110 assertions and 33 mutations, all killed. Two survived the first run and both were defects in my own tests: the whitelist and sysprotect exactness checks used a SUPERSTRING of a listed entry, which fails under grep -qF and grep -qxF alike and so proved nothing about which was in use. Two subjects are NOT at 100%, and the numbers are reported as measured: daemon_state.sh 67/67 = 100.00% daemon_location.sh 26/40 = 65.00% daemon_apps.sh 71/76 = 93.42% Both shortfalls are kcov attribution failures, shown to be artifacts rather than gaps. daemon_location.sh's missing lines are all inside the embedded awk Haversine; mutating the Earth radius and dropping the longitude term both fail the suite, and an isolated probe shows a one-line awk measuring 100% where the identical multi-line one measures 0%. Collapsing the formula to satisfy the tool would cost the readability of the only real mathematics in the repo, so it stays. daemon_apps.sh's five are the trailing `done <file` of the very loops described above. That is the same artifact piping fixed in curfew_net.sh, and it is exactly what must NOT be done here. Redirecting two of them from /dev/null fails the suite, so the lines run; all three are pinned in the mutation spec instead. Over-cap count 19 -> 18. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
24 lines
906 B
Bash
Executable File
24 lines
906 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Unit tests for the three libraries split out of focus_daemon.sh, against the
|
|
# fake device in daemon_libs_harness.sh. No real phone is needed.
|
|
#
|
|
# This is the only entry point; the cases live in sourced files purely to stay
|
|
# under the 250-line cap, so one coverage command measures all three subjects.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# shellcheck source=daemon_libs_harness.sh
|
|
. "${SCRIPT_DIR}/daemon_libs_harness.sh"
|
|
# shellcheck source=daemon_cases_location.sh
|
|
. "${SCRIPT_DIR}/daemon_cases_location.sh"
|
|
# shellcheck source=daemon_cases_state.sh
|
|
. "${SCRIPT_DIR}/daemon_cases_state.sh"
|
|
# shellcheck source=daemon_cases_apps.sh
|
|
. "${SCRIPT_DIR}/daemon_cases_apps.sh"
|
|
# shellcheck source=daemon_cases_sweep.sh
|
|
. "${SCRIPT_DIR}/daemon_cases_sweep.sh"
|
|
|
|
printf '\nResults: %d passed, %d failed\n' "${PASS}" "${FAIL}"
|
|
[[ "${FAIL}" -eq 0 ]]
|