mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-13 13:30:47 +01:00
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Has been cancelled
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Has been cancelled
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Has been cancelled
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Has been cancelled
Python tests / test (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Shell tests / shell-tests (push) Has been cancelled
Shell tests / lib-tests (push) Has been cancelled
Shell tests / arch-tests (push) Has been cancelled
amd_x3d_mode defaulted to frequency, so the scheduler preferred the non-V-cache CCD. kuhy chose cache: games prefer CPUs 0-5,12-17; background jobs are already pinned to 6-11,18-23. A udev rule matches DRIVER amd_x3d_vcache on add (boot coldplug) and bind (any rebind), so it hard-codes no device name and survives a rebind, unlike a tmpfiles w line. fixes/fix_amd_x3d_vcache.sh installs it, fires a synthetic bind event and checks the mode ends on cache. Same layout as fix_webcam_c270.sh, with a bats test. Host: mode frequency -> cache, prefcore ranking now favours 0-5,12-17. vmbox has no X3D device: only the install step was proven there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWYWDKuhbBAoNETfoB9
91 lines
3.0 KiB
Bash
Executable File
91 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
# Tests for fixes/fix_amd_x3d_vcache.sh against a fake driver sysfs tree and
|
|
# stubbed sudo/udevadm, so nothing touches /etc or the real X3D driver.
|
|
#
|
|
# Requires: bats (extra/bats). Run with:
|
|
# bats linux_configuration/tests/test_fix_amd_x3d_vcache.bats
|
|
|
|
bats_require_minimum_version 1.5.0
|
|
|
|
setup() {
|
|
REPO_DIR="$(cd -- "$(dirname -- "$BATS_TEST_FILENAME")/.." && pwd)"
|
|
SCRIPT="$REPO_DIR/fixes/fix_amd_x3d_vcache.sh"
|
|
export X3D_DRIVER_SYSFS="$BATS_TEST_TMPDIR/drivers/amd_x3d_vcache"
|
|
export X3D_RULES_DIR="$BATS_TEST_TMPDIR/rules.d"
|
|
mkdir -p "$X3D_DRIVER_SYSFS/AMDI0101:00" "$X3D_RULES_DIR" "$BATS_TEST_TMPDIR/bin"
|
|
echo frequency >"$X3D_DRIVER_SYSFS/AMDI0101:00/amd_x3d_mode"
|
|
export CALLS="$BATS_TEST_TMPDIR/calls"
|
|
# sudo runs its command; udevadm "trigger" stands in for the kernel bind
|
|
# event by flipping the fake attribute the way the installed rule would.
|
|
cat >"$BATS_TEST_TMPDIR/bin/sudo" <<'STUB'
|
|
#!/bin/bash
|
|
echo "sudo $*" >>"$CALLS"
|
|
exec "$@"
|
|
STUB
|
|
cat >"$BATS_TEST_TMPDIR/bin/udevadm" <<'STUB'
|
|
#!/bin/bash
|
|
echo "udevadm $*" >>"$CALLS"
|
|
if [[ "$1" == trigger && "${FAKE_RULE_WORKS:-1}" == 1 ]]; then
|
|
echo cache >"$X3D_DRIVER_SYSFS/AMDI0101:00/amd_x3d_mode"
|
|
fi
|
|
STUB
|
|
chmod +x "$BATS_TEST_TMPDIR/bin/sudo" "$BATS_TEST_TMPDIR/bin/udevadm"
|
|
export PATH="$BATS_TEST_TMPDIR/bin:$PATH"
|
|
}
|
|
|
|
@test "install puts the rule in place, triggers a bind event and ends on cache" {
|
|
run "$SCRIPT"
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules" ]
|
|
grep -q 'DRIVER=="amd_x3d_vcache"' "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules"
|
|
grep -q 'ATTR{amd_x3d_mode}="cache"' "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules"
|
|
grep -q '^udevadm control --reload' "$CALLS"
|
|
grep -q '^udevadm trigger --action=bind' "$CALLS"
|
|
[ "$(cat "$X3D_DRIVER_SYSFS/AMDI0101:00/amd_x3d_mode")" = cache ]
|
|
}
|
|
|
|
@test "the rule hard-codes no device name" {
|
|
run ! grep -q 'AMDI0101' "$REPO_DIR/fixes/60-amd-x3d-vcache-mode.rules"
|
|
}
|
|
|
|
@test "install fails loudly when the mode does not end on cache" {
|
|
FAKE_RULE_WORKS=0 run "$SCRIPT"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"frequency"* ]]
|
|
}
|
|
|
|
@test "install without the driver installs the rule and skips the trigger" {
|
|
rm -rf "$X3D_DRIVER_SYSFS"
|
|
run "$SCRIPT"
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules" ]
|
|
run ! grep -q '^udevadm trigger' "$CALLS"
|
|
}
|
|
|
|
@test "install with the driver loaded but no X3D device installs the rule and succeeds" {
|
|
rm -rf "${X3D_DRIVER_SYSFS:?}/AMDI0101:00"
|
|
run "$SCRIPT"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"no X3D device"* ]]
|
|
[ -f "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules" ]
|
|
}
|
|
|
|
@test "--remove deletes the rule and reloads udev" {
|
|
touch "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules"
|
|
run "$SCRIPT" --remove
|
|
[ "$status" -eq 0 ]
|
|
[ ! -e "$X3D_RULES_DIR/60-amd-x3d-vcache-mode.rules" ]
|
|
grep -q '^udevadm control --reload' "$CALLS"
|
|
}
|
|
|
|
@test "--status reports rule and live mode" {
|
|
run "$SCRIPT" --status
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"frequency"* ]]
|
|
}
|
|
|
|
@test "unknown option exits 2" {
|
|
run "$SCRIPT" --bogus
|
|
[ "$status" -eq 2 ]
|
|
}
|