using AcDream.App.Rendering.Gpu.Vk;
namespace AcDream.App.Tests.Rendering.Gpu.Vk;
///
/// Campaign V slice V9: the probe harness's bounded-run decision.
///
/// The harness presents until its window closes, which is right at a desk
/// and impossible in CI — nothing there ever closes a window.
/// ACDREAM_VULKAN_PROBE_FRAMES gives it a frame budget instead. Every
/// other line of the harness needs a window and a driver; this decision does
/// not, so it is tested here rather than left to the lavapipe job to discover.
///
///
public sealed class VulkanBringUpBudgetTests
{
///
/// The interactive default. An unset or malformed budget is zero, and zero
/// must never retire the loop, or the developer diagnostic this harness
/// exists for would close itself the moment it opened.
///
[Theory]
[InlineData(0)]
[InlineData(-1)]
public void ANonPositiveBudgetNeverRetires(int budget)
{
Assert.False(
VulkanBringUpHost.ShouldRetire(
budget,
presentedFrames: 10_000,
capturesScreenshot: true,
screenshotRequested: true));
}
[Fact]
public void TheLoopRunsUntilTheBudgetIsReached()
{
Assert.False(
VulkanBringUpHost.ShouldRetire(
frameBudget: 30,
presentedFrames: 29,
capturesScreenshot: false,
screenshotRequested: false));
Assert.True(
VulkanBringUpHost.ShouldRetire(
frameBudget: 30,
presentedFrames: 30,
capturesScreenshot: false,
screenshotRequested: false));
}
///
/// The invariant the CI render gate rests on: a run that owes a PNG cannot
/// exit before the capture has been attempted. The harness captures at frame
/// four, so a budget below that would otherwise exit with an empty artifact
/// directory and a green step — the one outcome an unattended render gate
/// must never produce.
///
[Fact]
public void ARunThatOwesAScreenshotStaysOpenUntilItHasBeenAttempted()
{
Assert.False(
VulkanBringUpHost.ShouldRetire(
frameBudget: 2,
presentedFrames: 2,
capturesScreenshot: true,
screenshotRequested: false));
Assert.True(
VulkanBringUpHost.ShouldRetire(
frameBudget: 2,
presentedFrames: 4,
capturesScreenshot: true,
screenshotRequested: true));
}
///
/// With no artifact directory there is no PNG to wait for, so the budget is
/// the only term.
///
[Fact]
public void ARunWithNoArtifactDirectoryRetiresOnTheBudgetAlone()
{
Assert.True(
VulkanBringUpHost.ShouldRetire(
frameBudget: 1,
presentedFrames: 1,
capturesScreenshot: false,
screenshotRequested: false));
}
}