Add debug output to BasicEventSourceTests.TestsManifestGeneration.Test_EventSource_Et...
authorDavid Mason <davmason@microsoft.com>
Wed, 9 Aug 2023 22:31:53 +0000 (15:31 -0700)
committerGitHub <noreply@github.com>
Wed, 9 Aug 2023 22:31:53 +0000 (15:31 -0700)
src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsManifestGeneration.Etw.cs

index 7c2f5d3..2824569 100644 (file)
@@ -143,9 +143,18 @@ namespace BasicEventSourceTests
 
             ETWTraceEventSource source = new ETWTraceEventSource(fileName);
 
+            Dictionary<string, int> providers = new Dictionary<string, int>();
+            int eventCount = 0;
             var sawManifestData = false;
             source.Dynamic.All += (eventData) =>
             {
+                eventCount++;
+                if (!providers.ContainsKey(eventData.ProviderName))
+                {
+                    providers[eventData.ProviderName] = 0;
+                }
+                providers[eventData.ProviderName]++;
+
                 if (eventData.ProviderName.Equals("SimpleEventSource") && eventData.EventName.Equals("ManifestData"))
                 {
                     sawManifestData = true;
@@ -153,6 +162,18 @@ namespace BasicEventSourceTests
             };
             source.Process();
             //File.Delete(fileName);
+
+            if (!sawManifestData)
+            {
+                Console.WriteLine("Did not see ManifestData event from SimpleEventSource, test will fail. Additional info:");
+                Console.WriteLine($"    file name {fileName}");
+                Console.WriteLine($"    total event count {eventCount}");
+                Console.WriteLine($"    total providers {providers.Count}");
+                foreach (var provider in providers.Keys)
+                {
+                    Console.WriteLine($"        Provider name {provider} event count {providers[provider]}");
+                }
+            }
             return sawManifestData;
         }
     }