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

Run trimming tests as AOT tests #101229

Merged
merged 6 commits into from
Apr 22, 2024
Merged

Conversation

MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Apr 18, 2024

Not everything is passing, so I baselined this. Some we'll probably exclude permanently, others are more concerning and we need to determine if it's test issues or product issues.

Cc @dotnet/ilc-contrib

Not everything is passing, so I baselined this. Some we'll probably exclude permanently, others are more concerning and we need to determine if it's test issues or product issues.
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

<DisabledNativeAotTestAppProjects Include="$(MSBuildThisFileDirectory)\System.Runtime\tests\System.Runtime.Tests\TrimmingTests\System.Runtime.TrimmingTests.proj" />
<DisabledNativeAotTestAppProjects Include="$(MSBuildThisFileDirectory)\System.Text.Json\tests\System.Text.Json.Tests\TrimmingTests\System.Text.Json.TrimmingTests.proj" />

<NativeAotTestAppProjects Include="$(MSBuildThisFileDirectory)*\tests\**\*.NativeAotTests.proj;$(MSBuildThisFileDirectory)*\tests\**\*.TrimmingTests.proj"
Copy link
Member

Choose a reason for hiding this comment

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

Should we just get rid of the NativeAotTests.proj extension (there is only 1 currently in the repo) and instead just have TrimmingTests.proj, which are run as both PublishTrimmed and PublishAot?

Copy link
Member Author

@MichalStrehovsky MichalStrehovsky Apr 18, 2024

Choose a reason for hiding this comment

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

If you don't have concerns about running the NativeAotTests with trimming as well, that sounds good to me too.

Trimming is generally a subset of AOT.

Copy link
Member

Choose a reason for hiding this comment

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

This is the only NativeAotTests today:

public static int Main()
{
DiagnosticSource diagnosticSource = new DiagnosticListener("TestDiagnosticListener");
using (var listener = new TestEventListener())
{
var data = new EventData()
{
Id = Guid.NewGuid(),
};
Write(diagnosticSource, "Test.Start", data);
if (!(listener.LogDataPayload?.Count == 3 &&
(string)listener.LogDataPayload[0] == "TestDiagnosticListener" &&
(string)listener.LogDataPayload[1] == "Test.Start"))
{
return -1;
}
object[] args = (object[])listener.LogDataPayload[2];
if (args.Length != 2)
{
return -2;
}
IDictionary<string, object> arg = (IDictionary<string, object>)args[0];
if (!((string)arg["Key"] == "Id" && (string)arg["Value"] == data.Id.ToString()))
{
return -3;
}
arg = (IDictionary<string, object>)args[1];
if (!((string)arg["Key"] == "*Enumerate" && (string)arg["Value"] == "1,2,3"))
{
return -4;
}
return 100;
}
}

It should work just fine with PublishTrimmed. It was written to test the MakeGenericType deep inside of DiagnosticSourceEventSource works with NativeAOT.

I think it would be best to just have 1 "kind of test" and it runs for both PublishTrimmed and PublishAot. It will make it easier to write these, and it will add a bit of coverage to both scenarios.

@@ -142,7 +142,7 @@

<MSBuild Projects="@(TestConsoleApps)"
Targets="Publish"
Properties="Configuration=$(Configuration);BuildProjectReferences=false;TargetOS=$(TargetOS);TargetArchitecture=$(TargetArchitecture)" />
Properties="Configuration=$(Configuration);BuildProjectReferences=false;TargetOS=$(TargetOS);TargetArchitecture=$(TargetArchitecture);_IsPublishing=true" />
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests weren't building because they couldn't find AppHost. This is running the Publish target directly, which is very problematic because it bypasses logic in the SDK. We have been having a conversation with the SDK team for months. The fix is to do what real publish does and that's setting _IsPublishing. We do that in multiple places in this repo even though it's used/defined by the SDK.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for making this happen.

@@ -81,14 +81,17 @@
<_additionalPropertiesString>@(_propertiesAsItems->'&lt;%(Identity)&gt;%(Value)&lt;/%(Identity)&gt;', '%0a ')</_additionalPropertiesString>
</PropertyGroup>

<!-- RunNativeAotTestApps trumps TestTrimming, same as PublishAot trumps PublishTrimmed -->
Copy link
Member

Choose a reason for hiding this comment

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

(nit) this comment doesn't align with the code. The comment says one trumps the other. The code says if they are both true it is an error.

@MichalStrehovsky
Copy link
Member Author

/ba-g slow mac

@MichalStrehovsky MichalStrehovsky merged commit d8eecb7 into dotnet:main Apr 22, 2024
147 of 152 checks passed
@MichalStrehovsky MichalStrehovsky deleted the aottests branch April 22, 2024 09:44
matouskozak pushed a commit to matouskozak/runtime that referenced this pull request Apr 30, 2024
Not everything is passing, so I baselined this. Some we'll probably exclude permanently, others are more concerning and we need to determine if it's test issues or product issues.
@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants