Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/tests/CommonTestRunner/Debuggees/EventPipeTracee/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public static async Task<int> Main(string[] args)
Console.WriteLine($"{pid} EventPipeTracee: start process");
Console.Out.Flush();

// Workaround for https://github.com/dotnet/runtime/issues/127681
// LoggingEventSource has a static initialization order bug fields are declared after the singleton instance.
// Workaround for https://github.com/dotnet/runtime/issues/127681.
// LoggingEventSource has a static initialization order bug: fields are declared after the singleton instance.
// If EventPipe enables the source during or before the LoggingEventSource.Instance constructor, ParseFilterSpec
// produces wrong rules. Force the type initializer to complete before connecting to the pipe (which signals
// the test harness that EventPipe can be enabled).
// produces wrong rules. The pipe connection signals that the test harness can enable EventPipe, so fully
// construct the logger factory and loggers first. This also ensures its filter options monitor is subscribed
// before EventPipe updates the filter specification; otherwise that update can be missed and the application
// filters remain active, dropping the LoggerRemoteTest records.
ServiceCollection serviceCollection = new();
serviceCollection.AddLogging(builder => {
builder.AddEventSourceLogger();
Expand All @@ -55,18 +57,17 @@ public static async Task<int> Main(string[] args)
builder.AddFilter(AppLoggerCategoryName, LogLevel.Warning);
});

using ILoggerFactory loggerFactory = serviceCollection.BuildServiceProvider().GetService<ILoggerFactory>();
ILogger customCategoryLogger = loggerFactory.CreateLogger(loggerCategory);
ILogger appCategoryLogger = loggerFactory.CreateLogger(AppLoggerCategoryName);

// Signal that the tracee has started
Console.WriteLine($"{pid} EventPipeTracee: connecting to pipe");
Console.Out.Flush();
pipeStream.Connect(5 * 60 * 1000);
Console.WriteLine($"{pid} EventPipeTracee: connected to pipe");
Console.Out.Flush();


using ILoggerFactory loggerFactory = serviceCollection.BuildServiceProvider().GetService<ILoggerFactory>();
ILogger customCategoryLogger = loggerFactory.CreateLogger(loggerCategory);
ILogger appCategoryLogger = loggerFactory.CreateLogger(AppLoggerCategoryName);

using ActivitySource activitySource = useActivitySource
? new ActivitySource("EventPipeTracee.ActivitySource", version: "1.0.0")
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -43,11 +42,6 @@ public EventLogsPipelineUnitTests(ITestOutputHelper output)
[SkippableTheory, MemberData(nameof(Configurations))]
public async Task TestLogsAllCategoriesAllLevels(TestConfiguration config)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541");
}

using Stream outputStream = await GetLogsAsync(config, settings => {
settings.UseAppFilters = false;
});
Expand All @@ -68,7 +62,7 @@ public async Task TestLogsAllCategoriesAllLevels(TestConfiguration config)
/// <summary>
/// Test that log events at or above the default level are collected.
/// </summary>
[SkippableTheory(Skip = "https://github.com/dotnet/diagnostics/issues/2541"), MemberData(nameof(Configurations))]
[SkippableTheory, MemberData(nameof(Configurations))]
public async Task TestLogsAllCategoriesDefaultLevel(TestConfiguration config)
{
using Stream outputStream = await GetLogsAsync(config, settings => {
Expand All @@ -90,14 +84,9 @@ public async Task TestLogsAllCategoriesDefaultLevel(TestConfiguration config)
/// <summary>
/// Test that log events at the default level are collected for categories without a specified level.
/// </summary>
[SkippableTheory(Skip = "Unreliable test https://github.com/dotnet/diagnostics/issues/3143"), MemberData(nameof(Configurations))]
[SkippableTheory, MemberData(nameof(Configurations))]
public async Task TestLogsAllCategoriesDefaultLevelFallback(TestConfiguration config)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541");
}

using Stream outputStream = await GetLogsAsync(config, settings => {
settings.UseAppFilters = false;
settings.LogLevel = LogLevel.Error;
Expand Down Expand Up @@ -143,11 +132,6 @@ public async Task TestLogsAllCategoriesDefaultLevelNoneNotSupported(TestConfigur
[SkippableTheory, MemberData(nameof(Configurations))]
public async Task TestLogsUseAppFilters(TestConfiguration config)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541");
}

using Stream outputStream = await GetLogsAsync(config);

Assert.True(outputStream.Length > 0, "No data written by logging process.");
Expand All @@ -164,7 +148,7 @@ public async Task TestLogsUseAppFilters(TestConfiguration config)
/// Test that log events are collected for the categories and levels specified by the application
/// and for the categories and levels specified in the filter specs.
/// </summary>
[SkippableTheory(Skip = "https://github.com/dotnet/diagnostics/issues/2541"), MemberData(nameof(Configurations))]
[SkippableTheory, MemberData(nameof(Configurations))]
public async Task TestLogsUseAppFiltersAndFilterSpecs(TestConfiguration config)
{
using Stream outputStream = await GetLogsAsync(config, settings => {
Expand All @@ -191,11 +175,6 @@ public async Task TestLogsUseAppFiltersAndFilterSpecs(TestConfiguration config)
[SkippableTheory, MemberData(nameof(Configurations))]
public async Task TestLogsWildcardCategory(TestConfiguration config)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541");
}

using Stream outputStream = await GetLogsAsync(config, settings => {
settings.UseAppFilters = false;
settings.LogLevel = LogLevel.Critical;
Expand Down
Loading