fix(windows): launch commands on the interactive desktop

This commit is contained in:
cabbage committed 2026-10-27 18:35:29 +00:00
1 parent 30e7bb8545
commit 8d28925e44
20 files changed
+1036 -28

No files matched your search

+3 -2
View File
@@ -10,7 +10,7 @@ usage() {
usage: scripts/windows/build-test-bundle --run-id ID --config FILE [--ca FILE] [--no-build] [--native-fixture]
Builds bin/rvbox.exe in the pinned Docker toolchain, then creates exactly:
.test-runs/ID/windows-bundle/{rvbox.exe,client.toml[,ca.pem],manifest.sha256}
.test-runs/ID/windows-bundle/{rvbox.exe,client.toml,windows_gui_probe.ps1[,ca.pem],manifest.sha256}
The bundle is for the resettable native-test fixture only. The config must use
the target guest paths and the declared test nginx endpoint. Existing bundles
@@ -75,6 +75,7 @@ trap 'rmdir "$bundle" 2>/dev/null || true' INT TERM HUP
install -m 700 "$binary" "$bundle/rvbox.exe"
install -m 600 "$config" "$bundle/client.toml"
install -m 644 "$repo_root/skills/rvbox/scripts/windows_gui_probe.ps1" "$bundle/windows_gui_probe.ps1"
if [ -n "$ca" ]; then install -m 600 "$ca" "$bundle/ca.pem"; fi
commit=$(git -C "$repo_root" rev-parse HEAD)
@@ -82,7 +83,7 @@ commit=$(git -C "$repo_root" rev-parse HEAD)
printf 'run_id=%s\n' "$run_id"
printf 'git_commit=%s\n' "$commit"
printf 'native_fixture=%s\n' "$native_fixture"
(cd "$bundle" && sha256sum rvbox.exe client.toml ${ca:+ca.pem})
(cd "$bundle" && sha256sum rvbox.exe client.toml windows_gui_probe.ps1 ${ca:+ca.pem})
} >"$bundle/manifest.sha256"
chmod 600 "$bundle/manifest.sha256"
+34
View File
@@ -188,6 +188,37 @@ assert_stdin_close() {
fail "stdin command did not reach terminal success"
}
assert_gui() {
gui_label=$1
gui_elevated=$2
gui_probe_command="@powershell.exe -NoLogo -NoProfile -STA -ExecutionPolicy Bypass -File \"C:/ProgramData/RVBox/test-runs/$run_id/windows_gui_probe.ps1\" -Seconds 2"
if [ "$gui_elevated" = yes ]; then
gui_result=$(rvc run --elevated --shell cmd "$client_id" "$gui_probe_command" 2>&1) || fail "GUI probe RPC failed: $gui_result"
else
gui_result=$(rvc run --shell cmd "$client_id" "$gui_probe_command" 2>&1) || fail "GUI probe RPC failed: $gui_result"
fi
printf '%s\n' "$gui_result" >"$fixture_dir/gui-$gui_label.log"
gui_issue=$(printf '%s\n' "$gui_result" | awk 'NR == 1 { print $1 }')
case $gui_issue in ????????-????-7???-????-????????????) ;; *) fail "GUI probe returned invalid issue UUID: $gui_result" ;; esac
gui_state=$(rvc stat "$client_id" "$gui_issue") || fail "GUI probe status failed"
printf '%s\n' "$gui_state" >"$fixture_dir/gui-$gui_label.stat"
printf '%s\n' "$gui_state" | grep -q 'lifecycle=COMMAND_SUCCEEDED' || fail "GUI probe failed: $gui_state (see gui-$gui_label.log)"
printf '%s\n' "$gui_result" | python3 -c '
import json, sys
reports = [json.loads(line) for line in sys.stdin if line.lstrip().startswith("{")]
if len(reports) != 1:
raise SystemExit("GUI probe did not return exactly one report")
r = reports[0]
if not (r.get("window_observed") and r.get("session_id", 0) > 0 and
r.get("window_station", "").lower() == "winsta0" and
r.get("desktop", "").lower() == "default" and
r.get("input_desktop", "").lower() == "default" and
r.get("console_window_visible") is False):
raise SystemExit("GUI probe did not observe a real window on the unlocked input desktop")
' || fail "GUI visibility/desktop assertion failed; inspect gui-$gui_label.log"
printf 'passed gui-%s issue=%s\n' "$gui_label" "$gui_issue"
}
assert_signal_term() {
issued=$(rvc run --background --shell cmd "$client_id" 'ping -t 127.0.0.1 >NUL' 2>&1) || fail "signal command admission failed: $issued"
issue=$(printf '%s\n' "$issued" | awk 'NR == 1 { print $1 }')
@@ -300,10 +331,13 @@ case $action in
assert_signal_term
assert_server_restart_reconnect
assert_context active-user no active-user
assert_gui active-user no
assert_context active-user-elevated yes active-user-elevated
assert_gui active-user-elevated yes
"$repo_root/scripts/windows/test-host" run --run-id "$run_id" --fail-contexts ACTIVE_USER_ELEVATED
wait_client
assert_context active-system yes active-system
assert_gui active-system yes
"$repo_root/scripts/windows/test-host" run --run-id "$run_id" --fail-contexts ACTIVE_USER_ELEVATED,ACTIVE_SYSTEM
wait_client
assert_context local-system-active-fallback yes local-system
+13 -8
View File
@@ -550,6 +550,10 @@ case "$action" in
require_lease
VBoxManage guestcontrol "$vm" --username "$guest_user" --passwordfile "$password_file" \
copyto "$host_stage/client.toml" "$guest_root\\client.toml" </dev/null
if [ -f "$host_stage/windows_gui_probe.ps1" ]; then
VBoxManage guestcontrol "$vm" --username "$guest_user" --passwordfile "$password_file" \
copyto "$host_stage/windows_gui_probe.ps1" "$guest_root\\windows_gui_probe.ps1" </dev/null
fi
;;
stage-copy-ca)
assert_identity
@@ -847,14 +851,19 @@ case $action in
remote prepare-stage
[ -f "$bundle/rvbox.exe" ] && [ ! -L "$bundle/rvbox.exe" ] || fail "rvbox.exe must be a regular non-symlink file"
[ -f "$bundle/client.toml" ] && [ ! -L "$bundle/client.toml" ] || fail "client.toml must be a regular non-symlink file"
bundle_files='rvbox.exe client.toml'
if [ -f "$bundle/ca.pem" ]; then
[ ! -L "$bundle/ca.pem" ] || fail "ca.pem must not be a symlink"
local_hashes=$(cd "$bundle" && sha256sum rvbox.exe client.toml ca.pem)
else
local_hashes=$(cd "$bundle" && sha256sum rvbox.exe client.toml)
bundle_files="$bundle_files ca.pem"
fi
if [ -f "$bundle/windows_gui_probe.ps1" ]; then
[ ! -L "$bundle/windows_gui_probe.ps1" ] || fail "GUI probe must not be a symlink"
bundle_files="$bundle_files windows_gui_probe.ps1"
fi
local_hashes=$(cd "$bundle" && sha256sum $bundle_files)
copy_stage_file "$bundle/client.toml" client.toml
if [ -f "$bundle/ca.pem" ]; then copy_stage_file "$bundle/ca.pem" ca.pem; fi
if [ -f "$bundle/windows_gui_probe.ps1" ]; then copy_stage_file "$bundle/windows_gui_probe.ps1" windows_gui_probe.ps1; fi
local_exe_hash=$(sha256sum "$bundle/rvbox.exe" | awk '{print $1}')
remote_exe_hash=$(ssh -o BatchMode=yes "$RVBOX_TEST_VBOX_HOST" "sha256sum '$host_stage/rvbox.exe' 2>/dev/null | awk '{print \$1}'" 2>/dev/null || true)
if [ "$local_exe_hash" = "$remote_exe_hash" ]; then
@@ -863,11 +872,7 @@ case $action in
accelerated_stage || fail "accelerated executable transfer failed"
trap 'if [ -n "$accelerated_artifact" ]; then rm -f "$accelerated_artifact"; fi' EXIT HUP INT TERM
fi
if [ -f "$bundle/ca.pem" ]; then
remote_hashes=$(ssh -o BatchMode=yes "$RVBOX_TEST_VBOX_HOST" "cd '$host_stage' && sha256sum rvbox.exe client.toml ca.pem" 2>/dev/null || true)
else
remote_hashes=$(ssh -o BatchMode=yes "$RVBOX_TEST_VBOX_HOST" "cd '$host_stage' && sha256sum rvbox.exe client.toml" 2>/dev/null || true)
fi
remote_hashes=$(ssh -o BatchMode=yes "$RVBOX_TEST_VBOX_HOST" "cd '$host_stage' && sha256sum $bundle_files" 2>/dev/null || true)
[ "$local_hashes" = "$remote_hashes" ] || fail "bundle transfer did not reach the expected SHA-256 manifest"
printf 'verified transfer_sha256 run_id=%s\n%s\n' "$run_id" "$local_hashes"
remote stage