Skip to content

Commit 664058e

Browse files
committed
test-infra(win): CI-shaped VM harness, managed-install smoke gate, calibrated suite tier
The 40 hidden Windows failures fixed in the previous commit reached CI unseen because the local Windows leg never validly ran the C suite: MSYS2's shared /tmp fails the secure-ancestry validation (refusals, not signal) and the ssh driver piped everything through `tail -40`. This closes those holes and hardens the gates that let an install failure scroll past. - vm-run-tests.sh (new, used by win.sh test / ubsan-test / trap-ubsan-test): gives the suites CI's exact protected per-user temp root (owner-stamped, protected current-SID DACL, mirroring the workflow's pwsh step), shapes the runner's build directory like a real user checkout (drive-root trees inherit an Authenticated-Users Modify ACE that profile-rooted checkouts do not have, which the activation source-directory policy correctly refuses; DACL re-rooted two-step — directory protect then child /reset, since inheritance flags are directory-only and a /T re-root leaves files with empty deny-all DACLs), streams the FULL output, and refuses to report success unless the runner printed its completion summary. - smoke: Phase 8 no longer swallows the install exit code. On Windows it now requires the managed install to SUCCEED and to publish an exact two-link canonical launcher — a staging refusal used to scroll past as tolerated noise while the downstream config assertions kept passing. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent f517455 commit 664058e

3 files changed

Lines changed: 114 additions & 4 deletions

File tree

‎scripts/smoke-test.sh‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,14 +1074,39 @@ echo '# Personal Rovo guidance' > "$ROVO_INSTRUCTIONS"
10741074

10751075
# Run install — override platform config dirs so cbm_app_config_dir() and
10761076
# cbm_app_local_dir() resolve to FAKE_HOME paths on all platforms.
1077+
PHASE8_INSTALL_RC=0
1078+
PHASE8_INSTALL_LOG=$(smoke_mktemp_file)
10771079
HOME="$FAKE_HOME" \
10781080
XDG_CONFIG_HOME="$FAKE_HOME/.config" \
10791081
APPDATA="$FAKE_HOME/AppData/Roaming" \
10801082
LOCALAPPDATA="$FAKE_HOME/AppData/Local" \
10811083
KIMI_CODE_HOME="$CUSTOM_KIMI_HOME" \
10821084
CBM_ROO_CONFIG_PATH="$ROO_CFG" \
10831085
PATH="$FAKE_HOME/.local/bin:$PATH" \
1084-
"$BINARY" install -y 2>&1 || true
1086+
"$BINARY" install -y > "$PHASE8_INSTALL_LOG" 2>&1 || PHASE8_INSTALL_RC=$?
1087+
cat "$PHASE8_INSTALL_LOG"
1088+
if [[ "$BINARY" == *.exe ]]; then
1089+
# The managed install itself must SUCCEED on Windows — an install-time
1090+
# staging/ACL refusal used to scroll past as tolerated noise while the
1091+
# downstream config assertions kept passing against a previous generation
1092+
# ("staging transaction open failed (status -3, os 0)" hid a real install
1093+
# failure class on Administrators-default-owner profiles).
1094+
if [ "$PHASE8_INSTALL_RC" -ne 0 ]; then
1095+
echo "FAIL 8-0: managed install exited rc=$PHASE8_INSTALL_RC"
1096+
exit 1
1097+
fi
1098+
PHASE8_CANONICAL="$FAKE_HOME/.local/bin/codebase-memory-mcp.exe"
1099+
if [ ! -f "$PHASE8_CANONICAL" ]; then
1100+
echo "FAIL 8-0: canonical launcher missing after managed install"
1101+
exit 1
1102+
fi
1103+
PHASE8_LINKS=$(stat -c %h "$PHASE8_CANONICAL" 2>/dev/null || echo 0)
1104+
if [ "$PHASE8_LINKS" != "2" ]; then
1105+
echo "FAIL 8-0: canonical launcher is not an exact two-link file (links=$PHASE8_LINKS)"
1106+
exit 1
1107+
fi
1108+
echo "OK 8-0: managed install committed an exact two-link canonical launcher"
1109+
fi
10851110

10861111
# Helper for JSON validation (pipe file to python — avoids MSYS2 path translation issues)
10871112
json_get() { cat "$1" 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print($2)" 2>/dev/null || echo ""; }
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
# vm-run-tests.sh — run C test suites on the Windows VM under a CI-shaped
3+
# protected temp root. Runs ON the VM (MSYS2 shell), invoked by win.sh
4+
# test / ubsan-test / trap-ubsan-test.
5+
#
6+
# Why the temp root: the daemon/coordination suites fail closed on the
7+
# MSYS-shared /tmp (C:\msys64\tmp), whose ancestry grants mutation rights to
8+
# Authenticated Users — running them there produces security refusals, not
9+
# test signal. CI gives the harness a per-user root under the profile with an
10+
# owner-stamped, protected current-SID DACL (.github/workflows/_test.yml
11+
# "Create protected per-user temp root"); this script mirrors that exactly so
12+
# the VM leg validates what CI will see.
13+
#
14+
# Why the guard: this leg once piped through `tail -40`, and a suite that
15+
# never validly ran looked green — 40 Windows failures reached CI unseen.
16+
# Output now streams in full, and a run whose log lacks the runner's
17+
# completion summary is a hard failure regardless of exit code.
18+
set -uo pipefail
19+
20+
RUNNER="${CBM_VM_RUNNER:-build/c/test-runner}"
21+
LOG="${CBM_VM_TEST_LOG:-/tmp/win-test.log}"
22+
23+
[ $# -ge 1 ] || { echo "usage: vm-run-tests.sh <suite...>" >&2; exit 2; }
24+
[ -x "$RUNNER" ] || { echo "ERROR: runner '$RUNNER' missing — build first" >&2; exit 2; }
25+
26+
# Stale roots from earlier runs are removed up front; the current root is kept
27+
# after the run for post-mortem inspection.
28+
root_windows="$(powershell -NoProfile -Command '
29+
$ErrorActionPreference = "Stop"
30+
Get-ChildItem -LiteralPath $env:USERPROFILE -Directory -Filter "cbm-vm-tmp-*" -ErrorAction SilentlyContinue |
31+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
32+
$root = Join-Path $env:USERPROFILE ("cbm-vm-tmp-" + [guid]::NewGuid().ToString("N"))
33+
New-Item -ItemType Directory -Path $root | Out-Null
34+
$sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
35+
$acl = [System.Security.AccessControl.DirectorySecurity]::new()
36+
$acl.SetOwner($sid)
37+
$acl.SetAccessRuleProtection($true, $false)
38+
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
39+
$sid,
40+
[System.Security.AccessControl.FileSystemRights]::FullControl,
41+
([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
42+
[System.Security.AccessControl.InheritanceFlags]::ObjectInherit),
43+
[System.Security.AccessControl.PropagationFlags]::None,
44+
[System.Security.AccessControl.AccessControlType]::Allow)
45+
$acl.AddAccessRule($rule) | Out-Null
46+
Set-Acl -LiteralPath $root -AclObject $acl
47+
Write-Output $root
48+
' | tr -d '\r')"
49+
[ -n "$root_windows" ] || { echo "ERROR: protected temp root creation failed" >&2; exit 2; }
50+
51+
TEMP="$(cygpath -m "$root_windows")"
52+
TMP="$TEMP"
53+
TMPDIR="$(cygpath -u "$root_windows")"
54+
export TEMP TMP TMPDIR
55+
56+
# The runner's directory must look like a real user checkout: repos under a
57+
# profile carry no Authenticated-Users ACE, but C:\cbm (like CI's workspace
58+
# drive) inherits Modify for Authenticated Users from the drive root, which
59+
# the activation transaction's source-directory policy correctly refuses —
60+
# install-flow tests would then fail on the environment, not the code.
61+
# Two steps, both idempotent: protect the DIRECTORY (inheritance flags are
62+
# directory-only — a /T re-root leaves files with empty, deny-all DACLs),
63+
# then /reset the children so they re-inherit the clean set from it.
64+
runner_dir_w="$(cygpath -w "$(dirname "$RUNNER")")"
65+
me="$(whoami | tr -d '\r')"
66+
MSYS2_ARG_CONV_EXCL='*' icacls "$runner_dir_w" /inheritance:r \
67+
/grant:r "${me}:(OI)(CI)F" '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' \
68+
/Q >/dev/null 2>&1 || true
69+
MSYS2_ARG_CONV_EXCL='*' icacls "${runner_dir_w}\\*" /reset /T /C /Q >/dev/null 2>&1 || true
70+
71+
echo "=== vm-run-tests: runner=$RUNNER temp=$TEMP suites: $* ==="
72+
73+
"$RUNNER" "$@" 2>&1 | tee "$LOG"
74+
rc="${PIPESTATUS[0]}"
75+
76+
if ! grep -Eq '[0-9]+ passed' "$LOG"; then
77+
echo "GUARD: test runner produced no completion summary — the suites did" \
78+
"not validly run; treating as failure (runner rc=$rc)" >&2
79+
exit 90
80+
fi
81+
exit "$rc"

‎test-infrastructure/vm/win.sh‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ build)
107107
;;
108108
test)
109109
[ $# -ge 1 ] || { echo "usage: win.sh test <suite...>" >&2; exit 2; }
110-
vm clangarm64 "cd /c/cbm && ./build/c/test-runner $* 2>&1 | tail -40"
110+
# vm-run-tests.sh gives the suites CI's protected per-user temp root
111+
# (daemon suites fail closed on the MSYS-shared /tmp), streams the FULL
112+
# output, and refuses to report success without the runner's completion
113+
# summary. A `| tail -40` here once hid 40 real Windows failures.
114+
vm clangarm64 "cd /c/cbm && bash test-infrastructure/vm/vm-run-tests.sh $*"
111115
;;
112116
guards)
113117
# Match the Windows CI product build: a clean, embedded-UI payload plus the
@@ -152,7 +156,7 @@ ubsan-build)
152156
;;
153157
ubsan-test)
154158
[ $# -ge 1 ] || { echo "usage: win.sh ubsan-test <suite...>" >&2; exit 2; }
155-
vm clang64 "cd /c/cbm && ./build/c/test-runner $* 2>&1 | tail -40"
159+
vm clang64 "cd /c/cbm && CBM_VM_TEST_LOG=/tmp/win-ubsan-test.log bash test-infrastructure/vm/vm-run-tests.sh $*"
156160
;;
157161
trap-ubsan-build)
158162
# NATIVE ARM64 UBSan via trap mode. -fsanitize-trap=undefined needs NO
@@ -170,7 +174,7 @@ trap-ubsan-test)
170174
[ $# -ge 1 ] || { echo "usage: win.sh trap-ubsan-test <suite...>" >&2; exit 2; }
171175
# A UB trap crashes the runner with SIGILL (exit 132); the harness reports
172176
# the failing suite so the emulated diagnosis loop can name the check.
173-
vm clangarm64 "cd /c/cbm && ./build/trap-ubsan/test-runner $* 2>&1 | tail -40"
177+
vm clangarm64 "cd /c/cbm && CBM_VM_RUNNER=build/trap-ubsan/test-runner CBM_VM_TEST_LOG=/tmp/win-trap-ubsan-test.log bash test-infrastructure/vm/vm-run-tests.sh $*"
174178
;;
175179
pageheap)
176180
# OS-level heap verification (page-granular overflow/UAF detection) for the

0 commit comments

Comments
 (0)