-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSmokeTestRunner.cs
More file actions
2960 lines (2601 loc) · 111 KB
/
SmokeTestRunner.cs
File metadata and controls
2960 lines (2601 loc) · 111 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
namespace lifeviz;
internal static class SmokeTestRunner
{
private static readonly int[] CurrentScenePresetRows = { 144, 240, 480, 720, 1080, 1440, 2160 };
private static readonly int[] RealtimePacingRows = { 144, 240, 480 };
private static readonly TimeSpan CurrentSceneProfileWarmupDuration = TimeSpan.FromSeconds(4);
private static readonly TimeSpan CurrentScenePresetProfileDuration = TimeSpan.FromSeconds(6);
private static readonly TimeSpan RealtimePacingProfileDuration = TimeSpan.FromSeconds(8);
private const double RealtimePacingTargetFps = 60.0;
private static readonly string[] CurrentSceneBisectVariants =
{
"baseline",
"no-audio",
"no-video",
"no-sim-groups",
"first-static-only"
};
public static bool TryRun(string[] args, out int exitCode)
{
exitCode = 0;
if (args.Length < 2 || !string.Equals(args[0], "--smoke-test", StringComparison.OrdinalIgnoreCase))
{
return false;
}
Logger.Initialize();
App.SuppressErrorDialogs = true;
App.IsSmokeTestMode = true;
try
{
string target = args[1].Trim();
App.CaptureGpuFallbackBuffersInSmokeTest =
!(target.StartsWith("profile-", StringComparison.OrdinalIgnoreCase) ||
target.StartsWith("pacing-", StringComparison.OrdinalIgnoreCase));
string? smokeVideoPath = args.Length >= 3 ? args[2] : Environment.GetEnvironmentVariable("LIFEVIZ_SMOKE_VIDEO");
if (TryRunCurrentScenePresetProfileTarget(target, out exitCode))
{
return true;
}
exitCode = target.ToLowerInvariant() switch
{
"profile-240" => RunFrameProfileSmokeTest(240, "smoke-mainloop-240p"),
"profile-480" => RunFrameProfileSmokeTest(480, "smoke-mainloop-480p"),
"profile-rgb-240" => RunFrameProfileSmokeTest(240, "smoke-mainloop-rgb-240p", rgbMode: true),
"profile-rgb-480" => RunFrameProfileSmokeTest(480, "smoke-mainloop-rgb-480p", rgbMode: true),
"profile-file-240" => RunFrameProfileSmokeTest(240, "smoke-mainloop-file-240p", rgbMode: false, smokeVideoPath),
"profile-file-480" => RunFrameProfileSmokeTest(480, "smoke-mainloop-file-480p", rgbMode: false, smokeVideoPath),
"profile-file-rgb-240" => RunFrameProfileSmokeTest(240, "smoke-mainloop-file-rgb-240p", rgbMode: true, smokeVideoPath),
"profile-file-rgb-480" => RunFrameProfileSmokeTest(480, "smoke-mainloop-file-rgb-480p", rgbMode: true, smokeVideoPath),
"profile-current-scene" => RunCurrentSceneProfileSmokeTest(visibleWindow: false),
"profile-current-scene-visible" => RunCurrentSceneProfileSmokeTest(visibleWindow: true),
"profile-current-scene-fullscreen" => RunCurrentSceneProfileSmokeTest(visibleWindow: true, forcedRows: null, fullscreen: true),
"profile-current-scene-bisect" => RunCurrentSceneBisectSmokeTest(),
"profile-current-scene-presets" => RunCurrentScenePresetProfileSmokeSuite(visibleWindow: false),
"profile-current-scene-visible-presets" => RunCurrentScenePresetProfileSmokeSuite(visibleWindow: true),
"profile-current-scene-fullscreen-presets" => RunCurrentScenePresetProfileSmokeSuite(visibleWindow: true, fullscreen: true),
"profile-current-scene-interaction" => RunCurrentSceneInteractionProfileSmokeTest(),
"current-scene-hover-presentation" => RunCurrentSceneHoverPresentationSmokeTest(),
"pacing-current-scene-visible-presets" => RunCurrentScenePacingSmokeSuite(visibleWindow: true),
"pacing-current-scene-fullscreen-presets" => RunCurrentScenePacingSmokeSuite(visibleWindow: true, fullscreen: true),
"pacing-current-scene-interaction" => RunCurrentSceneInteractionPacingSmokeTest(),
"pacing-current-scene-overlay-fullscreen-144" => RunCurrentSceneOverlayPacingSmokeTest(fullscreen: true, rows: 144),
"pacing-current-scene-suite" => RunCurrentScenePacingSuite(),
"frame-pump-thread-safety" => RunFramePumpThreadSafetySmokeTest(),
"gpu-benchmark" => RunGpuBenchmark(),
"gpu-handoff" => RunGpuCompositeToSimulationSmokeTest(),
"gpu-rgb-threshold" => RunGpuCompositeRgbThresholdSmokeTest(),
"gpu-passthrough-signed-model" => RunGpuPassthroughSignedModelSmokeTest(),
"passthrough-underlay-only" => RunPassthroughUnderlayOnlySmokeTest(),
"gpu-frequency-hue" => RunGpuFrequencyHueSmokeTest(),
"simulation-reactive-mappings" => RunSimulationReactiveMappingsSmokeTest(),
"pixel-sort-reactive-cell-size" => RunPixelSortReactiveCellSizeSmokeTest(),
"simulation-reactive-persistence" => RunSimulationReactiveMappingsPersistenceSmokeTest(),
"simulation-reactive-legacy-migration" => RunSimulationReactiveLegacyMigrationSmokeTest(),
"simulation-reactive-removal" => RunSimulationReactiveRemovalSmokeTest(),
"simulation-reactive-editor-isolation" => RunSimulationReactiveEditorIsolationSmokeTest(),
"sim-group-legacy-migration" => RunSimGroupLegacyMigrationSmokeTest(),
"no-sim-group-renders-composite" => RunNoSimGroupRendersCompositeSmokeTest(),
"sim-group-removal-clears-runtime" => RunSimGroupRemovalClearsRuntimeSmokeTest(),
"disabled-sim-group-renders-composite" => RunDisabledSimGroupRendersCompositeSmokeTest(),
"sim-group-stack-order" => RunSimGroupStackOrderSmokeTest(),
"sim-group-inline-hue" => RunSimGroupInlineHueSmokeTest(),
"sim-group-inline-presentation" => RunSimGroupInlinePresentationSmokeTest(),
"sim-group-enabled-toggle" => RunSimGroupEnabledToggleSmokeTest(),
"sim-group-remove-source" => RunSimGroupRemoveSourceSmokeTest(),
"sim-group-live-edit-selection" => RunSimGroupLiveEditSelectionSmokeTest(),
"pixel-sort-editor-roundtrip" => RunPixelSortEditorRoundTripSmokeTest(),
"gpu-pixel-sort" => RunGpuPixelSortSmokeTest(),
"sim-group-pixel-sort-color" => RunSimGroupPixelSortColorSmokeTest(),
"gpu-injection-mode" => RunGpuInjectionModeSmokeTest(),
"gpu-file-injection-mode" => RunGpuFileInjectionModeSmokeTest(smokeVideoPath),
"gpu-sim" => RunGpuSimulationSmokeTest(),
"gpu-source" => RunGpuSourceCompositeSmokeTest(),
"source-reset" => RunSourceResetSmokeTest(),
"gpu-render" => RunGpuPresentationSmokeTest(),
"profile-mainloop" => RunFrameProfileSmokeTest(),
"profile-mainloop-sim-group" => RunFrameProfileSmokeTest(240, "smoke-mainloop-sim-group", rgbMode: false, smokeVideoPath: null, includeSimGroup: true),
"dimensions" => RunDimensionChangeSmokeTest(),
"shutdown" => RunShutdownSmokeTest(),
"startup" => RunStartupSmokeTest(),
"startup-recovery" => RunStartupRecoverySmokeTest(),
"all" => RunAllSmokeTests(),
_ => throw new ArgumentException($"Unknown smoke test target '{target}'. Expected profile-240, profile-480, profile-rgb-240, profile-rgb-480, profile-file-240, profile-file-480, profile-file-rgb-240, profile-file-rgb-480, profile-current-scene, profile-current-scene-visible, profile-current-scene-fullscreen, profile-current-scene-bisect, profile-current-scene-presets, profile-current-scene-visible-presets, profile-current-scene-fullscreen-presets, profile-current-scene-<144|240|480|720|1080|1440|2160>, profile-current-scene-visible-<144|240|480|720|1080|1440|2160>, profile-current-scene-fullscreen-<144|240|480|720|1080|1440|2160>, profile-current-scene-interaction, current-scene-hover-presentation, pacing-current-scene-visible-presets, pacing-current-scene-fullscreen-presets, pacing-current-scene-interaction, pacing-current-scene-overlay-fullscreen-144, pacing-current-scene-suite, frame-pump-thread-safety, gpu-benchmark, gpu-handoff, gpu-rgb-threshold, gpu-passthrough-signed-model, passthrough-underlay-only, gpu-frequency-hue, simulation-reactive-mappings, pixel-sort-reactive-cell-size, simulation-reactive-persistence, simulation-reactive-legacy-migration, simulation-reactive-removal, simulation-reactive-editor-isolation, sim-group-legacy-migration, no-sim-group-renders-composite, sim-group-removal-clears-runtime, disabled-sim-group-renders-composite, sim-group-stack-order, sim-group-inline-hue, sim-group-inline-presentation, sim-group-enabled-toggle, sim-group-remove-source, sim-group-live-edit-selection, pixel-sort-editor-roundtrip, gpu-pixel-sort, sim-group-pixel-sort-color, gpu-injection-mode, gpu-file-injection-mode, gpu-sim, gpu-source, source-reset, gpu-render, profile-mainloop, profile-mainloop-sim-group, dimensions, shutdown, startup, startup-recovery, or all.")
};
}
catch (Exception ex)
{
Logger.Error("Smoke test failed.", ex);
Console.Error.WriteLine(ex);
exitCode = 1;
}
finally
{
Logger.Shutdown();
App.SuppressErrorDialogs = false;
App.IsSmokeTestMode = false;
App.LoadUserConfigInSmokeTest = false;
App.CaptureGpuFallbackBuffersInSmokeTest = true;
}
return true;
}
private static int RunAllSmokeTests()
{
int gpuResult = RunGpuSimulationSmokeTest();
if (gpuResult != 0)
{
return gpuResult;
}
return RunGpuUiSmokeSuite();
}
private static bool TryRunCurrentScenePresetProfileTarget(string target, out int exitCode)
{
exitCode = 0;
const string hiddenPrefix = "profile-current-scene-";
const string visiblePrefix = "profile-current-scene-visible-";
const string fullscreenPrefix = "profile-current-scene-fullscreen-";
bool visibleWindow;
bool fullscreen;
string? suffix;
if (target.StartsWith(fullscreenPrefix, StringComparison.OrdinalIgnoreCase))
{
visibleWindow = true;
fullscreen = true;
suffix = target.Substring(fullscreenPrefix.Length);
}
else if (target.StartsWith(visiblePrefix, StringComparison.OrdinalIgnoreCase))
{
visibleWindow = true;
fullscreen = false;
suffix = target.Substring(visiblePrefix.Length);
}
else if (target.StartsWith(hiddenPrefix, StringComparison.OrdinalIgnoreCase))
{
visibleWindow = false;
fullscreen = false;
suffix = target.Substring(hiddenPrefix.Length);
}
else
{
return false;
}
if (!int.TryParse(suffix, out int rows) || !CurrentScenePresetRows.Contains(rows))
{
return false;
}
exitCode = RunCurrentSceneProfileSmokeTest(visibleWindow, rows, fullscreen);
return true;
}
private static int RunFramePumpThreadSafetySmokeTest()
{
Logger.Info("Running frame pump thread-safety smoke test.");
var app = new App();
bool ok = false;
Exception? capturedException = null;
app.Startup += (_, _) =>
{
var window = new MainWindow();
try
{
window.Show();
ok = window.RunFramePumpThreadSafetySmoke();
}
catch (Exception ex)
{
capturedException = ex;
}
finally
{
if (window.IsVisible)
{
window.Close();
}
app.Shutdown();
}
};
app.Run();
if (capturedException != null)
{
throw capturedException;
}
if (!ok)
{
throw new InvalidOperationException("Frame pump thread-safety smoke test failed.");
}
Logger.Info("Frame pump thread-safety smoke test passed.");
return 0;
}
private static int RunGpuSimulationSmokeTest()
{
Logger.Info("Running GPU simulation smoke test.");
using var backend = new GpuSimulationBackend();
backend.Configure(144, 24, 16d / 9d);
backend.SetBinningMode(GameOfLifeEngine.BinningMode.Fill);
backend.SetInjectionMode(GameOfLifeEngine.InjectionMode.Threshold);
backend.SetMode(GameOfLifeEngine.LifeMode.NaiveGrayscale);
if (!backend.IsGpuAvailable || !backend.IsGpuActive)
{
throw new InvalidOperationException("GPU simulation backend did not activate for Naive Grayscale mode.");
}
bool[,] mask = BuildHalfPlaneMask(backend.Rows, backend.Columns);
backend.InjectFrame(mask);
for (int i = 0; i < 4; i++)
{
backend.Step();
}
byte[] fillBuffer = new byte[backend.Columns * backend.Rows * 4];
backend.FillColorBuffer(fillBuffer);
ValidateColorBuffer(fillBuffer, "GPU grayscale fill");
backend.SetBinningMode(GameOfLifeEngine.BinningMode.Binary);
byte[] binaryBuffer = new byte[backend.Columns * backend.Rows * 4];
backend.FillColorBuffer(binaryBuffer);
ValidateColorBuffer(binaryBuffer, "GPU grayscale binary");
backend.SetMode(GameOfLifeEngine.LifeMode.RgbChannels);
if (!backend.IsGpuActive)
{
throw new InvalidOperationException("GPU simulation backend did not stay active for RGB Channel Bins mode.");
}
var (r, g, b) = BuildRgbMasks(backend.Rows, backend.Columns);
backend.InjectRgbFrame(r, g, b);
backend.Step();
byte[] rgbBuffer = new byte[backend.Columns * backend.Rows * 4];
backend.FillColorBuffer(rgbBuffer);
ValidateColorBuffer(rgbBuffer, "GPU RGB");
backend.SetMode(GameOfLifeEngine.LifeMode.NaiveGrayscale);
if (!backend.IsGpuActive)
{
throw new InvalidOperationException("GPU simulation backend did not reactivate after returning to Naive Grayscale.");
}
Logger.Info("GPU simulation smoke test passed.");
return 0;
}
private static int RunGpuPixelSortSmokeTest()
{
Logger.Info("Running GPU pixel sort smoke test.");
var window = new MainWindow();
try
{
return window.RunGpuPixelSortSmoke() ? 0 : 1;
}
finally
{
window.Close();
}
}
private static int RunSimGroupPixelSortColorSmokeTest()
{
Logger.Info("Running sim-group pixel sort color smoke test.");
var window = new MainWindow();
try
{
return window.RunSimGroupPixelSortColorSmoke() ? 0 : 1;
}
finally
{
window.Close();
}
}
private static int RunGpuBenchmark()
{
Logger.Info("Running GPU benchmark.");
const int simulationIterations = 180;
using (var backend = new GpuSimulationBackend())
{
backend.Configure(144, 24, 16d / 9d);
backend.SetBinningMode(GameOfLifeEngine.BinningMode.Fill);
backend.SetInjectionMode(GameOfLifeEngine.InjectionMode.Threshold);
backend.SetMode(GameOfLifeEngine.LifeMode.NaiveGrayscale);
if (!backend.IsGpuAvailable || !backend.IsGpuActive)
{
throw new InvalidOperationException("GPU simulation backend did not activate for benchmark.");
}
bool[,] mask = BuildHalfPlaneMask(backend.Rows, backend.Columns);
byte[] colorBuffer = new byte[backend.Columns * backend.Rows * 4];
for (int i = 0; i < 12; i++)
{
backend.InjectFrame(mask);
backend.Step();
backend.FillColorBuffer(colorBuffer);
}
long injectTicks = 0;
long stepTicks = 0;
long fillTicks = 0;
for (int i = 0; i < simulationIterations; i++)
{
long start = Stopwatch.GetTimestamp();
backend.InjectFrame(mask);
injectTicks += Stopwatch.GetTimestamp() - start;
start = Stopwatch.GetTimestamp();
backend.Step();
stepTicks += Stopwatch.GetTimestamp() - start;
start = Stopwatch.GetTimestamp();
backend.FillColorBuffer(colorBuffer);
fillTicks += Stopwatch.GetTimestamp() - start;
}
double tickScale = 1000.0 / Stopwatch.Frequency;
Logger.Info(
$"GPU sim benchmark: {backend.Columns}x{backend.Rows} depth {backend.Depth}, " +
$"inject {injectTicks * tickScale / simulationIterations:0.###} ms, " +
$"step {stepTicks * tickScale / simulationIterations:0.###} ms, " +
$"fill/readback {fillTicks * tickScale / simulationIterations:0.###} ms.");
}
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
if (!IsKnownSmokeTeardownException(args.Exception))
{
failure ??= args.Exception;
}
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
const int compositeIterations = 180;
var result = window.RunGpuSourceCompositeBenchmark(compositeIterations);
if (!result.ok || result.buildCount <= 0)
{
failure ??= new InvalidOperationException("GPU source composite benchmark did not produce a valid composite.");
app.Shutdown(1);
return;
}
Logger.Info(
$"GPU source benchmark: {result.width}x{result.height}, " +
$"{result.buildCount} builds, {result.passCount} passes, " +
$"upload {result.uploadMs / result.buildCount:0.###} ms, " +
$"draw {result.drawMs / result.buildCount:0.###} ms, " +
$"readback {result.readbackMs / result.buildCount:0.###} ms.");
var handoff = window.RunGpuCompositeToSimulationBenchmark(compositeIterations);
if (!handoff.ok || handoff.buildCount <= 0)
{
failure ??= new InvalidOperationException("GPU composite-to-simulation benchmark did not produce a valid handoff.");
app.Shutdown(1);
return;
}
Logger.Info(
$"GPU handoff benchmark: {handoff.width}x{handoff.height}, " +
$"{handoff.buildCount} builds, {handoff.passCount} passes, " +
$"upload {handoff.uploadMs / handoff.buildCount:0.###} ms, " +
$"draw {handoff.drawMs / handoff.buildCount:0.###} ms, " +
$"readback {handoff.readbackMs / handoff.buildCount:0.###} ms, " +
$"inject {handoff.injectMs:0.###} ms, " +
$"step {handoff.stepMs:0.###} ms, " +
$"fill/readback {handoff.fillMs:0.###} ms.");
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU benchmark failed.", failure);
}
Logger.Info("GPU benchmark completed.");
return exitCode;
}
private static int RunGpuSourceCompositeSmokeTest()
{
Logger.Info("Running GPU source composite smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunGpuSourceCompositeSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("GPU source compositor did not produce a valid composite through MainWindow.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU source composite smoke test failed.", failure);
}
Logger.Info("GPU source composite smoke test passed.");
return exitCode;
}
private static int RunSourceResetSmokeTest()
{
Logger.Info("Running source reset smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
window.Loaded += (_, _) =>
{
window.Dispatcher.BeginInvoke(new Action(() =>
{
bool ok = window.RunSourceResetSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("Source reset path did not preserve visible passthrough output.");
app.Shutdown(1);
return;
}
window.Close();
app.Shutdown(0);
}), DispatcherPriority.ApplicationIdle);
};
window.Show();
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("Source reset smoke test failed.", failure);
}
Logger.Info("Source reset smoke test passed.");
return exitCode;
}
private static int RunGpuCompositeToSimulationSmokeTest()
{
Logger.Info("Running GPU composite-to-simulation handoff smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunGpuCompositeToSimulationSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("GPU composite-to-simulation handoff did not complete successfully.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU composite-to-simulation handoff smoke test failed.", failure);
}
Logger.Info("GPU composite-to-simulation handoff smoke test passed.");
return exitCode;
}
private static int RunGpuCompositeRgbThresholdSmokeTest()
{
Logger.Info("Running GPU RGB threshold smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunGpuCompositeRgbThresholdSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("GPU RGB threshold smoke did not complete successfully.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU RGB threshold smoke test failed.", failure);
}
Logger.Info("GPU RGB threshold smoke test passed.");
return exitCode;
}
private static int RunGpuInjectionModeSmokeTest()
{
Logger.Info("Running GPU injection-mode smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunGpuInjectionModeSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("GPU injection-mode smoke did not complete successfully.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU injection-mode smoke test failed.", failure);
}
Logger.Info("GPU injection-mode smoke test passed.");
return exitCode;
}
private static int RunGpuPassthroughSignedModelSmokeTest()
{
Logger.Info("Running GPU passthrough signed-model smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunGpuPassthroughSignedModelSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("GPU passthrough signed-model smoke did not complete successfully.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU passthrough signed-model smoke test failed.", failure);
}
Logger.Info("GPU passthrough signed-model smoke test passed.");
return exitCode;
}
private static int RunGpuFrequencyHueSmokeTest()
{
Logger.Info("Running GPU frequency-hue smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunGpuFrequencyHueSmoke();
if (!ok)
{
failure ??= new InvalidOperationException("GPU frequency-hue smoke did not complete successfully.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("GPU frequency-hue smoke test failed.", failure);
}
Logger.Info("GPU frequency-hue smoke test passed.");
return exitCode;
}
private static int RunPassthroughUnderlayOnlySmokeTest()
{
Logger.Info("Running passthrough underlay-only smoke test.");
Exception? failure = null;
var app = new App();
app.InitializeComponent();
app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
app.DispatcherUnhandledException += (_, args) =>
{
failure ??= args.Exception;
args.Handled = true;
app.Shutdown(1);
};
app.Startup += (_, _) =>
{
var window = new MainWindow
{
Width = 160,
Height = 120,
ShowInTaskbar = false,
ShowActivated = false,
WindowStartupLocation = WindowStartupLocation.Manual,
Left = -10000,
Top = -10000,
Opacity = 0.0
};
bool ok = window.RunPassthroughUnderlayOnlySmoke();
if (!ok)
{
failure ??= new InvalidOperationException("Passthrough underlay-only smoke did not complete successfully.");
app.Shutdown(1);
return;
}
app.Shutdown(0);
};
int exitCode = app.Run();
if (failure != null)
{
throw new InvalidOperationException("Passthrough underlay-only smoke test failed.", failure);
}
Logger.Info("Passthrough underlay-only smoke test passed.");
return exitCode;
}
private static int RunSimulationReactiveMappingsSmokeTest()
{
int exitCode = 0;
var thread = new Thread(() =>
{
try
{
var app = new App();
app.InitializeComponent();
var window = new MainWindow();
bool ok = window.RunSimulationReactiveMappingsSmoke();
window.Close();
app.Shutdown();
exitCode = ok ? 0 : 1;
}
catch (Exception ex)
{
Logger.Error("Simulation reactive mappings smoke failed.", ex);
Console.Error.WriteLine(ex);
exitCode = 1;
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return exitCode;
}
private static int RunPixelSortReactiveCellSizeSmokeTest()
{
int exitCode = 0;
var thread = new Thread(() =>
{
try
{
var app = new App();
app.InitializeComponent();
var window = new MainWindow();
bool ok = window.RunPixelSortReactiveCellSizeSmoke();
window.Close();
app.Shutdown();
exitCode = ok ? 0 : 1;
}
catch (Exception ex)
{
Logger.Error("Pixel sort reactive cell size smoke failed.", ex);
Console.Error.WriteLine(ex);
exitCode = 1;
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return exitCode;
}
private static int RunSimulationReactiveMappingsPersistenceSmokeTest()
{
int exitCode = 0;
var thread = new Thread(() =>
{
try
{
var app = new App();
app.InitializeComponent();
var window = new MainWindow();
bool ok = window.RunSimulationReactiveMappingsPersistenceSmoke();
window.Close();
app.Shutdown();
exitCode = ok ? 0 : 1;
}
catch (Exception ex)
{
Logger.Error("Simulation reactive persistence smoke failed.", ex);
Console.Error.WriteLine(ex);
exitCode = 1;
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return exitCode;
}
private static int RunSimulationReactiveLegacyMigrationSmokeTest()
{
int exitCode = 0;
var thread = new Thread(() =>
{
try
{
var app = new App();
app.InitializeComponent();
var window = new MainWindow();
bool ok = window.RunSimulationReactiveLegacyMigrationSmoke();
window.Close();
app.Shutdown();
exitCode = ok ? 0 : 1;
}
catch (Exception ex)
{
Logger.Error("Simulation reactive legacy migration smoke failed.", ex);
Console.Error.WriteLine(ex);
exitCode = 1;
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return exitCode;
}
private static int RunSimulationReactiveRemovalSmokeTest()
{
int exitCode = 0;
var thread = new Thread(() =>
{
try
{
var app = new App();
app.InitializeComponent();
var window = new MainWindow();
bool ok = window.RunSimulationReactiveRemovalSmoke();
window.Close();
app.Shutdown();
exitCode = ok ? 0 : 1;
}
catch (Exception ex)
{
Logger.Error("Simulation reactive removal smoke failed.", ex);
Console.Error.WriteLine(ex);
exitCode = 1;
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return exitCode;
}
private static int RunSimulationReactiveEditorIsolationSmokeTest()
{
int exitCode = 0;
var thread = new Thread(() =>
{
try
{