diff --git a/src/tests/baseservices/exceptions/sharedexceptions/emptystacktrace/oomexception01.cs b/src/tests/baseservices/exceptions/sharedexceptions/emptystacktrace/oomexception01.cs index 0ac3e49f5abb6..32942d796bea5 100644 --- a/src/tests/baseservices/exceptions/sharedexceptions/emptystacktrace/oomexception01.cs +++ b/src/tests/baseservices/exceptions/sharedexceptions/emptystacktrace/oomexception01.cs @@ -18,44 +18,55 @@ public static int Main() public void RunTest() { - CreateAndThrow(); + CreateAndThrow(); } public void CreateAndThrow() { - string currStack; - + string currStack; + try { - throw new Exception(); + throw new Exception(); + } + catch(Exception e) + { + currStack = e.StackTrace; } - catch(Exception e) - { - currStack = e.StackTrace; - } - + try - { + { Guid[] g = new Guid[Int32.MaxValue]; } catch(OutOfMemoryException e) { retVal = 100; - - Console.WriteLine("Caught OOM"); - if(e.StackTrace.ToString().Substring(0, e.StackTrace.Length - 8) != currStack.Substring(0, currStack.Length - 8)) - { - Console.WriteLine("Actual Exception Stack Trace:"); + Console.WriteLine("Caught OOM"); + + string oomStack = e.StackTrace; + string expectedStack = currStack; + + if (oomStack.IndexOf(':') != -1) + { + oomStack = oomStack.Substring(0, oomStack.IndexOf(':') - 1); + } + + if (expectedStack.IndexOf(':') != -1) + { + expectedStack = expectedStack.Substring(0, expectedStack.IndexOf(':') - 1); + } + + if (oomStack != expectedStack) + { + Console.WriteLine("Actual Exception Stack Trace:"); Console.WriteLine(e.StackTrace); Console.WriteLine(); - Console.WriteLine("Expected Stack Trace:"); - Console.WriteLine(currStack.ToString()); + Console.WriteLine("Expected Stack Trace:"); + Console.WriteLine(currStack.ToString()); retVal = 50; } } - } - } diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 0fd2318537f78..b575a39cc9cae 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -2,9 +2,6 @@ - - https://github.com/dotnet/runtime/issues/51209 - timeout