@@ -437,29 +437,43 @@ OSError spawnAndWaitSharedLibrary(TestContext* context, const String& testPath,
437
437
spawner.standardError_ = stdErrorString;
438
438
spawner.standardOutput_ = stdOutString;
439
439
440
- spawner.resultCode_ = TestToolUtil::getReturnCode (res);
440
+ spawner.resultCode_ = ( int ) TestToolUtil::getReturnCode (res);
441
441
442
442
return kOSError_None ;
443
443
}
444
444
445
445
return kOSError_OperationFailed ;
446
446
}
447
447
448
+ ToolReturnCode getReturnCode (OSProcessSpawner& spawner)
449
+ {
450
+ return TestToolUtil::getReturnCodeFromInt (spawner.getResultCode ());
451
+ }
448
452
449
- OSError spawnAndWait (TestContext* context, const String& testPath, SpawnType spawnType, OSProcessSpawner& spawner)
453
+ ToolReturnCode spawnAndWait (TestContext* context, const String& testPath, SpawnType spawnType, OSProcessSpawner& spawner)
450
454
{
455
+ OSError spawnResult = kOSError_OperationFailed ;
451
456
switch (spawnType)
452
457
{
453
458
case SpawnType::UseExe:
454
459
{
455
- return spawnAndWaitExe (context, testPath, spawner);
460
+ spawnResult = spawnAndWaitExe (context, testPath, spawner);
461
+ break ;
456
462
}
457
463
case SpawnType::UseSharedLibrary:
458
464
{
459
- return spawnAndWaitSharedLibrary (context, testPath, spawner);
465
+ spawnResult = spawnAndWaitSharedLibrary (context, testPath, spawner);
466
+ break ;
460
467
}
468
+ default : break ;
461
469
}
462
- return kOSError_OperationFailed ;
470
+
471
+ if (spawnResult != kOSError_None )
472
+ {
473
+ return ToolReturnCode::FailedToRun;
474
+ }
475
+
476
+ return getReturnCode (spawner);
463
477
}
464
478
465
479
String getOutput (OSProcessSpawner& spawner)
@@ -530,6 +544,25 @@ static void _initSlangCompiler(TestContext* context, OSProcessSpawner& spawnerOu
530
544
}
531
545
}
532
546
547
+ TestResult asTestResult (ToolReturnCode code)
548
+ {
549
+ switch (code)
550
+ {
551
+ case ToolReturnCode::Success: return TestResult::Pass;
552
+ case ToolReturnCode::Ignored: return TestResult::Ignored;
553
+ default : return TestResult::Fail;
554
+ }
555
+ }
556
+
557
+ #define TEST_RETURN_ON_DONE (x ) \
558
+ { \
559
+ const ToolReturnCode toolRet_ = x; \
560
+ if (TestToolUtil::isDone (toolRet_)) \
561
+ { \
562
+ return asTestResult (toolRet_); \
563
+ } \
564
+ }
565
+
533
566
TestResult runSimpleTest (TestContext* context, TestInput& input)
534
567
{
535
568
// need to execute the stand-alone Slang compiler on the file, and compare its output to what we expect
@@ -547,10 +580,7 @@ TestResult runSimpleTest(TestContext* context, TestInput& input)
547
580
spawner.pushArgument (arg);
548
581
}
549
582
550
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
551
- {
552
- return TestResult::Fail;
553
- }
583
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
554
584
555
585
String actualOutput = getOutput (spawner);
556
586
@@ -621,10 +651,7 @@ TestResult runReflectionTest(TestContext* context, TestInput& input)
621
651
spawner.pushArgument (arg);
622
652
}
623
653
624
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
625
- {
626
- return TestResult::Fail;
627
- }
654
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
628
655
629
656
String actualOutput = getOutput (spawner);
630
657
@@ -772,11 +799,8 @@ TestResult runCrossCompilerTest(TestContext* context, TestInput& input)
772
799
expectedSpawner.pushArgument (arg);
773
800
}
774
801
775
- if (spawnAndWait (context, outputStem, input.spawnType , expectedSpawner) != kOSError_None )
776
- {
777
- return TestResult::Fail;
778
- }
779
-
802
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , expectedSpawner));
803
+
780
804
String expectedOutput = getOutput (expectedSpawner);
781
805
String expectedOutputPath = outputStem + " .expected" ;
782
806
try
@@ -788,10 +812,8 @@ TestResult runCrossCompilerTest(TestContext* context, TestInput& input)
788
812
return TestResult::Fail;
789
813
}
790
814
791
- if (spawnAndWait (context, outputStem, input.spawnType , actualSpawner) != kOSError_None )
792
- {
793
- return TestResult::Fail;
794
- }
815
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , actualSpawner));
816
+
795
817
String actualOutput = getOutput (actualSpawner);
796
818
797
819
TestResult result = TestResult::Pass;
@@ -847,10 +869,7 @@ TestResult generateHLSLBaseline(TestContext* context, TestInput& input)
847
869
spawner.pushArgument (" -pass-through" );
848
870
spawner.pushArgument (" fxc" );
849
871
850
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
851
- {
852
- return TestResult::Fail;
853
- }
872
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
854
873
855
874
String expectedOutput = getOutput (spawner);
856
875
String expectedOutputPath = outputStem + " .expected" ;
@@ -895,10 +914,7 @@ TestResult runHLSLComparisonTest(TestContext* context, TestInput& input)
895
914
spawner.pushArgument (" -target" );
896
915
spawner.pushArgument (" dxbc-assembly" );
897
916
898
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
899
- {
900
- return TestResult::Fail;
901
- }
917
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
902
918
903
919
// We ignore output to stdout, and only worry about what the compiler
904
920
// wrote to stderr.
@@ -1004,10 +1020,7 @@ TestResult doGLSLComparisonTestRun(TestContext* context,
1004
1020
spawner.pushArgument (arg);
1005
1021
}
1006
1022
1007
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
1008
- {
1009
- return TestResult::Fail;
1010
- }
1023
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
1011
1024
1012
1025
OSProcessSpawner::ResultCode resultCode = spawner.getResultCode ();
1013
1026
@@ -1043,6 +1056,13 @@ TestResult runGLSLComparisonTest(TestContext* context, TestInput& input)
1043
1056
TestResult hlslResult = doGLSLComparisonTestRun (context, input, " __GLSL__" , " glslang" , " .expected" , &expectedOutput);
1044
1057
TestResult slangResult = doGLSLComparisonTestRun (context, input, " __SLANG__" , nullptr , " .actual" , &actualOutput);
1045
1058
1059
+ // If either is ignored, the whole test is
1060
+ if (hlslResult == TestResult::Ignored ||
1061
+ slangResult == TestResult::Ignored)
1062
+ {
1063
+ return TestResult::Ignored;
1064
+ }
1065
+
1046
1066
Slang::File::WriteAllText (outputStem + " .expected" , expectedOutput);
1047
1067
Slang::File::WriteAllText (outputStem + " .actual" , actualOutput);
1048
1068
@@ -1093,11 +1113,7 @@ TestResult runComputeComparisonImpl(TestContext* context, TestInput& input, cons
1093
1113
// clear the stale actual output file first. This will allow us to detect error if render-test fails and outputs nothing.
1094
1114
File::WriteAllText (actualOutputFile, " " );
1095
1115
1096
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
1097
- {
1098
- printf (" error spawning render-test\n " );
1099
- return TestResult::Fail;
1100
- }
1116
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
1101
1117
1102
1118
auto actualOutput = getOutput (spawner);
1103
1119
auto expectedOutput = getExpectedOutput (outputStem);
@@ -1192,10 +1208,7 @@ TestResult doRenderComparisonTestRun(TestContext* context, TestInput& input, cha
1192
1208
spawner.pushArgument (" -o" );
1193
1209
spawner.pushArgument (outputStem + outputKind + " .png" );
1194
1210
1195
- if (spawnAndWait (context, outputStem, input.spawnType , spawner) != kOSError_None )
1196
- {
1197
- return TestResult::Fail;
1198
- }
1211
+ TEST_RETURN_ON_DONE (spawnAndWait (context, outputStem, input.spawnType , spawner));
1199
1212
1200
1213
OSProcessSpawner::ResultCode resultCode = spawner.getResultCode ();
1201
1214
0 commit comments