From a1a9515580af95e3f50cee91340d9bbd63b4c9ba Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Tue, 18 Oct 2022 12:56:19 -0400 Subject: [PATCH 1/8] EventListener: Add test for logging a null string --- .../BasicEventSourceTest/TestsWriteEventToListener.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs index fd5ff41c332b60..ccec74c456cd71 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs @@ -200,6 +200,15 @@ public unsafe void Test_WriteEvent_ArgsBasicTypes() #endregion + #region Validate "null" arguments + + log.EventS(null); + Assert.Equal(8, LoudListener.t_lastEvent.EventId); + Assert.Equal(1, LoudListener.t_lastEvent.Payload.Count); + Assert.Null((string)LoudListener.t_lastEvent.Payload[0]); + + #endregion + #region Validate DateTime Test_WriteEvent_ArgsBasicTypes_Etw_Validate_DateTime(log); #endregion From 0adbcc6062b3f048ed4b98a1301e23ea762b6b93 Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Fri, 4 Nov 2022 18:26:20 -0400 Subject: [PATCH 2/8] EventSource: Add tests for passing in null args --- .../TestsWriteEventToListener.cs | 65 ++++++++++++++++++- .../CustomEventSources/EventSourceTest.cs | 12 ++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs index ccec74c456cd71..ae33fb1b147c29 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsWriteEventToListener.cs @@ -205,7 +205,70 @@ public unsafe void Test_WriteEvent_ArgsBasicTypes() log.EventS(null); Assert.Equal(8, LoudListener.t_lastEvent.EventId); Assert.Equal(1, LoudListener.t_lastEvent.Payload.Count); - Assert.Null((string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + + log.EventSS(null, null); + Assert.Equal(9, LoudListener.t_lastEvent.EventId); + Assert.Equal(2, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[1]); + + log.EventSSS(null, null, null); + Assert.Equal(10, LoudListener.t_lastEvent.EventId); + Assert.Equal(3, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[1]); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[2]); + + log.EventSI(null, 10); + Assert.Equal(11, LoudListener.t_lastEvent.EventId); + Assert.Equal(2, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + + log.EventSL(null, 10); + Assert.Equal(12, LoudListener.t_lastEvent.EventId); + Assert.Equal(2, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(10, (long)LoudListener.t_lastEvent.Payload[1]); + + log.EventSII(null, 10, 11); + Assert.Equal(13, LoudListener.t_lastEvent.EventId); + Assert.Equal(3, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + Assert.Equal(11, (int)LoudListener.t_lastEvent.Payload[2]); + + log.EventWithLongAndString(10, null); + Assert.Equal(43, LoudListener.t_lastEvent.EventId); + Assert.Equal(2, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal(10, (long)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[1]); + + log.EventWithIntAndString(10, null); + Assert.Equal(42, LoudListener.t_lastEvent.EventId); + Assert.Equal(2, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[1]); + + log.EventWithByteArray(null); + Assert.Equal(52, LoudListener.t_lastEvent.EventId); + Assert.Equal(1, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal(new byte[0], (byte[])LoudListener.t_lastEvent.Payload[0]); + + log.EventWithLongAndByteArray(10, null); + Assert.Equal(55, LoudListener.t_lastEvent.EventId); + Assert.Equal(2, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal(10, (long)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(new byte[0], (byte[])LoudListener.t_lastEvent.Payload[1]); + + log.EventWithFallbackArgs(null, 10, 11, 12); + Assert.Equal(56, LoudListener.t_lastEvent.EventId); + Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); + Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); #endregion diff --git a/src/libraries/System.Diagnostics.Tracing/tests/CustomEventSources/EventSourceTest.cs b/src/libraries/System.Diagnostics.Tracing/tests/CustomEventSources/EventSourceTest.cs index 7a6734e33ca3de..d50df9190a55a7 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/CustomEventSources/EventSourceTest.cs +++ b/src/libraries/System.Diagnostics.Tracing/tests/CustomEventSources/EventSourceTest.cs @@ -367,6 +367,18 @@ public unsafe void EventWithBytePointer(byte* ptr, int length) WriteEventCore(54, 1, &data); } + [Event(55)] + public unsafe void EventWithLongAndByteArray(long l, byte[] arr) + { + this.WriteEvent(55, l, arr); + } + + [Event(56)] + public unsafe void EventWithFallbackArgs(string str, int i, float f, long l) + { + this.WriteEvent(56, str, i, f, l); + } + #region Keywords / Tasks /Opcodes / Channels public class Keywords { From 185c96db1bc1a73e71cd3c97c6aaa9ce067f7549 Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Thu, 10 Nov 2022 21:03:47 -0500 Subject: [PATCH 3/8] Tests: Add files for testing null event (not yet implemented) --- .../BasicEventSourceTest/ETWNullEventTest.cs | 53 +++++++++++++++++++ .../ETWNullEventTest.csproj | 19 +++++++ 2 files changed, 72 insertions(+) create mode 100644 src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.cs create mode 100644 src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.cs new file mode 100644 index 00000000000000..8ee18cc321c971 --- /dev/null +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.cs @@ -0,0 +1,53 @@ +// 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.Diagnostics.Tracing; +using System.Collections.Generic; +using Tracing.Tests.Common; +using Microsoft.Diagnostics.NETCore.Client; + +namespace Tracing.Tests.ETWNullEventTest +{ + public class ProviderValidation + { + public static int Main(string[] args) + { + Console.WriteLine("----------------------------------------------------"); + Console.WriteLine("ETW Null event test!!!!"); + Console.WriteLine("----------------------------------------------------"); + var providers = new List() + { + new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose), + //ExceptionKeyword (0x8000): 0b1000_0000_0000_0000 + new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Warning, 0b1000_0000_0000_0000) + }; + + return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024); + } + + private static Dictionary _expectedEventCounts = new Dictionary() + { + { "Microsoft-Windows-DotNETRuntime", new ExpectedEventCount(1000, 0.2f) }, + { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, + { "Microsoft-DotNETCore-SampleProfiler", -1 } + }; + + private static Action _eventGeneratingAction = () => + { + for (int i = 0; i < 1000; i++) + { + if (i % 100 == 0) + Logger.logger.Log($"Thrown an exception {i} times..."); + try + { + throw new ArgumentNullException("Throw ArgumentNullException"); + } + catch (Exception e) + { + //Do nothing + } + } + }; + } +} diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj new file mode 100644 index 00000000000000..f95d07a19fa25f --- /dev/null +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj @@ -0,0 +1,19 @@ + + + .NETCoreApp + exe + true + 1 + true + true + + true + + + + + + + From f434ff6bd0c6d0cf52b08ba02202038e17505881 Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Fri, 2 Dec 2022 10:31:36 -0500 Subject: [PATCH 4/8] Tests: Attempt to create correct csproj but getting error --- .../ETWNullEventTest.csproj | 19 ------------------- ...gnostics.Tracing.ETWNullEvent.Tests.csproj | 19 +++++++++++++++++++ ...TWNullEventTest.cs => TestETWNullEvent.cs} | 0 3 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj create mode 100644 src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj rename src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/{ETWNullEventTest.cs => TestETWNullEvent.cs} (100%) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj deleted file mode 100644 index f95d07a19fa25f..00000000000000 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - .NETCoreApp - exe - true - 1 - true - true - - true - - - - - - - diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj new file mode 100644 index 00000000000000..c420685c5f9f92 --- /dev/null +++ b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj @@ -0,0 +1,19 @@ + + + true + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent) + true + true + + + diagnostics_tracing;marshal-ilgen + + + + + + + + + + \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.cs b/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestETWNullEvent.cs similarity index 100% rename from src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/ETWNullEventTest.cs rename to src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestETWNullEvent.cs From 6532c491332e4449d001e88a64b657d88c6d4f7e Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Fri, 9 Dec 2022 12:17:11 -0500 Subject: [PATCH 5/8] ETW Null Event Test: Get test file to compile --- .../tracing/eventpipe/nullevent/ETWNullEvent.cs} | 2 +- .../tracing/eventpipe/nullevent/ETWNullEvent.csproj} | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) rename src/{libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestETWNullEvent.cs => tests/tracing/eventpipe/nullevent/ETWNullEvent.cs} (97%) rename src/{libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj => tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj} (66%) diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestETWNullEvent.cs b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs similarity index 97% rename from src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestETWNullEvent.cs rename to src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs index 8ee18cc321c971..b2af28fd97c31b 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestETWNullEvent.cs +++ b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs @@ -7,7 +7,7 @@ using Tracing.Tests.Common; using Microsoft.Diagnostics.NETCore.Client; -namespace Tracing.Tests.ETWNullEventTest +namespace Tracing.Tests.ETWNullEvent { public class ProviderValidation { diff --git a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj similarity index 66% rename from src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj rename to src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj index c420685c5f9f92..1868f6cd9f8cfb 100644 --- a/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/System.Diagnostics.Tracing.ETWNullEvent.Tests.csproj +++ b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj @@ -9,11 +9,9 @@ diagnostics_tracing;marshal-ilgen - - - + - - + + \ No newline at end of file From d8571bd5a03d67d40c75f13fd30458e4f400eb34 Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Fri, 9 Dec 2022 12:57:57 -0500 Subject: [PATCH 6/8] ETW Null Event Test: Add test for expected value from null string and null byte array --- .../eventpipe/nullevent/ETWNullEvent.cs | 88 +++++++++++++------ .../eventpipe/nullevent/ETWNullEvent.csproj | 1 + 2 files changed, 60 insertions(+), 29 deletions(-) diff --git a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs index b2af28fd97c31b..52c1a0c03a2bbf 100644 --- a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs +++ b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs @@ -1,53 +1,83 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using BasicEventSourceTests; +using Microsoft.Diagnostics.NETCore.Client; +using Microsoft.Diagnostics.Tracing; using System; -using System.Diagnostics.Tracing; using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.Tracing; +using System.Linq; +using System.Threading.Tasks; using Tracing.Tests.Common; -using Microsoft.Diagnostics.NETCore.Client; +using Xunit; + +[EventSource(Name = "Test.EventSourceNull")] +class EventSourceNullTest : EventSource +{ + [Event(1)] + public void EventNullString(string str, int i, float f, long l) + { + WriteEvent(1, str, i, f, l); + } + + [Event(2)] + public void EventNullByteArray(byte[] bytes, int i, float f, long l) + { + WriteEvent(2, bytes, i, f, l); + } +} + namespace Tracing.Tests.ETWNullEvent { public class ProviderValidation { - public static int Main(string[] args) + public static void Main(string[] args) { Console.WriteLine("----------------------------------------------------"); Console.WriteLine("ETW Null event test!!!!"); Console.WriteLine("----------------------------------------------------"); - var providers = new List() + + List providers = new List { - new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose), - //ExceptionKeyword (0x8000): 0b1000_0000_0000_0000 - new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Warning, 0b1000_0000_0000_0000) + new EventPipeProvider("Test.EventSourceNull", EventLevel.Verbose) }; - return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024); - } - - private static Dictionary _expectedEventCounts = new Dictionary() - { - { "Microsoft-Windows-DotNETRuntime", new ExpectedEventCount(1000, 0.2f) }, - { "Microsoft-Windows-DotNETRuntimeRundown", -1 }, - { "Microsoft-DotNETCore-SampleProfiler", -1 } - }; - - private static Action _eventGeneratingAction = () => - { - for (int i = 0; i < 1000; i++) + int processId = Process.GetCurrentProcess().Id; + DiagnosticsClient client = new DiagnosticsClient(processId); + using (EventPipeSession session = client.StartEventPipeSession(providers, /* requestRunDown */ false)) { - if (i % 100 == 0) - Logger.logger.Log($"Thrown an exception {i} times..."); - try - { - throw new ArgumentNullException("Throw ArgumentNullException"); - } - catch (Exception e) + using (var log = new EventSourceNullTest()) { - //Do nothing + using (var el = new LoudListener(log)) + { + string s = null; + log.EventNullString(s, 10, 11, 12); + Assert.Equal(1, LoudListener.t_lastEvent.EventId); + Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); + Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); + + byte[] b = null; + byte[] expected = new byte[0]; + log.EventNullByteArray(b, 10, 11, 12); + Assert.Equal(1, LoudListener.t_lastEvent.EventId); + Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); + Assert.Equal(expected, (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); + Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); + + var events = new EventPipeEventSource(session.EventStream); + events.Process(); + } + session.Stop(); } } - }; + } } } diff --git a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj index 1868f6cd9f8cfb..bfb5dda3397c11 100644 --- a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj +++ b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.csproj @@ -10,6 +10,7 @@ + From 324719bc947dd120ccaf62ff60a9c48501eddeda Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Fri, 9 Dec 2022 14:38:37 -0500 Subject: [PATCH 7/8] ETW Null Event Test: Fix some minor errors --- .../tracing/eventpipe/nullevent/ETWNullEvent.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs index 52c1a0c03a2bbf..f4b2af63f6b0d7 100644 --- a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs +++ b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs @@ -36,10 +36,6 @@ public class ProviderValidation { public static void Main(string[] args) { - Console.WriteLine("----------------------------------------------------"); - Console.WriteLine("ETW Null event test!!!!"); - Console.WriteLine("----------------------------------------------------"); - List providers = new List { new EventPipeProvider("Test.EventSourceNull", EventLevel.Verbose) @@ -53,8 +49,7 @@ public static void Main(string[] args) { using (var el = new LoudListener(log)) { - string s = null; - log.EventNullString(s, 10, 11, 12); + log.EventNullString(null, 10, 11, 12); Assert.Equal(1, LoudListener.t_lastEvent.EventId); Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); @@ -62,12 +57,10 @@ public static void Main(string[] args) Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); - byte[] b = null; - byte[] expected = new byte[0]; - log.EventNullByteArray(b, 10, 11, 12); - Assert.Equal(1, LoudListener.t_lastEvent.EventId); + log.EventNullByteArray(null, 10, 11, 12); + Assert.Equal(2, LoudListener.t_lastEvent.EventId); Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); - Assert.Equal(expected, (string)LoudListener.t_lastEvent.Payload[0]); + Assert.Equal(new byte[0], (byte[])LoudListener.t_lastEvent.Payload[0]); Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); From a20873f50c60169dccb3cc37b6b096591d0793fc Mon Sep 17 00:00:00 2001 From: "James S. Wang" Date: Fri, 9 Dec 2022 14:47:11 -0500 Subject: [PATCH 8/8] ETW Null Event Test: Reduce to minimal test case --- .../eventpipe/nullevent/ETWNullEvent.cs | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs index f4b2af63f6b0d7..5808c145225685 100644 --- a/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs +++ b/src/tests/tracing/eventpipe/nullevent/ETWNullEvent.cs @@ -45,29 +45,33 @@ public static void Main(string[] args) DiagnosticsClient client = new DiagnosticsClient(processId); using (EventPipeSession session = client.StartEventPipeSession(providers, /* requestRunDown */ false)) { + using (var log = new EventSourceNullTest()) { - using (var el = new LoudListener(log)) - { - log.EventNullString(null, 10, 11, 12); - Assert.Equal(1, LoudListener.t_lastEvent.EventId); - Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); - Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); - Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); - Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); - Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); + log.EventNullString(null, 10, 11, 12); + var events = new EventPipeEventSource(session.EventStream); + events.Process(); + // using (var el = new LoudListener(log)) + // { + // log.EventNullString(null, 10, 11, 12); + // Assert.Equal(1, LoudListener.t_lastEvent.EventId); + // Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); + // Assert.Equal("", (string)LoudListener.t_lastEvent.Payload[0]); + // Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + // Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); + // Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); - log.EventNullByteArray(null, 10, 11, 12); - Assert.Equal(2, LoudListener.t_lastEvent.EventId); - Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); - Assert.Equal(new byte[0], (byte[])LoudListener.t_lastEvent.Payload[0]); - Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); - Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); - Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); + // log.EventNullByteArray(null, 10, 11, 12); + // Assert.Equal(2, LoudListener.t_lastEvent.EventId); + // Assert.Equal(4, LoudListener.t_lastEvent.Payload.Count); + // Assert.Equal(new byte[0], (byte[])LoudListener.t_lastEvent.Payload[0]); + // Assert.Equal(10, (int)LoudListener.t_lastEvent.Payload[1]); + // Assert.Equal(11, (float)LoudListener.t_lastEvent.Payload[2]); + // Assert.Equal(12, (long)LoudListener.t_lastEvent.Payload[3]); - var events = new EventPipeEventSource(session.EventStream); - events.Process(); - } + // var events = new EventPipeEventSource(session.EventStream); + // events.Process(); + // } session.Stop(); } }