Skip to content

Commit

Permalink
Modify test OOMException01 and enable test OOMException01 (#51280)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wscho77 committed Apr 15, 2021
1 parent 243fd16 commit e77435b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

}

}

3 changes: 0 additions & 3 deletions src/tests/issues.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<Project DefaultTargets = "GetListOfTestCmds" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- All OS/Arch/Runtime excludes -->
<ItemGroup Condition="'$(XunitTestBinBase)' != ''">
<ExcludeList Include="$(XunitTestBinBase)/baseservices/exceptions/sharedexceptions/emptystacktrace/OOMException01/*">
<Issue>https://github.com/dotnet/runtime/issues/51209</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)/readytorun/DynamicMethodGCStress/DynamicMethodGCStress/*">
<Issue>timeout</Issue>
</ExcludeList>
Expand Down

0 comments on commit e77435b

Please sign in to comment.