mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-14 00:40:48 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
171 lines
6.7 KiB
Bash
Executable File
171 lines
6.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# lib/tests/arch_sysctl_quarantined_cases.sh — 23 GREEN assertions for
|
|
# arch_sysctl.sh, deliberately OUTSIDE the test_*.sh glob that run_all.sh
|
|
# iterates. Not dead code, and not broken: run it directly and it passes.
|
|
#
|
|
# WHY IT IS QUARANTINED
|
|
#
|
|
# While this file was named test_arch_sysctl.sh, its presence in the suite
|
|
# made kcov stop registering bt_audio.sh entirely -- a lib that is OFF the
|
|
# allowlist at 127/127, so check_shell_coverage.sh went red on main. Bisected:
|
|
#
|
|
# a2b23521 (session start) bt_audio 127/127
|
|
# afe6ac3a (shfmt reformat) bt_audio 127/127
|
|
# 7c14cfca (this file lands) bt_audio "kcov instrumented no lines"
|
|
#
|
|
# Removing this one file restores bt_audio to 127/127 with every other new
|
|
# test file (arch_cpu, arch_hardware x2, thorium x2) still present. Both
|
|
# candidate causes inside lib_test_core.sh were ruled out by reverting each
|
|
# independently in a throwaway worktree: `export out` and the _t_hide farm
|
|
# cache each left bt_audio broken while this file was present.
|
|
#
|
|
# The cost of keeping it is therefore a gated lib's measurement; the benefit
|
|
# is nil, because arch_sysctl.sh has NEVER measured through the jail (it
|
|
# reports "kcov instrumented no lines" on its own too, like nc_php.sh). It
|
|
# stays on meta/shell-coverage-allowlist.txt.
|
|
#
|
|
# TO RUN THESE CASES:
|
|
# bash linux_configuration/fixes/lib/tests/arch_sysctl_quarantined_cases.sh
|
|
#
|
|
# TO UN-QUARANTINE: rename back to test_arch_sysctl.sh, then re-measure
|
|
# bt_audio.sh through run_all.sh and confirm it is still 127/127 BEFORE
|
|
# committing. Do not assume a kcov upgrade fixed it.
|
|
#
|
|
set -uo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# shellcheck source=arch_desktop_harness.sh
|
|
. "${SCRIPT_DIR}/arch_desktop_harness.sh"
|
|
|
|
# shellcheck source=../arch_sysctl.sh
|
|
. "${FIXES_DIR}/lib/arch_sysctl.sh"
|
|
|
|
printf '\n-- tweak_vm_sysctl --\n'
|
|
|
|
# A sysctl stub that reports every parameter as already at its wanted value,
|
|
# so needs_update stays false. Values are keyed by the parameter name in $2
|
|
# (sysctl is called as `sysctl -n KEY`).
|
|
_stub_sysctl_tuned() {
|
|
_t_stub_stdin sysctl <<'STUB'
|
|
case "$2" in
|
|
vm.swappiness) echo 10 ;;
|
|
vm.vfs_cache_pressure) echo 50 ;;
|
|
vm.dirty_ratio) echo 15 ;;
|
|
vm.dirty_background_ratio) echo 5 ;;
|
|
vm.dirty_writeback_centisecs) echo 1500 ;;
|
|
vm.page-cluster) echo 0 ;;
|
|
net.core.default_qdisc) echo fq ;;
|
|
net.ipv4.tcp_congestion_control) echo bbr ;;
|
|
net.ipv4.tcp_fastopen) echo 3 ;;
|
|
net.core.rmem_max) echo 16777216 ;;
|
|
net.core.wmem_max) echo 16777216 ;;
|
|
net.ipv4.tcp_rmem) printf '4096\t1048576\t16777216\n' ;;
|
|
net.ipv4.tcp_wmem) printf '4096\t1048576\t16777216\n' ;;
|
|
net.ipv4.tcp_mtu_probing) echo 1 ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
STUB
|
|
}
|
|
|
|
# Case 1: values already tuned AND the drop-in exists -> skip without writing.
|
|
arch_desktop_reset
|
|
_stub_sysctl_tuned
|
|
: >"${SYSCTL_DROPIN_DIR}/90-desktop-performance.conf"
|
|
_t_run tweak_vm_sysctl
|
|
_t_eq "0" "$?" "tweak_vm_sysctl: returns 0 when already tuned"
|
|
_t_contains "$out" "already tuned" "tweak_vm_sysctl: reports the skip"
|
|
_t_eq "" "$(_t_dropin 90-desktop-performance.conf)" \
|
|
"tweak_vm_sysctl: leaves the existing drop-in untouched"
|
|
_t_lacks "$(_t_calls)" "sysctl --system" \
|
|
"tweak_vm_sysctl: does not reload when skipping"
|
|
|
|
# Case 2: values already tuned but NO drop-in file -> must still write it.
|
|
# This is the arm that a naive "nothing to do" check would wrongly skip.
|
|
arch_desktop_reset
|
|
_stub_sysctl_tuned
|
|
_t_run tweak_vm_sysctl
|
|
_t_contains "$(_t_dropin 90-desktop-performance.conf)" "vm.swappiness = 10" \
|
|
"tweak_vm_sysctl: writes the drop-in when it is missing"
|
|
_t_lacks "$out" "already tuned" \
|
|
"tweak_vm_sysctl: does not report a skip when the drop-in is absent"
|
|
|
|
# Case 3: a value differs -> write the drop-in and reload.
|
|
arch_desktop_reset
|
|
_t_stub_stdin sysctl <<'STUB'
|
|
case "$2" in
|
|
vm.swappiness) echo 60 ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
STUB
|
|
_t_run tweak_vm_sysctl
|
|
dropin="$(_t_dropin 90-desktop-performance.conf)"
|
|
_t_contains "$dropin" "vm.swappiness = 10" "tweak_vm_sysctl: writes swappiness"
|
|
_t_contains "$dropin" "vm.vfs_cache_pressure = 50" \
|
|
"tweak_vm_sysctl: writes vfs_cache_pressure"
|
|
_t_contains "$dropin" "vm.page-cluster = 0" "tweak_vm_sysctl: writes page-cluster"
|
|
_t_contains "$dropin" "managed by optimize_arch_desktop.sh" \
|
|
"tweak_vm_sysctl: stamps the drop-in as managed"
|
|
_t_contains "$(_t_calls)" "sysctl --system" "tweak_vm_sysctl: reloads sysctl"
|
|
|
|
# Case 4: sysctl failing outright (unknown key) still reaches the write path.
|
|
arch_desktop_reset
|
|
_t_stub sysctl 'exit 1'
|
|
_t_run tweak_vm_sysctl
|
|
_t_eq "0" "$?" "tweak_vm_sysctl: returns 0 when sysctl -n fails"
|
|
_t_contains "$(_t_dropin 90-desktop-performance.conf)" "vm.dirty_ratio = 15" \
|
|
"tweak_vm_sysctl: writes the drop-in when current values are unreadable"
|
|
|
|
printf '\n-- tweak_network_sysctl --\n'
|
|
|
|
# Case 5: the tcp_bbr module is unavailable -> warn and return without writing.
|
|
arch_desktop_reset
|
|
_t_stub modprobe 'exit 1'
|
|
_t_run tweak_network_sysctl
|
|
_t_eq "0" "$?" "tweak_network_sysctl: returns 0 when tcp_bbr is unavailable"
|
|
_t_contains "$out" "tcp_bbr kernel module unavailable" \
|
|
"tweak_network_sysctl: warns about the missing module"
|
|
_t_eq "" "$(_t_dropin 91-desktop-network.conf)" \
|
|
"tweak_network_sysctl: writes nothing without tcp_bbr"
|
|
|
|
# Case 6: already tuned AND drop-in present -> skip. The tcp_rmem/tcp_wmem
|
|
# values come back tab-separated from the kernel, which is why the lib
|
|
# normalizes both sides through xargs before comparing; this case is what
|
|
# proves that normalization works.
|
|
arch_desktop_reset
|
|
_stub_sysctl_tuned
|
|
: >"${SYSCTL_DROPIN_DIR}/91-desktop-network.conf"
|
|
_t_run tweak_network_sysctl
|
|
_t_contains "$out" "already tuned" \
|
|
"tweak_network_sysctl: skips when tab-separated values match"
|
|
_t_lacks "$(_t_calls)" "sysctl --system" \
|
|
"tweak_network_sysctl: does not reload when skipping"
|
|
|
|
# Case 7: already tuned but no drop-in -> write it.
|
|
arch_desktop_reset
|
|
_stub_sysctl_tuned
|
|
_t_run tweak_network_sysctl
|
|
_t_contains "$(_t_dropin 91-desktop-network.conf)" "net.ipv4.tcp_congestion_control = bbr" \
|
|
"tweak_network_sysctl: writes the drop-in when it is missing"
|
|
|
|
# Case 8: a value differs -> write and reload.
|
|
arch_desktop_reset
|
|
_t_stub_stdin sysctl <<'STUB'
|
|
case "$2" in
|
|
net.ipv4.tcp_congestion_control) echo cubic ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
STUB
|
|
_t_run tweak_network_sysctl
|
|
dropin="$(_t_dropin 91-desktop-network.conf)"
|
|
_t_contains "$dropin" "net.core.default_qdisc = fq" \
|
|
"tweak_network_sysctl: writes the qdisc"
|
|
_t_contains "$dropin" "net.ipv4.tcp_rmem = 4096 1048576 16777216" \
|
|
"tweak_network_sysctl: writes the receive buffers"
|
|
_t_contains "$dropin" "net.ipv4.tcp_mtu_probing = 1" \
|
|
"tweak_network_sysctl: writes mtu probing"
|
|
_t_contains "$(_t_calls)" "sysctl --system" "tweak_network_sysctl: reloads sysctl"
|
|
|
|
printf '\narch_sysctl: %d passed, %d failed\n' "$PASS" "$FAIL"
|
|
[[ $FAIL -eq 0 ]]
|