mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 19:54:01 +01:00
Gives linux_configuration/scripts/lib a real test suite, which takes all nine of its libraries off meta/shell-coverage-allowlist.txt at once — coverage is per-directory, so this is the highest-ratio first batch. 139 assertions across four suites, all offline: the mtk toolkit is driven through its existing MTK_ROOT_FIXTURE seam, and adb is shimmed onto a narrowed PATH. Nothing reads the wall clock, this host's udev rules, or a real device, because the suite runs in shell-tests.yml and again on every pre-push via ci-mirror — a host-dependent assertion would be a flake that blocks unrelated pushes. The gate only checks that tests/run_all.sh EXISTS, so an empty one would mark all nine libraries covered while testing nothing. Each of the four load-bearing rules was therefore mutation-tested and the suite required to go red: classify_device's && -> ||, discover_partitions' init_boot/boot ordering, mtk_select_device's refusal to guess between two phones, and is_hour_in_range's 10#$ octal guard. That last one initially SURVIVED. Dropping 10#$ makes bash abort with "value too great for base", a non-zero exit indistinguishable from an honest out-of-range result, so the status-only assertion passed either way. It now asserts stderr is empty. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
31 lines
1.3 KiB
Bash
Executable File
31 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs every linux_configuration/scripts/lib test.
|
|
#
|
|
# The glob is test_*.sh, NOT one prefix per subject: this directory holds
|
|
# suites for several libraries (mtk_*, common_datetime, ...), and a prefix
|
|
# glob silently skips every suite added after it — including in the CI
|
|
# discovery step in shell-tests.yml, which runs this file.
|
|
#
|
|
# This file's existence is what meta/scripts/check_shell_coverage.sh checks:
|
|
# is_covered() tests for tests/run_all.sh and nothing more, so an empty one
|
|
# here would mark all nine libraries in the parent directory covered while
|
|
# testing nothing. The suites it runs, and the gaps they leave, are named in
|
|
# mtk_harness.sh's header.
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
rc=0
|
|
for t in "$HERE"/test_*.sh; do
|
|
printf '\n=== %s ===\n' "$(basename "$t")"
|
|
# Each suite exits non-zero on failure; keep going so one red suite does not
|
|
# hide the state of the others, then fail the run as a whole.
|
|
# Invoked directly, NOT as `bash "$t"`: under kcov the latter instruments
|
|
# bash itself and reports zero lines for every lib. A fresh process per
|
|
# suite also matters here, because mtk_common.sh declares readonly
|
|
# patterns and sourcing it twice in one shell aborts under set -e.
|
|
"$t" || rc=1
|
|
done
|
|
|
|
exit "$rc"
|