From e77435ba6c0de2a6131e339299ac699c6d2ea4ef Mon Sep 17 00:00:00 2001 From: "ws77.cho" Date: Fri, 16 Apr 2021 01:51:30 +0900 Subject: [PATCH] Modify test OOMException01 and enable test OOMException01 (#51280) * Modify TC to compare strings before ':' In order to avoid failure due to modification of #44013, the TC has been modified so that the content after':' is not compared. * Enable OOMException01 Failed TC is fixed at #51280 --- .../emptystacktrace/oomexception01.cs | 49 ++++++++++++------- src/tests/issues.targets | 3 -- 2 files changed, 30 insertions(+), 22 deletions(-) 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