Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable dedup optimization in FullAOT mode only #20687

Merged
merged 12 commits into from
Jun 7, 2024
36 changes: 30 additions & 6 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,26 @@ public void RaisesAppDomainUnhandledExceptionEvent (ApplePlatform platform)
}
}

bool FindAssembly(string path, string dllName)
{
try
{
foreach (string file in Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories))
{
if (Path.GetFileName(file).Equals(dllName, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to ignore any exceptions? Wouldn't it be better to just let exceptions flow, which would eventually fail the test? This seems like it could end up hiding problems at some point.

}

return false;
}

[Test]
[TestCase (ApplePlatform.iOS, "ios-arm64;")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")]
Expand All @@ -1936,11 +1956,13 @@ public void PartialAOTExceptCoreLib (ApplePlatform platform, string runtimeIdent

DotNet.AssertBuild (project_path, properties);

var dllPath = Path.Combine (appPath, "aot-instances.dll");
Assert.That (dllPath, Does.Not.Exist, "Dedup optimization shouldn't been enabled for partial AOT compilation");
Assert.True (!FindAssembly (appPath, "aot-instances.dll"), "Dedup optimization shouldn't been enabled for partial AOT compilation");

var appExecutable = GetNativeExecutable (platform, appPath);
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

if (CanExecute (platform, runtimeIdentifiers)) {
var output = ExecuteWithMagicWordAndAssert (appExecutable);
}
}

[Test]
Expand All @@ -1961,11 +1983,13 @@ public void PartialAOTOnlyCoreLib (ApplePlatform platform, string runtimeIdentif

DotNet.AssertBuild (project_path, properties);

var dllPath = Path.Combine (appPath, "aot-instances.dll");
Assert.That (dllPath, Does.Not.Exist, "Dedup optimization shouldn't been enabled for partial AOT compilation");
Assert.True (!FindAssembly (appPath, "aot-instances.dll"), "Dedup optimization shouldn't been enabled for partial AOT compilation");

var appExecutable = GetNativeExecutable (platform, appPath);
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

if (CanExecute (platform, runtimeIdentifiers)) {
var output = ExecuteWithMagicWordAndAssert (appExecutable);
}
}
}
}
Loading