mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 17:34:04 +01:00
Sixth of the 16 untested fixes/lib libs, and the first with no dead branch to
fix -- the whole job was test-writing. 43 assertions across two files;
93/93 = 100.00% through run_all.sh, twice, the second at --min 100 (exit 0),
then cleared with the real gate confirming and no exemption.
The one genuine gap was check_memory_pressure's high-swap branch (lines
158-159), which fires only when swap is heavily used WHILE RAM is still
available -- a state this host does not happen to be in. The lib reads the
absolute /proc/meminfo, but every read goes through `awk`, so stubbing awk
supplies controlled figures without touching /proc: the stub answers on the
pattern being matched and execs the real awk for anything else. Both
directions are covered, including RAM genuinely exhausted, which must NOT be
flagged because it is not the stutter signature.
Everything else here is branch coverage of probes whose inputs are external
commands: failed systemd units, ACPI error counts, a CPU-hungry Xorg,
governors all-performance vs one-powersave vs unsupported, thermal
throttling excerpts, the TLP/power-profiles-daemon conflict in all three
combinations, and storage health with and without fstrim/smartctl.
lib_test_core.sh gains _t_stub_cat. "Print this fixture file" is by far the
commonest stub shape, and writing it inline forces every call site to embed
a literal ${LIB_TEST_DEV} that must not expand at write time -- SC2016 on
every use. Passing the fixture NAME as data removes the class outright, and
two earlier bluetooth test files are simplified onto it. All 21 test files
and three harnesses now lint clean with no suppression anywhere.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
5.3 KiB
JSON
54 lines
5.3 KiB
JSON
{
|
|
"intent": "Test linux_configuration/scripts/single_use/fixes/lib/arch_perf_probes.sh to 100% line coverage and take it off the shell-coverage allowlist, sixth of the 16 untested fixes/lib libs.",
|
|
"scope": [
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/test_arch_perf_probes.sh (new, 16 assertions)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/test_arch_perf_probes_health.sh (new, 27 assertions)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/lib_test_core.sh (new _t_stub_cat helper)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/test_bt_pairing_usb.sh and test_bt_adapter_reset.sh (simplified onto _t_stub_cat)",
|
|
"meta/shell-coverage-allowlist.txt (one line removed)",
|
|
"Non-goal: any change to arch_perf_probes.sh itself -- unlike the two libs before it, this one had no dead branch"
|
|
],
|
|
"changes": [
|
|
"Added test_arch_perf_probes.sh covering collect_basics (a quiet machine, failed systemd units, frequent ACPI errors, a CPU-hungry Xorg, and the load-average threshold) and check_cpu_governor (all cores on performance, one core left on powersave, and no governor files at all).",
|
|
"Added test_arch_perf_probes_health.sh covering check_thermal_state (sensors present and clean, throttling messages excerpted, sensors absent), check_power_services (both daemons enabled, neither enabled, exactly one enabled), check_storage_health (healthy disk, disabled fstrim.timer, missing smartctl), and check_memory_pressure (heavy swap with RAM free, heavy swap with RAM exhausted, and a swapless machine).",
|
|
"The high-swap branch is reached by stubbing awk rather than /proc/meminfo, which the lib reads by absolute path: every meminfo read goes through awk, so the stub answers on the pattern being matched and execs the real awk for every other call. That closed lines 158-159, the only genuine test gap in the lib.",
|
|
"Added _t_stub_cat to lib_test_core.sh: the commonest stub shape is 'print this fixture file', and writing it inline forced every call site to embed a literal ${LIB_TEST_DEV} that must not expand at write time. Passing the fixture name as data removes that whole class of SC2016 with no suppression, and two earlier bluetooth test files were simplified onto it.",
|
|
"Removed linux_configuration/scripts/single_use/fixes/lib/arch_perf_probes.sh from meta/shell-coverage-allowlist.txt."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh",
|
|
"result": "pass",
|
|
"evidence": "arch_perf_probes (basics/governor): 16 passed; arch_perf_probes (health): 27 passed; both 0 failed. All 21 test files in the directory pass, so the five cleared libs and the eight pacman_hook_stall suites stay green after _t_stub_cat landed."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/shell_coverage_jail.sh --subject linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh --measure arch_perf_probes.sh --min 1 --fail-on-case-error -- \"\"",
|
|
"result": "pass",
|
|
"evidence": "arch_perf_probes.sh: 93/93 lines = 100.00%, up from 91/93 = 97.85% before the check_memory_pressure swap branch was covered. No 'outside kcov's line set' lines reported."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/shell_coverage_jail.sh --subject linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh --measure arch_perf_probes.sh --min 100 --fail-on-case-error -- \"\"",
|
|
"result": "pass",
|
|
"evidence": "arch_perf_probes.sh: 93/93 lines = 100.00%, exit code 0. Second matching run at the --min 100 bar."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/check_shell_coverage.sh on arch_perf_probes.sh, arch_perf_report.sh and bt_audio.sh",
|
|
"result": "pass",
|
|
"evidence": "'check_shell_coverage.sh: every checked shell library meets the coverage bar', exit 0, with the arch_perf_probes.sh allowlist line already removed so it had no exemption. The other two are included to confirm the libs cleared in c309c95f did not regress."
|
|
},
|
|
{
|
|
"command": "shellcheck on every file in fixes/lib/tests",
|
|
"result": "pass",
|
|
"evidence": "All 21 test files plus the three harnesses lint clean, with no suppression added anywhere in this commit."
|
|
}
|
|
],
|
|
"risks": [
|
|
"check_cpu_governor and collect_basics read absolute paths (/sys/devices/system/cpu via find, /proc/loadavg) that have no environment override, so those cases are driven by stubbing the command the lib shells out to (find, getconf, ps, systemctl, journalctl). The load-average case additionally self-skips with an explicit note if this host's 1-minute load happens to sit below 1, so it cannot silently start asserting nothing.",
|
|
"The awk stub used for the swap cases execs /usr/bin/awk for any pattern it does not recognise. If the lib later reads a new /proc/meminfo field, the stub will fall through to the real awk and the fabricated figures will silently stop applying to that field rather than failing loudly."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; that restores the arch_perf_probes.sh allowlist line and deletes the two test files together.",
|
|
"After rollback, run bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh and confirm the remaining suites pass, then bash meta/scripts/check_shell_coverage.sh to confirm the gate is green with arch_perf_probes.sh exempt again."
|
|
]
|
|
}
|