Stop pipefail from turning grep -q SIGPIPE exits into false negatives (#6614)
* Stop pipefail from turning grep -q SIGPIPE exits into false negatives grep -q exits at the first match, and when the producer is still writing it dies with SIGPIPE. Under pipefail that 141 becomes the pipeline's status, so hardware checks like lspci | grep -q read as "not found" on exactly the machines they target. The T2 defaults migration hit this and silently skipped real T2 Macs (#6608). Redirect grep to /dev/null instead of -q wherever a pipeline feeds grep in a pipefail context, so grep reads all input and the producer never gets killed. The install-time T2 checks aren't run under pipefail today but are switched too, since they're the same detection line the issue calls out. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Re-run the T2 defaults migration its broken hardware check skipped The SIGPIPE bug marked 1785944594 as applied without doing anything on affected T2 Macs. The original migration is idempotent, so a fresh migration can just source it now that the guard is fixed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Address Copilot review: fix OCR grep pipeline and prove the T2 repair screen_contains piped tesseract into grep -Fqi under the acceptance suite's pipefail, the same SIGPIPE false negative the rest of the branch fixes. The T2 test's lspci stub now keeps writing past the pipe buffer after the match so every scenario exercises the SIGPIPE case, and a new case runs the rerun migration against fixtures a bitten install would have. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
667d2d2f31
commit
b85ae70ebd
@@ -318,7 +318,7 @@ PATH="$TMPDIR/bin:$PATH" wl-paste --type text --watch "$current_script" text &
|
||||
stale_pid=$!
|
||||
PIDS_TO_KILL+=("$stale_pid")
|
||||
sleep 0.2
|
||||
pgrep -f 'wl-paste .*--watch .*/shell/plugins/clipboard/capture\.sh' | grep -qx "$stale_pid" || fail "clipboard reaper pattern matches running watchers"
|
||||
pgrep -f 'wl-paste .*--watch .*/shell/plugins/clipboard/capture\.sh' | grep -x "$stale_pid" >/dev/null || fail "clipboard reaper pattern matches running watchers"
|
||||
kill "$stale_pid" 2>/dev/null || true
|
||||
wait "$stale_pid" 2>/dev/null || true
|
||||
pass "clipboard reaper pattern matches running watchers"
|
||||
|
||||
@@ -33,9 +33,15 @@ mkdir -p "$stub_bin"
|
||||
cat >"$stub_bin/lspci" <<'SH'
|
||||
#!/bin/bash
|
||||
|
||||
# Chatty like real lspci: keep writing well past the pipe buffer after the T2
|
||||
# match, so a grep -q consumer would kill this stub with SIGPIPE and pipefail
|
||||
# would read that as "no T2 hardware" (#6608).
|
||||
if (( ${T2_HARDWARE:-0} == 1 )); then
|
||||
echo '01:00.0 Bridge [0680]: Apple Inc. T2 Security Chip [106b:1801]'
|
||||
fi
|
||||
for _ in {1..4096}; do
|
||||
echo '02:00.0 Host bridge [0600]: Filler Device [ffff:0000]'
|
||||
done
|
||||
SH
|
||||
|
||||
cat >"$stub_bin/sudo" <<'SH'
|
||||
@@ -179,3 +185,30 @@ grep -q 'pcie_ports=compat' "$limine_conf" || fail "non-T2 Limine configuration
|
||||
! grep -q '\[Fan2\]' "$fan_conf" || fail "non-T2 fan configuration is unchanged"
|
||||
[[ ! -s $calls ]] || fail "non-T2 systems skip the repair" "$(cat "$calls")"
|
||||
pass "T2 migration skips unrelated hardware"
|
||||
|
||||
# The previous block left the fixtures looking like an install the SIGPIPE bug
|
||||
# skipped: stale Limine parameters, one fan section, and no repair marker. The
|
||||
# rerun migration must complete the repair the original was marked as done for.
|
||||
rerun_migration="$ROOT/migrations/1786137597.sh"
|
||||
rm -f "$repair_marker"
|
||||
: >"$calls"
|
||||
|
||||
PATH="$stub_bin:$PATH" \
|
||||
TEST_LOG="$calls" \
|
||||
T2_HARDWARE=1 \
|
||||
TINY_DFR_INSTALLED=0 \
|
||||
OMARCHY_PATH="$ROOT" \
|
||||
OMARCHY_T2_LIMINE_CONF="$limine_conf" \
|
||||
OMARCHY_T2_FAN_CONF="$fan_conf" \
|
||||
OMARCHY_T2_RUNNING_CMDLINE="$running_cmdline" \
|
||||
OMARCHY_T2_REPAIR_MARKER="$repair_marker" \
|
||||
bash -euo pipefail "$rerun_migration" >/dev/null
|
||||
|
||||
grep -Fq 'pm_async=off mem_sleep_default=deep' "$limine_conf" ||
|
||||
fail "T2 rerun migration updates the Limine suspend parameters"
|
||||
(( $(grep -Ec '^[[:space:]]*\[Fan2\][[:space:]]*$' "$fan_conf") == 1 )) ||
|
||||
fail "T2 rerun migration adds the second-fan section"
|
||||
grep -Fxq 'limine-mkinitcpio' "$calls" ||
|
||||
fail "T2 rerun migration rebuilds the boot image"
|
||||
[[ -f $repair_marker ]] || fail "T2 rerun migration records the machine-wide repair"
|
||||
pass "T2 rerun migration repairs installs the broken hardware check skipped"
|
||||
|
||||
Reference in New Issue
Block a user