Skip to content

Mark SampleProfilerSampleType.TestEntryPoint with [ActiveIssue] for Native AOT#125218

Merged
MichalStrehovsky merged 2 commits intomainfrom
copilot/mark-test-entrypoint-active-issue
Mar 5, 2026
Merged

Mark SampleProfilerSampleType.TestEntryPoint with [ActiveIssue] for Native AOT#125218
MichalStrehovsky merged 2 commits intomainfrom
copilot/mark-test-entrypoint-active-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 5, 2026

SampleProfilerSampleType.TestEntryPoint (added in #124410) fails on Native AOT. Skipping it there until #125217 is resolved.

Description

  • Added [ActiveIssue("https://github.com/dotnet/runtime/issues/125217", typeof(Utilities), nameof(Utilities.IsNativeAot))] above [Fact] on TestEntryPoint
  • Added using TestLibrary; (needed for Utilities.IsNativeAot)
[ActiveIssue("https://github.com/dotnet/runtime/issues/125217", typeof(Utilities), nameof(Utilities.IsNativeAot))]
[Fact]
public static int TestEntryPoint()

Pattern matches existing usage in rundownvalidation.cs.

Original prompt

Problem

The test SampleProfilerSampleType.TestEntryPoint added in PR #124410 (src/tests/tracing/eventpipe/eventsvalidation/SampleProfilerSampleType.cs) is failing in Native AOT runs. It needs to be marked with an [ActiveIssue] attribute scoped to Native AOT until the issue is resolved.

Tracking issue: #125217

Required Change

In src/tests/tracing/eventpipe/eventsvalidation/SampleProfilerSampleType.cs, add the following [ActiveIssue] attribute to the TestEntryPoint method, directly above the existing [Fact] attribute:

[ActiveIssue("https://github.com/dotnet/runtime/issues/125217", typeof(Utilities), nameof(Utilities.IsNativeAot))]

The result should look like:

[ActiveIssue("https://github.com/dotnet/runtime/issues/125217", typeof(Utilities), nameof(Utilities.IsNativeAot))]
[Fact]
public static int TestEntryPoint()

Additionally, add a using TestLibrary; directive to the using statements at the top of the file (needed for Utilities.IsNativeAot), since Utilities comes from TestLibrary. Look at nearby tests like src/tests/tracing/eventpipe/rundownvalidation/rundownvalidation.cs to confirm the pattern — it already has using TestLibrary; and uses [ActiveIssue("...", typeof(Utilities), nameof(Utilities.IsNativeAot))].

The current file is at: src/tests/tracing/eventpipe/eventsvalidation/SampleProfilerSampleType.cs

  • BlobSha: cf47e8c1c9fc80228157af41d54184e99fc010af

Current file content for reference

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tracing;
using Tracing.Tests.Common;
using Xunit;

namespace Tracing.Tests.SampleProfilerSampleType
{
    // Validates that ThreadSample events from the SampleProfiler report
    // SampleType == Managed (2) when threads are executing managed code.
    // Regression test for https://github.com/dotnet/runtime/issues/123996
    public class SampleProfilerSampleType
    {
        private const uint SampleTypeExternal = 1;
        private const uint SampleTypeManaged = 2;

        [Fact]
        public static int TestEntryPoint()
        {
            var providers = new List<EventPipeProvider>()
            {
                new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose)
            };

            return IpcTraceTest.RunAndValidateEventCounts(
                _expectedEventCounts,
                _eventGeneratingAction,
                providers,
                1024,
                _DoesTraceContainEvents);
        }

        private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>()
        {
            { "Microsoft-Windows-DotNETRuntimeRundown", -1 },
            { "Microsoft-DotNETCore-SampleProfiler", -1 }
        };

        private static Action _eventGeneratingAction = () =>
        {
            // Spin doing managed work so the sample profiler can capture
            // ThreadSample events while we are in cooperative (managed) mode.
            Stopwatch sw = Stopwatch.StartNew();
            while (sw.ElapsedMilliseconds < 3000)
            {
                DoManagedWork();
            }
        };

        [MethodImpl(MethodImplOptions.NoInlining)]
        private static void DoManagedWork()
        {
            long sum = 0;
            for (int i = 0; i < 100_000; i++)
            {
                sum += i;
            }

            GC.KeepAlive(sum);
        }

        private static Func<EventPipeEventSource, Func<int>> _DoesTraceContainEvents = (source) =>
        {
            int managedSamples = 0;
            int externalSamples = 0;
            int totalThreadSamples = 0;

            source.Dynamic.All += (eventData) =>
            {
                if (eventData.ProviderName != "Microsoft-DotNETCore-SampleProfiler")
                    return;

                totalThreadSamples++;
                try
                {
                    // The ThreadSample event payload is a single uint32 representing the sample type.
                    Span<byte> data = eventData.EventData().AsSpan();
                    if (data.Length >= 4)
                    {
                        uint sampleType = BitConverter.ToUInt32(data.Slice(0, 4));
                        if (sampleType == SampleTypeManaged)
                            managedSamples++;
                        else if (sampleType == SampleTypeExternal)
                            externalSamples++;
                    }
                }
                catch (Exception ex)
                {
                    Logger.logger.Log($"Exception reading SampleType payload: ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

…ative AOT (#125217)

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
@MichalStrehovsky MichalStrehovsky marked this pull request as ready for review March 5, 2026 12:38
Copilot AI changed the title [WIP] Mark TestEntryPoint with ActiveIssue attribute for Native AOT Mark SampleProfilerSampleType.TestEntryPoint with [ActiveIssue] for Native AOT Mar 5, 2026
@MichalStrehovsky MichalStrehovsky enabled auto-merge (squash) March 5, 2026 12:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the EventPipe tracing test SampleProfilerSampleType.TestEntryPoint to be skipped on Native AOT runs via an [ActiveIssue] attribute, aligning it with existing dotnet/runtime test patterns while the tracked issue remains unresolved.

Changes:

  • Add using TestLibrary; so the test can reference Utilities.IsNativeAot.
  • Mark TestEntryPoint with [ActiveIssue(..., typeof(Utilities), nameof(Utilities.IsNativeAot))] to skip on Native AOT.

You can also share your feedback on Copilot code review. Take the survey.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky
Copy link
Member

Also cc @dotnet/ilc-contrib. Outerloops are all red again and this is making it hard to spot real issues in the runs.

@MichalStrehovsky MichalStrehovsky merged commit 7023c7c into main Mar 5, 2026
89 of 91 checks passed
@MichalStrehovsky MichalStrehovsky deleted the copilot/mark-test-entrypoint-active-issue branch March 5, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants