mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 12:47:47 +01:00
Fifth of the 16 untested fixes/lib libs and the first of the arch-performance
group, which gets its own harness here. 38 assertions across two files. The
lib STAYS on the allowlist at 59/60 = 98.33%, measured twice.
The second dead branch this campaign has found, fixed here. Lines 36 and 65
matched on:
([0-9]+\.?[0-9]*)\ (G|M)
a REQUIRED space before the unit. journalctl actually prints "Archived and
active journals take up 305.5M in the file system." with no separator --
verified against the real binary on this machine. So check_journal_size could
never report a large journal and apply_safe_fixes could never vacuum one:
both were unreachable. The space is now optional, and tests cover the spaced
and unspaced forms so neither can rot.
NOTE: this makes a previously-dead DESTRUCTIVE action live. With
--apply-safe-fixes and a journal over a gigabyte, the entry script will now
really run `journalctl --vacuum-size=300M`. That is the flag's documented
purpose and it stays behind the flag, but it has never actually executed
before today.
Line 20, the one uncovered line, is `} >>"$REPORT_FILE"` -- the closing brace
of a redirected group. A minimal probe writes both inner lines to the file
while bash attributes no statement to the brace, and the report assertions
independently prove the group runs, since they read the text it writes. Same
defect (a) class as bt_audio's `} |`.
That form now caps four libs: bt_audio.sh, arch_perf_report.sh, and
arch_perf_probes.sh and nvidia_config.sh which are still untested. So the
continuation_lines() fix is worth landing after all -- as its own commit,
next, so a denominator change can be reverted without taking these tests
with it.
_t_hide and _t_full_path move from bt_harness.sh into lib_test_core.sh: they
are generic PATH plumbing and the arch harness needs them for the
"nvidia-smi is not installed" branch. All twelve existing suites re-run green
after the move.
One trap worth recording: apply_safe_fixes appends to the ACTIONS array, so
it must be called directly rather than inside "$(...)" -- a command
substitution runs it in a subshell where the appends die with it, and the
assertions read an empty array.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
56 lines
6.2 KiB
JSON
56 lines
6.2 KiB
JSON
{
|
|
"intent": "Test linux_configuration/scripts/single_use/fixes/lib/arch_perf_report.sh, fifth of the 16 untested fixes/lib libs and the first of the arch-performance group, and fix a second production bug the tests exposed: the journal size check could never fire. The lib reaches 98.33% and STAYS on the allowlist, capped by one closing-brace line.",
|
|
"scope": [
|
|
"linux_configuration/scripts/single_use/fixes/lib/arch_perf_report.sh (two regexes: the journal size match)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/arch_perf_harness.sh (new family harness)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/test_arch_perf_report.sh (new, 17 assertions)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/test_arch_perf_report_fixes.sh (new, 21 assertions)",
|
|
"linux_configuration/scripts/single_use/fixes/lib/tests/lib_test_core.sh and bt_harness.sh (_t_hide/_t_full_path moved into the core)",
|
|
"meta/shell-coverage-allowlist.txt is deliberately UNCHANGED: arch_perf_report.sh does not meet the 100% bar"
|
|
],
|
|
"changes": [
|
|
"Fixed the journal size regexes in arch_perf_report.sh, lines 36 and 65. Both required a SPACE before the unit -- ([0-9]+\\.?[0-9]*)\\ (G|M) -- but journalctl prints 'Archived and active journals take up 305.5M in the file system.' with no separator, verified on this machine. check_journal_size could therefore never report a large journal, and apply_safe_fixes could never vacuum one: both were dead code. The space is now optional (\\ ?), and tests cover the spaced and unspaced forms.",
|
|
"Added arch_perf_harness.sh: sources lib_test_core.sh and the real scripts/lib/common.sh, points REPORT_FILE into the throwaway tmpdir, and redefines add_finding, add_action and run_and_log verbatim from diagnose_arch_performance.sh, which owns them rather than any lib.",
|
|
"Added test_arch_perf_report.sh covering check_gpu_state (nvidia-smi absent, an idle GPU pinned in P0, a busy P0 GPU that must NOT be flagged, an idle GPU in a low-power state, and nvidia-smi returning nothing) and check_journal_size (gigabyte, megabyte, space-separated, and journalctl failing).",
|
|
"Added test_arch_perf_report_fixes.sh covering apply_safe_fixes (disabled by the flag, nothing to do, enabling a disabled fstrim.timer, disabling a conflicting tlp.service, and vacuuming a multi-gigabyte journal) and print_summary (clean run, findings listed and counted, actions section).",
|
|
"Moved _t_hide and _t_full_path from bt_harness.sh into lib_test_core.sh. They are generic PATH plumbing, not bluetooth-specific, and the arch harness needs them for the 'nvidia-smi is not installed' branch.",
|
|
"apply_safe_fixes is called directly rather than inside a command substitution: it appends to the ACTIONS array, and a substitution runs it in a subshell where those appends die with it, leaving the assertions reading an empty array."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh",
|
|
"result": "pass",
|
|
"evidence": "arch_perf_report (probes): 17 passed; arch_perf_report (fixes/summary): 21 passed; both 0 failed. All fixes lib test files passed, so the four bluetooth libs and the eight pacman_hook_stall suites stay green after _t_hide moved into the core."
|
|
},
|
|
{
|
|
"command": "bash meta/scripts/shell_coverage_jail.sh --subject linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh --measure arch_perf_report.sh --min 1 --fail-on-case-error -- \"\"",
|
|
"result": "pass",
|
|
"evidence": "arch_perf_report.sh: 59/60 lines = 98.33%, uncovered: 20. Run twice with the identical line set."
|
|
},
|
|
{
|
|
"command": "bash -c 'line=\"...take up 4.2G in the file system.\"; [[ $line =~ ([0-9]+\\.?[0-9]*)\\ (G|M) ]]'",
|
|
"result": "pass",
|
|
"evidence": "Reproduced the bug before fixing: NO MATCH against the old regex, so no journal size could ever be flagged. With the optional space the same line matches and yields 4.2G. journalctl on this host prints '305.5M' with no space, confirming the real format the old regex excluded."
|
|
},
|
|
{
|
|
"command": "Read uncovered line 20 and probe it minimally",
|
|
"result": "pass",
|
|
"evidence": "Line 20 is '} >>\"$REPORT_FILE\"', the closing brace of a redirected group. A minimal probe ({ echo a; echo b; } >>file inside a function) writes both lines to the file while bash attributes no statement to the closing brace. The report assertions independently prove the group runs, since they read the very text it writes. Same defect (a) class as bt_audio's '} |' lines."
|
|
},
|
|
{
|
|
"command": "grep -lE '^[[:space:]]*\\}[[:space:]]*>' over all 22 fixes/lib libs",
|
|
"result": "pass",
|
|
"evidence": "The redirected-closing-brace form appears in arch_perf_report.sh, arch_perf_probes.sh and nvidia_config.sh. Together with bt_audio.sh's '} |' that is four libs capped by one detector gap, which is why the continuation_lines() fix is now worth landing as its own commit."
|
|
}
|
|
],
|
|
"risks": [
|
|
"The journal regex fix makes a previously-dead DESTRUCTIVE action live. apply_safe_fixes will now actually run 'journalctl --vacuum-size=300M' when the entry script is invoked with --apply-safe-fixes and the journal exceeds a gigabyte, deleting roughly 3.9G of logs on a 4.2G journal. That is the documented intent of the flag, and the vacuum still only runs behind it, but it has never actually executed before this commit.",
|
|
"arch_perf_report.sh stays on the allowlist at 98.33%, capped by line 20. Clearing it needs continuation_lines() in meta/scripts/lib/shell_coverage_lines.py to exclude a closing brace followed by a redirection or pipe, which lands separately so a regression can be reverted without losing these tests.",
|
|
"The GPU tests stub nvidia-smi rather than reading the real card, so they assert on the lib's parsing of a known nvidia-smi contract, not on this host's actual GPU state."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; it adds a harness and two test files, moves two helpers between harness files, and changes two regexes in one lib. No allowlist entry is touched.",
|
|
"After rollback, run bash linux_configuration/scripts/single_use/fixes/lib/tests/run_all.sh and confirm the remaining suites pass; the coverage gate is unaffected since arch_perf_report.sh stays exempt either way."
|
|
]
|
|
}
|