Fix stack overflow tests to accept 800703E9 exit code too (#65331)
authorJan Vorlicek <jan.vorlicek@volny.cz>
Tue, 15 Feb 2022 12:15:12 +0000 (13:15 +0100)
committerGitHub <noreply@github.com>
Tue, 15 Feb 2022 12:15:12 +0000 (13:15 +0100)
Sometimes a process failing with stack overflow returns exit code
0x800703e9 (ERROR_STACK_OVERFLOW). This change updates the stack
overflow test to accept that code too.

src/tests/baseservices/exceptions/stackoverflow/stackoverflowtester.cs

index 8f147d2..55e3d02 100644 (file)
@@ -40,19 +40,25 @@ namespace TestStackOverflow
 
             stderrLines = lines;
 
-            int expectedExitCode;
+            int[] expectedExitCodes;
             if ((Environment.OSVersion.Platform == PlatformID.Unix) || (Environment.OSVersion.Platform == PlatformID.MacOSX))
             {
-                expectedExitCode = 128 + 6;
+                expectedExitCodes = new int[] { 128 + 6};
             }
             else
             {
-                expectedExitCode = unchecked((int)0xC00000FD);
+                expectedExitCodes = new int[] { unchecked((int)0xC00000FD), unchecked((int)0x800703E9) };
             }
 
-            if (testProcess.ExitCode != expectedExitCode)
+            if (!Array.Exists(expectedExitCodes, code => testProcess.ExitCode == code))
             {
-                Console.WriteLine($"Exit code: 0x{testProcess.ExitCode:X8}, expected 0x{expectedExitCode:X8}");
+                string separator = string.Empty;
+                StringBuilder expectedListBuilder = new StringBuilder();
+                Array.ForEach(expectedExitCodes, code => {
+                    expectedListBuilder.Append($"{separator}0x{code:X8}");
+                    separator = " or ";
+                });
+                Console.WriteLine($"Exit code: 0x{testProcess.ExitCode:X8}, expected {expectedListBuilder.ToString()}");
                 return false;
             }