mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 19:54:01 +01:00
The bind-mount logic goes to hosts_mount.sh, the Magisk-module and
cache-invalidation logic to hosts_magisk.sh. Both flat siblings, both in
both deploy lists; the two lists were then checked to correspond exactly
in both directions, since a push with no matching cp stages a file that
never lands and the enforcer would fail to source it.
Audited for stdin-draining `while read` loops BEFORE extracting, because
piping one would change behaviour in a way stubs cannot catch. There are
none here. Also confirmed no function writes a global, so there was no
cross-half hazard of the kind that kept NET_BUILT in curfew_enforcer.sh.
69 assertions, 43/43 and 62/62 lines, 17 mutations all killed. Two survived
the first run and both were real findings:
- the unmount give-up threshold was not pinned. Raising it from 5 to 500
changed nothing observable, so the enforcer could have spun 500 times
per poll against a mount that was never going to clear. Now asserted as
a call count.
- the `[ ! -f $HOSTS_TARGET ] && return 1` guard in
is_bind_mounted_correctly is PROVABLY EQUIVALENT: sha256_of returns
empty for a missing file, so the existing -n check already rejects that
case. No test can distinguish it. Equivalent code is a claim of a check
that is not being made, so it is deleted rather than covered by a test
that would pass either way. Old and new bodies were compared across all
four input states -- both-missing, target-missing, match, mismatch --
and agree on every one.
That deletion is the only non-verbatim function; the other 19 moved
untouched, making this the first fully verbatim extraction of the session.
Ordering is asserted where it is load-bearing: /system must go back to ro
after rw, and +i must be restored after being dropped. Presence assertions
alone would pass with either pair reversed.
UNVERIFIED ON DEVICE -- the highest-stakes of the four enforcer splits now
outstanding, since a failure to source leaves nothing blocking while the
phone looks normal. Over-cap count 20 -> 19.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
25 lines
935 B
Bash
Executable File
25 lines
935 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Unit tests for hosts_mount.sh and hosts_magisk.sh — the two halves split out
|
|
# of hosts_enforcer.sh — against the fake device in hosts_libs_harness.sh.
|
|
# No real phone is needed.
|
|
#
|
|
# This is the only entry point; the cases live in two sourced files purely to
|
|
# stay under the 250-line cap, so one coverage command measures both subjects.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# shellcheck source=hosts_libs_harness.sh
|
|
. "${SCRIPT_DIR}/hosts_libs_harness.sh"
|
|
# shellcheck source=hosts_cases_mount.sh
|
|
. "${SCRIPT_DIR}/hosts_cases_mount.sh"
|
|
# shellcheck source=hosts_cases_assert.sh
|
|
. "${SCRIPT_DIR}/hosts_cases_assert.sh"
|
|
# shellcheck source=hosts_cases_magisk.sh
|
|
. "${SCRIPT_DIR}/hosts_cases_magisk.sh"
|
|
# shellcheck source=hosts_cases_cache.sh
|
|
. "${SCRIPT_DIR}/hosts_cases_cache.sh"
|
|
|
|
printf '\nResults: %d passed, %d failed\n' "${PASS}" "${FAIL}"
|
|
[[ "${FAIL}" -eq 0 ]]
|