diff options
Diffstat (limited to 'test/image_harness.zig')
| -rw-r--r-- | test/image_harness.zig | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/test/image_harness.zig b/test/image_harness.zig index 21ec706e..1141d81f 100644 --- a/test/image_harness.zig +++ b/test/image_harness.zig @@ -231,8 +231,11 @@ fn runKitty(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !vo var h = try eh.Harness.initArgs(gpa, exe, 12, 30, image_path); defer h.deinit(); - try h.pump(150); - try h.expectRawContains("\x1b_Gi=1,a=q\x1b\\", "app did not issue the Kitty graphics capability query"); + try h.expectRawWaitFor( + "\x1b_Gi=1,a=q\x1b\\", + 5000, + "app did not issue the Kitty graphics capability query", + ); // APC says graphics is present; DA1 is the last capability response and // closes the asynchronous handshake. Arrow-up is an ordinary queued event @@ -278,8 +281,11 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) var h = try eh.Harness.initArgs(gpa, exe, 16, 40, pdf_path); defer h.deinit(); - try h.pump(150); - try h.expectRawContains("\x1b_Gi=1,a=q\x1b\\", "app did not issue the Kitty graphics capability query"); + try h.expectRawWaitFor( + "\x1b_Gi=1,a=q\x1b\\", + 5000, + "app did not issue the Kitty graphics capability query", + ); try h.send("\x1b_Gi=1;OK\x1b\\\x1b[?1;2c\x1b[A"); const transmit = "\x1b_Gf=32,s=96,v=64,i="; @@ -514,27 +520,24 @@ fn runGui(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !void var h = try eh.Harness.initArgs(gpa, exe, 10, 20, image_path); defer h.deinit(); - try h.pump(1200); - - const capture = readFile(gpa, capture_path) catch |err| { - std.debug.print("SDL image harness produced no capture ({t}); raw child output: {s}\n", .{ err, h.raw.items }); - return err; - }; - defer gpa.free(capture); - const pixels = ppmPixels(capture) orelse return error.BadCapture; - var exact: usize = 0; - var i: usize = 0; - while (i + 2 < pixels.len) : (i += 3) { - if (std.mem.eql(u8, pixels[i .. i + 3], &fixture_rgb)) exact += 1; - } // The source contributes 512 aligned pixels. Leave ample room for driver // filtering while still excluding glyph-art fallback and incidental UI // colors. - if (exact < 200) { - std.debug.print("SDL image harness found only {d} native-color pixels in the GPU capture\n", .{exact}); - return error.NativePixelsMissing; - } - std.debug.print("native image harness ok: SDL GPU capture ({d} source pixels)\n", .{exact}); + // + // WAIT for the capture rather than budget a fixed startup and read once. + // The first frame lands when the GPU device is ready, and on a host whose + // only SPIR-V backend is vulkan-on-MoltenVK that is ~0.7s idle and past + // 1.9s under load — a 1200ms budget made this arm fail with an unwritten + // latest.ppm while the device was still coming up. Same deadline the PDF + // arm below already gives its first capture. + const bounds = waitForCaptureBounds(&h, capture_path, fixture_rgb, 200, 5000) catch |err| { + std.debug.print( + "SDL image harness produced no usable capture ({t}); raw child output: {s}\n", + .{ err, h.raw.items }, + ); + return err; + }; + std.debug.print("native image harness ok: SDL GPU capture ({d} source pixels)\n", .{bounds.count}); } fn runGuiPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !void { @@ -681,8 +684,8 @@ fn waitForCaptureBounds( } else |_| {} _ = try h.pumpOnce(50); } - std.debug.print("SDL PDF harness found only {d} pixels of color {any}\n", .{ best, color }); - return error.PdfPageColorMissing; + std.debug.print("SDL harness found only {d} pixels of color {any}\n", .{ best, color }); + return error.CaptureColorMissing; } fn expectThemeGap( |
