Fix sandbox file write issue: use start-delay-ms for display helper

The sandboxed XCTest runner can't write the start signal file to /tmp/.
Added --start-delay-ms to create-virtual-display.m as alternative to
--start-path. CI uses 10s delay so the test captures baseline render
stats before churn begins. Test skips start signal write when
pre-launched.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
austinpower1258 2026-03-23 04:16:57 -07:00
parent 0c4415ceba
commit 82a9ccf218
3 changed files with 20 additions and 9 deletions

View file

@ -523,15 +523,18 @@ jobs:
for attempt in 1 2; do
cleanup 2>/dev/null || true
# Launch display helper from shell (non-sandboxed)
# Launch display helper from shell (non-sandboxed).
# Use --start-delay-ms instead of --start-path because the XCTest
# runner is sandboxed and can't write to /tmp/ for the start signal.
# 10s delay gives the test time to capture baseline render stats.
"$HELPER_PATH" \
--modes "1920x1080,1728x1117,1600x900,1440x810" \
--ready-path "$DISPLAY_READY" \
--display-id-path "$DISPLAY_ID_PATH" \
--start-path "$DISPLAY_START" \
--done-path "$DISPLAY_DONE" \
--iterations 40 \
--interval-ms 40 \
--start-delay-ms 10000 \
> "$HELPER_LOG" 2>&1 &
HELPER_PID=$!
@ -619,7 +622,7 @@ jobs:
# Write manifests so test can find the pre-launched state
MANIFEST_PATH="/tmp/cmux-ui-test-display-harness.json"
cat >"$MANIFEST_PATH" <<MANIFEST_EOF
{"readyPath":"$DISPLAY_READY","displayIDPath":"$DISPLAY_ID_PATH","startPath":"$DISPLAY_START","donePath":"$DISPLAY_DONE","logPath":"$HELPER_LOG"}
{"readyPath":"$DISPLAY_READY","displayIDPath":"$DISPLAY_ID_PATH","donePath":"$DISPLAY_DONE","logPath":"$HELPER_LOG"}
MANIFEST_EOF
PRELAUNCH_PATH="/tmp/cmux-ui-test-prelaunch.json"

View file

@ -82,11 +82,15 @@ final class DisplayResolutionRegressionUITests: XCTestCase {
var maxDiagnosticsUpdatedAt = baselineStats.diagnosticsUpdatedAt
var lastStats = baselineStats
do {
try Data("start\n".utf8).write(to: URL(fileURLWithPath: displayStartPath), options: .atomic)
} catch {
XCTFail("Expected start signal file to be created at \(displayStartPath): \(error)")
return
// When pre-launched from CI, the display helper uses --start-delay-ms
// instead of a start signal file (sandbox prevents writing to /tmp/).
if prelaunch == nil {
do {
try Data("start\n".utf8).write(to: URL(fileURLWithPath: displayStartPath), options: .atomic)
} catch {
XCTFail("Expected start signal file to be created at \(displayStartPath): \(error)")
return
}
}
let deadline = Date().addingTimeInterval(30.0)

View file

@ -166,6 +166,8 @@ int main(int argc, const char *argv[]) {
NSString *intervalArgument = argumentValue(arguments, @"--interval-ms");
NSInteger intervalMs = intervalArgument.length > 0 ? intervalArgument.integerValue : 40;
useconds_t intervalMicros = (useconds_t)(MAX(1, intervalMs) * 1000);
NSString *startDelayArgument = argumentValue(arguments, @"--start-delay-ms");
NSInteger startDelayMs = startDelayArgument.length > 0 ? startDelayArgument.integerValue : 0;
unsigned int width = 0;
unsigned int height = 0;
@ -229,7 +231,9 @@ int main(int argc, const char *argv[]) {
if (iterations > 0 && modeSpecs.count > 1) {
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
if (startPath.length > 0) {
if (startDelayMs > 0) {
usleep((useconds_t)(startDelayMs * 1000));
} else if (startPath.length > 0) {
while (![[NSFileManager defaultManager] fileExistsAtPath:startPath]) {
usleep(20 * 1000);
}