Пример #1
0
        public async void CustomEventProducesEventsWithNoKeywords()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "MyEventSource", -1 },
                };

                Action _eventGeneratingAction = () =>
                {
                    for (int i = 0; i < 1000; i++)
                    {
                        MyEventSource.Log.Event1();
                        MyEventSource.Log.Event2("anotherFile");
                        MyEventSource.Log.Event3();
                    }
                };

                var providers = new List <EventPipeProvider>()
                {
                    new EventPipeProvider("MyEventSource", EventLevel.Informational)
                };

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, null);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #2
0
        public static int Main(string[] args)
        {
            // This test validates that the rundown events are present
            // and that providers turned on that generate events are being written to
            // the stream.

            var providers = new List <Provider>()
            {
                new Provider("MyEventSource"),
                new Provider("Microsoft-DotNETCore-SampleProfiler")
            };

            var tests = new int[] { 4, 10 }
            .Select(x => (uint)Math.Pow(2, x))
            .Select(bufferSize => new SessionConfiguration(circularBufferSizeMB: bufferSize, format: EventPipeSerializationFormat.NetTrace, providers: providers))
            .Select <SessionConfiguration, Func <int> >(configuration => () => IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration));

            foreach (var test in tests)
            {
                var ret = test();
                if (ret < 0)
                {
                    return(ret);
                }
            }

            return(100);
        }
Пример #3
0
        public static int Main(string[] args)
        {
            // This tests the resilience of message sending with
            // smaller buffers, specifically 1MB and 4MB

            var providers = new List <Provider>()
            {
                new Provider("MyEventSource")
            };

            var tests = new int[] { 0, 2 }
            .Select(x => (uint)Math.Pow(2, x))
            .Select(bufferSize => new SessionConfiguration(circularBufferSizeMB: bufferSize, format: EventPipeSerializationFormat.NetTrace, providers: providers))
            .Select <SessionConfiguration, Func <int> >(configuration => () => IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration));

            foreach (var test in tests)
            {
                var ret = test();
                if (ret < 0)
                {
                    return(ret);
                }
            }

            return(100);
        }
Пример #4
0
        public static int Main(string[] args)
        {
            // This test validates that the rundown events are present
            // and that providers turned on that generate events are being written to
            // the stream.

            var providers = new List <Provider>()
            {
                new Provider("MyEventSource"),
                new Provider("Microsoft-DotNETCore-SampleProfiler")
            };

            var config = new SessionConfiguration(circularBufferSizeMB: (uint)Math.Pow(2, 10), format: EventPipeSerializationFormat.NetTrace, providers: providers);

            var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, config);

            if (ret < 0)
            {
                return(ret);
            }
            else
            {
                return(100);
            }
        }
Пример #5
0
        public static int Main(string[] args)
        {
            // This test tries to send a big event (>100KB) and checks that the app does not crash
            // See https://github.com/dotnet/runtime/issues/50515 for the regression issue
            var providers = new List <EventPipeProvider>()
            {
                new EventPipeProvider("BigEventSource", EventLevel.Verbose)
            };

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _Verify));
        }
Пример #6
0
        public static int Main(string[] args)
        {
            var providers = new List <EventPipeProvider>()
            {
                new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose),
                //GCKeyword (0x1): 0b1
                new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Informational, 0b1)
            };

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents));
        }
Пример #7
0
        public static int Main(string[] args)
        {
            var providers = new List <EventPipeProvider>()
            {
                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));
        }
Пример #8
0
        public async void GCWaitForPendingFinalizers_ProducesEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntime", -1 },
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 },
                    { "Microsoft-DotNETCore-SampleProfiler", -1 }
                };

                var providers = new List <Provider>()
                {
                    new Provider("Microsoft-DotNETCore-SampleProfiler"),
                    //GCKeyword (0x1): 0b1
                    new Provider("Microsoft-Windows-DotNETRuntime", 0b1, EventLevel.Informational)
                };

                Action _eventGeneratingAction = () =>
                {
                    for (int i = 0; i < 50; i++)
                    {
                        if (i % 10 == 0)
                        {
                            Logger.logger.Log($"Called GC.Collect() {i} times...");
                        }
                        TestClass testClass = new TestClass();
                        testClass           = null;
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                    }
                };

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int GCFinalizersEndEvents     = 0;
                    source.Clr.GCFinalizersStop  += (eventData) => GCFinalizersEndEvents += 1;
                    int GCFinalizersStartEvents   = 0;
                    source.Clr.GCFinalizersStart += (eventData) => GCFinalizersStartEvents += 1;
                    return(() => {
                        Logger.logger.Log("Event counts validation");
                        Logger.logger.Log("GCFinalizersEndEvents: " + GCFinalizersEndEvents);
                        Logger.logger.Log("GCFinalizersStartEvents: " + GCFinalizersStartEvents);
                        return GCFinalizersEndEvents >= 50 && GCFinalizersStartEvents >= 50 ? 100 : -1;
                    });
                };

                var config = new SessionConfiguration(circularBufferSizeMB: (uint)Math.Pow(2, 10), format: EventPipeSerializationFormat.NetTrace, providers: providers);

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, config, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #9
0
        public static int Main(string[] args)
        {
            // This test validates that if an EventSource generates an error
            // during construction it gets emitted over EventPipe

            List <EventPipeProvider> providers = new List <EventPipeProvider>
            {
                new EventPipeProvider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (long)ClrTraceEventParser.Keywords.GCHeapSnapshot)
            };

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesRundownContainMethodEvents));
        }
Пример #10
0
        public static int Main(string[] args)
        {
            // This test validates that if an EventSource generates an error
            // during construction it gets emitted over EventPipe

            var providers = new List <EventPipeProvider>
            {
                new EventPipeProvider("IllegalTypesEventSource", EventLevel.Verbose)
            };

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesRundownContainMethodEvents));
        }
Пример #11
0
        public static int Main(string[] args)
        {
            var providers = new List <Provider>()
            {
                new Provider("Microsoft-DotNETCore-SampleProfiler"),
                new Provider("Microsoft-Windows-DotNETRuntime", 0b1000_0000_0000_0000, EventLevel.Warning)
            };

            var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration));
        }
Пример #12
0
        public async void Contention_ProducesEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 }
                };

                var providers = new List <Provider>()
                {
                    //ContentionKeyword (0x4000): 0b100_0000_0000_0000
                    new Provider("Microsoft-Windows-DotNETRuntime", 0b100_0000_0000_0000, EventLevel.Informational)
                };

                Action _eventGeneratingAction = () =>
                {
                    for (int i = 0; i < 50; i++)
                    {
                        if (i % 10 == 0)
                        {
                            Logger.logger.Log($"Thread lock occured {i} times...");
                        }
                        var myobject   = new TestClass();
                        Thread thread1 = new Thread(new ThreadStart(() => myobject.DoSomething(myobject)));
                        Thread thread2 = new Thread(new ThreadStart(() => myobject.DoSomething(myobject)));
                        thread1.Start();
                        thread2.Start();
                        thread1.Join();
                        thread2.Join();
                    }
                };

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int ContentionStartEvents   = 0;
                    source.Clr.ContentionStart += (eventData) => ContentionStartEvents += 1;
                    int ContentionStopEvents    = 0;
                    source.Clr.ContentionStop  += (eventData) => ContentionStopEvents += 1;
                    return(() => {
                        Logger.logger.Log("Event counts validation");
                        Logger.logger.Log("ContentionStartEvents: " + ContentionStartEvents);
                        Logger.logger.Log("ContentionStopEvents: " + ContentionStopEvents);
                        return ContentionStartEvents > 0 && ContentionStopEvents > 0 ? 100 : -1;
                    });
                };
                var config = new SessionConfiguration(circularBufferSizeMB: (uint)Math.Pow(2, 10), format: EventPipeSerializationFormat.NetTrace, providers: providers);

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, config, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #13
0
        public static int Main(string[] args)
        {
            // This test tries to send a big event (>100KB) and checks that the app does not crash
            // See https://github.com/dotnet/runtime/issues/50515 for the regression issue
            var providers = new List <Provider>()
            {
                new Provider("BigEventSource")
            };

            var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _Verify));
        }
Пример #14
0
        public static int Main(string[] args)
        {
            // This test validates that the rundown events are present
            // and that the rundown contains the necessary events to get
            // symbols in a nettrace file.

            var providers = new List <EventPipeProvider>()
            {
                new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose)
            };

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesRundownContainMethodEvents));
        }
Пример #15
0
        public static int Main(string[] args)
        {
            // This test validates that if an EventSource generates an error
            // during construction it gets emitted over EventPipe

            List <Provider> providers = new List <Provider>
            {
                new Provider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (ulong)ClrTraceEventParser.Keywords.GCHeapSnapshot)
            };

            var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _DoesRundownContainMethodEvents));
        }
Пример #16
0
        public static int Main(string[] args)
        {
            Console.WriteLine("EventPipe validation test");
            var providers = new List <Provider>()
            {
                new Provider("Microsoft-DotNETCore-SampleProfiler"),
                new Provider("Microsoft-Windows-DotNETRuntime", 0b1, EventLevel.Informational)
            };

            var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);

            Console.WriteLine("Validation method: RunAndValidateEventCounts");
            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _DoesTraceContainEvents));
        }
Пример #17
0
        public static int Main(string[] args)
        {
            // This test validates that if an EventSource generates an error
            // during construction it gets emitted over EventPipe

            List <Provider> providers = new List <Provider>
            {
                new Provider("IllegalTypesEventSource")
            };

            var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _DoesRundownContainMethodEvents));
        }
Пример #18
0
        public static int Main(string[] args)
        {
            // This test validates that the rundown events are present
            // and that the rundown contains the necessary events to get
            // symbols in a nettrace file.

            var providers = new List <Provider>()
            {
                new Provider("Microsoft-DotNETCore-SampleProfiler")
            };

            var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers);

            return(IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _DoesRundownContainMethodEvents));
        }
Пример #19
0
    public static unsafe int Main()
    {
        var keywords =
            ClrTraceEventParser.Keywords.Jit | ClrTraceEventParser.Keywords.JittedMethodILToNativeMap;

        var dotnetRuntimeProvider = new List <EventPipeProvider>
        {
            new EventPipeProvider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (long)keywords)
        };

        return
            (IpcTraceTest.RunAndValidateEventCounts(
                 new Dictionary <string, ExpectedEventCount>(),
                 JitMethods,
                 dotnetRuntimeProvider,
                 1024,
                 ValidateMappings));
    }
Пример #20
0
    public static unsafe int Main()
    {
        var keywords =
            ClrTraceEventParser.Keywords.Jit | ClrTraceEventParser.Keywords.JittedMethodILToNativeMap;

        var dotnetRuntimeProvider = new List <Provider>
        {
            new Provider("Microsoft-Windows-DotNETRuntime", eventLevel: EventLevel.Verbose, keywords: (ulong)keywords)
        };

        var config = new SessionConfiguration(1024, EventPipeSerializationFormat.NetTrace, dotnetRuntimeProvider);

        return
            (IpcTraceTest.RunAndValidateEventCounts(
                 new Dictionary <string, ExpectedEventCount>(),
                 JitMethods,
                 config,
                 ValidateMappings));
    }
Пример #21
0
        public static int Main(string[] args)
        {
            // This test validates that the rundown events are present
            // and that providers turned on that generate events are being written to
            // the stream.

            var providers = new List <EventPipeProvider>()
            {
                new EventPipeProvider("MyEventSource", EventLevel.Verbose),
                new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Verbose)
            };

            var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024);

            if (ret < 0)
            {
                return(ret);
            }
            else
            {
                return(100);
            }
        }
Пример #22
0
        public static async Task <int> Main(string[] args)
        {
            if (args.Length >= 1)
            {
                Console.Out.WriteLine("Subprocess started!  Waiting for input...");
                var input = Console.In.ReadLine(); // will block until data is sent across stdin
                Console.Out.WriteLine($"Received '{input}'.  Exiting...");
                return(0);
            }

            bool fSuccess = true;

            if (!IpcTraceTest.EnsureCleanEnvironment())
            {
                return(-1);
            }
            IEnumerable <MethodInfo> tests = typeof(ReverseValidation).GetMethods().Where(mi => mi.Name.StartsWith("TEST_"));

            foreach (var test in tests)
            {
                Logger.logger.Log($"::== Running test: {test.Name}");
                bool result = true;
                try
                {
                    result = await(Task <bool>) test.Invoke(null, new object[] {});
                }
                catch (Exception e)
                {
                    result = false;
                    Logger.logger.Log(e.ToString());
                }
                fSuccess &= result;
                Logger.logger.Log($"Test passed: {result}");
                Logger.logger.Log($"");
            }
            return(fSuccess ? 100 : -1);
        }
Пример #23
0
        public static int Main(string[] args)
        {
            // This tests the resilience of message sending with
            // smaller buffers, specifically 1MB and 4MB

            var providers = new List <EventPipeProvider>()
            {
                new EventPipeProvider("MyEventSource", EventLevel.Verbose)
            };

            var buffersizes = new int[] { 0, 2 }
            .Select(x => (int)Math.Pow(2, x));

            foreach (var buffersize in buffersizes)
            {
                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, buffersize);
                if (ret != 100)
                {
                    return(ret);
                }
            }

            return(100);
        }
Пример #24
0
        public async void GCCollect_ProducesVerboseEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntime", -1 },
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 },
                    { "Microsoft-DotNETCore-SampleProfiler", -1 }
                };

                var GCProviders = new List <EventPipeProvider>()
                {
                    new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Informational),
                    //GCKeyword (0x1): 0b1
                    new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Verbose, 0x1)
                };

                Action _eventGeneratingAction = () =>
                {
                    List <string> testList = new List <string>();
                    for (int i = 0; i < 100000000; i++)
                    {
                        string t = "Test string!";
                        testList.Add(t);
                    }
                    GC.Collect();
                };

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int GCCreateSegmentEvents   = 0;
                    int GCFreeSegmentEvents     = 0;
                    source.Clr.GCCreateSegment += (eventData) => GCCreateSegmentEvents += 1;
                    source.Clr.GCFreeSegment   += (eventData) => GCFreeSegmentEvents += 1;

                    int GCAllocationTickEvents   = 0;
                    source.Clr.GCAllocationTick += (eventData) => GCAllocationTickEvents += 1;

                    int GCCreateConcurrentThreadEvents      = 0;
                    int GCTerminateConcurrentThreadEvents   = 0;
                    source.Clr.GCCreateConcurrentThread    += (eventData) => GCCreateConcurrentThreadEvents += 1;
                    source.Clr.GCTerminateConcurrentThread += (eventData) => GCTerminateConcurrentThreadEvents += 1;

                    return(() => {
                        Logger.logger.Log("Event counts validation");

                        Logger.logger.Log("GCCreateSegmentEvents: " + GCCreateSegmentEvents);
                        Logger.logger.Log("GCFreeSegmentEvents: " + GCFreeSegmentEvents);
                        bool GCSegmentResult = GCCreateSegmentEvents > 0 && GCFreeSegmentEvents > 0;
                        Logger.logger.Log("GCSegmentResult: " + GCSegmentResult);

                        Logger.logger.Log("GCAllocationTickEvents: " + GCAllocationTickEvents);
                        bool GCAllocationTickResult = GCAllocationTickEvents > 0;
                        Logger.logger.Log("GCAllocationTickResult: " + GCAllocationTickResult);

                        bool GCCollectResults = GCSegmentResult && GCAllocationTickResult;
                        Logger.logger.Log("GCCollectResults: " + GCCollectResults);

                        return GCCollectResults ? 100 : -1;
                    });
                };

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, GCProviders, 1024, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #25
0
        public async void GCCollect_ProducesEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntime", -1 },
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 },
                    { "Microsoft-DotNETCore-SampleProfiler", -1 }
                };

                var GCProviders = new List <EventPipeProvider>()
                {
                    new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Informational),
                    //GCKeyword (0x1): 0b1
                    new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Verbose, 0x1)
                };

                Action _eventGeneratingAction = () =>
                {
                    for (int i = 0; i < 50; i++)
                    {
                        if (i % 10 == 0)
                        {
                            Logger.logger.Log($"Called GC.Collect() {i} times...");
                        }
                        TestClass testClass = new TestClass();
                        testClass           = null;
                        GC.Collect();
                    }
                };

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int GCStartEvents   = 0;
                    int GCEndEvents     = 0;
                    source.Clr.GCStart += (eventData) => GCStartEvents += 1;
                    source.Clr.GCStop  += (eventData) => GCEndEvents += 1;

                    int GCRestartEEStartEvents   = 0;
                    int GCRestartEEStopEvents    = 0;
                    source.Clr.GCRestartEEStart += (eventData) => GCRestartEEStartEvents += 1;
                    source.Clr.GCRestartEEStop  += (eventData) => GCRestartEEStopEvents += 1;

                    int GCSuspendEEEvents        = 0;
                    int GCSuspendEEEndEvents     = 0;
                    source.Clr.GCSuspendEEStart += (eventData) => GCSuspendEEEvents += 1;
                    source.Clr.GCSuspendEEStop  += (eventData) => GCSuspendEEEndEvents += 1;

                    int GCHeapStatsEvents   = 0;
                    source.Clr.GCHeapStats += (eventData) => GCHeapStatsEvents += 1;

                    return(() => {
                        Logger.logger.Log("Event counts validation");

                        Logger.logger.Log("GCStartEvents: " + GCStartEvents);
                        Logger.logger.Log("GCEndEvents: " + GCEndEvents);
                        bool GCStartStopResult = GCStartEvents >= 50 && GCEndEvents >= 50 && Math.Abs(GCStartEvents - GCEndEvents) <= 2;
                        Logger.logger.Log("GCStartStopResult check: " + GCStartStopResult);

                        Logger.logger.Log("GCRestartEEStartEvents: " + GCRestartEEStartEvents);
                        Logger.logger.Log("GCRestartEEStopEvents: " + GCRestartEEStopEvents);
                        bool GCRestartEEStartStopResult = GCRestartEEStartEvents >= 50 && GCRestartEEStopEvents >= 50;
                        Logger.logger.Log("GCRestartEEStartStopResult check: " + GCRestartEEStartStopResult);

                        Logger.logger.Log("GCSuspendEEEvents: " + GCSuspendEEEvents);
                        Logger.logger.Log("GCSuspendEEEndEvents: " + GCSuspendEEEndEvents);
                        bool GCSuspendEEStartStopResult = GCSuspendEEEvents >= 50 && GCSuspendEEEndEvents >= 50;
                        Logger.logger.Log("GCSuspendEEStartStopResult check: " + GCSuspendEEStartStopResult);

                        Logger.logger.Log("GCHeapStatsEvents: " + GCHeapStatsEvents);
                        bool GCHeapStatsEventsResult = GCHeapStatsEvents >= 50 && GCHeapStatsEvents >= 50;
                        Logger.logger.Log("GCHeapStatsEventsResult check: " + GCHeapStatsEventsResult);

                        return GCStartStopResult && GCRestartEEStartStopResult && GCSuspendEEStartStopResult && GCHeapStatsEventsResult ? 100 : -1;
                    });
                };

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, GCProviders, 1024, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #26
0
        public async void AssemblyLoad_ProducesEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntime", -1 },
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 }
                };

                var providers = new List <Provider>()
                {
                    //LoaderKeyword (0x8): 0b1000
                    new Provider("Microsoft-Windows-DotNETRuntime", 0b1000, EventLevel.Informational)
                };

                string assemblyPath           = null;
                Action _eventGeneratingAction = () =>
                {
                    GetAssemblyPath();
                    try
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            if (i % 10 == 0)
                            {
                                Logger.logger.Log($"Load/Unload Assembly {i} times...");
                            }
                            AssemblyLoad assemblyLoad = new AssemblyLoad();
                            assemblyLoad.LoadFromAssemblyPath(assemblyPath + "\\Microsoft.Diagnostics.Runtime.dll");
                            assemblyLoad.Unload();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.logger.Log(ex.Message + ex.StackTrace);
                    }
                };

                void GetAssemblyPath()
                {
                    assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                }


                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int LoaderAssemblyLoadEvents     = 0;
                    int LoaderAssemblyUnloadEvents   = 0;
                    source.Clr.LoaderAssemblyLoad   += (eventData) => LoaderAssemblyLoadEvents += 1;
                    source.Clr.LoaderAssemblyUnload += (eventData) => LoaderAssemblyUnloadEvents += 1;

                    int LoaderModuleLoadEvents     = 0;
                    int LoaderModuleUnloadEvents   = 0;
                    source.Clr.LoaderModuleLoad   += (eventData) => LoaderModuleLoadEvents += 1;
                    source.Clr.LoaderModuleUnload += (eventData) => LoaderModuleUnloadEvents += 1;

                    return(() => {
                        Logger.logger.Log("Event counts validation");

                        Logger.logger.Log("LoaderAssemblyLoadEvents: " + LoaderAssemblyLoadEvents);
                        Logger.logger.Log("LoaderAssemblyUnloadEvents: " + LoaderAssemblyUnloadEvents);
                        //Unload method just marks as unloadable, not unload immediately, so we check the unload events >=1 to make the tests stable
                        bool LoaderAssemblyResult = LoaderAssemblyLoadEvents >= 100 && LoaderAssemblyUnloadEvents >= 1;
                        Logger.logger.Log("LoaderAssemblyResult check: " + LoaderAssemblyResult);

                        Logger.logger.Log("LoaderModuleLoadEvents: " + LoaderModuleLoadEvents);
                        Logger.logger.Log("LoaderModuleUnloadEvents: " + LoaderModuleUnloadEvents);
                        //Unload method just marks as unloadable, not unload immediately, so we check the unload events >=1 to make the tests stable
                        bool LoaderModuleResult = LoaderModuleLoadEvents >= 100 && LoaderModuleUnloadEvents >= 1;
                        Logger.logger.Log("LoaderModuleResult check: " + LoaderModuleResult);

                        return LoaderAssemblyResult && LoaderModuleResult ? 100 : -1;
                    });
                };

                var config = new SessionConfiguration(circularBufferSizeMB: (uint)Math.Pow(2, 10), format: EventPipeSerializationFormat.NetTrace, providers: providers);

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, config, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #27
0
        public async void MethodVerbose_ProducesEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    //registering Dynamic_All and Clr event callbacks will override each other, disable the check for the provider and check the events counts in the callback
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 },
                    { "Microsoft-DotNETCore-SampleProfiler", -1 }
                };

                var providers = new List <EventPipeProvider>()
                {
                    new EventPipeProvider("Microsoft-DotNETCore-SampleProfiler", EventLevel.Informational),
                    //MethodVerboseKeyword (0x10): 0b10000
                    new EventPipeProvider("Microsoft-Windows-DotNETRuntime", EventLevel.Verbose, 0b10000)
                };

                Action _eventGeneratingAction = () =>
                {
                    for (int i = 0; i < 100; i++)
                    {
                        if (i % 10 == 0)
                        {
                            Logger.logger.Log($"M_verbose occured {i} times...");
                        }

                        using (M_verbose verbose = new M_verbose())
                        {
                            verbose.IsZero('f');
                            verbose.Dispose();
                        }
                    }
                };

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int MethodLoadVerboseEvents     = 0;
                    int MethodUnloadVerboseEvents   = 0;
                    source.Clr.MethodLoadVerbose   += (eventData) => MethodLoadVerboseEvents += 1;
                    source.Clr.MethodUnloadVerbose += (eventData) => MethodUnloadVerboseEvents += 1;

                    int MethodJittingStartedEvents   = 0;
                    source.Clr.MethodJittingStarted += (eventData) => MethodJittingStartedEvents += 1;

                    return(() => {
                        Logger.logger.Log("Event counts validation");
                        Logger.logger.Log("MethodLoadVerboseEvents: " + MethodLoadVerboseEvents);
                        Logger.logger.Log("MethodUnloadVerboseEvents: " + MethodUnloadVerboseEvents);
                        //MethodUnloadVerboseEvents not stable, ignore the verification
                        bool MethodVerboseResult = MethodLoadVerboseEvents >= 1 && MethodUnloadVerboseEvents >= 0;
                        Logger.logger.Log("MethodVerboseResult check: " + MethodVerboseResult);

                        Logger.logger.Log("MethodJittingStartedEvents: " + MethodJittingStartedEvents);
                        bool MethodJittingStartedResult = MethodJittingStartedEvents >= 1;
                        Logger.logger.Log("MethodJittingStartedResult check: " + MethodJittingStartedResult);
                        return MethodVerboseResult && MethodJittingStartedResult ? 100 : -1;
                    });
                };

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, providers, 1024, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #28
0
        public async void GCCollect_ProducesVerboseEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntime", -1 },
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 },
                    { "Microsoft-DotNETCore-SampleProfiler", -1 }
                };

                var providers = new List <Provider>()
                {
                    new Provider("Microsoft-DotNETCore-SampleProfiler"),
                    //GCKeyword (0x1): 0b1
                    new Provider("Microsoft-Windows-DotNETRuntime", 0b1, EventLevel.Verbose)
                };

                Action _eventGeneratingAction = () =>
                {
                    List <string> testList = new List <string>();
                    for (int i = 0; i < 100000000; i++)
                    {
                        string t = "Test string!";
                        testList.Add(t);
                    }
                    GC.Collect();
                };

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int GCCreateSegmentEvents   = 0;
                    int GCFreeSegmentEvents     = 0;
                    source.Clr.GCCreateSegment += (eventData) => GCCreateSegmentEvents += 1;
                    source.Clr.GCFreeSegment   += (eventData) => GCFreeSegmentEvents += 1;

                    int GCAllocationTickEvents   = 0;
                    source.Clr.GCAllocationTick += (eventData) => GCAllocationTickEvents += 1;

                    int GCCreateConcurrentThreadEvents      = 0;
                    int GCTerminateConcurrentThreadEvents   = 0;
                    source.Clr.GCCreateConcurrentThread    += (eventData) => GCCreateConcurrentThreadEvents += 1;
                    source.Clr.GCTerminateConcurrentThread += (eventData) => GCTerminateConcurrentThreadEvents += 1;

                    return(() => {
                        Logger.logger.Log("Event counts validation");

                        Logger.logger.Log("GCCreateSegmentEvents: " + GCCreateSegmentEvents);
                        Logger.logger.Log("GCFreeSegmentEvents: " + GCFreeSegmentEvents);
                        bool GCSegmentResult = GCCreateSegmentEvents > 0 && GCFreeSegmentEvents > 0;
                        Logger.logger.Log("GCSegmentResult: " + GCSegmentResult);

                        Logger.logger.Log("GCAllocationTickEvents: " + GCAllocationTickEvents);
                        bool GCAllocationTickResult = GCAllocationTickEvents > 0;
                        Logger.logger.Log("GCAllocationTickResult: " + GCAllocationTickResult);

                        Logger.logger.Log("GCCreateConcurrentThreadEvents: " + GCCreateConcurrentThreadEvents);
                        //GCTerminateConcurrentThreadEvents not stable, ignore the verification
                        Logger.logger.Log("GCTerminateConcurrentThreadEvents: " + GCTerminateConcurrentThreadEvents);
                        bool GCConcurrentResult = GCCreateConcurrentThreadEvents > 0 && GCTerminateConcurrentThreadEvents >= 0;
                        Logger.logger.Log("GCConcurrentResult: " + GCConcurrentResult);

                        bool GCCollectResults = GCSegmentResult && GCAllocationTickResult && GCConcurrentResult;
                        Logger.logger.Log("GCCollectResults: " + GCCollectResults);

                        return GCCollectResults ? 100 : -1;
                    });
                };

                var config = new SessionConfiguration(circularBufferSizeMB: (uint)Math.Pow(2, 10), format: EventPipeSerializationFormat.NetTrace, providers: providers);

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, config, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Пример #29
0
        public async void ThreadPool_ProducesEvents()
        {
            await RemoteTestExecutorHelper.RunTestCaseAsync(() =>
            {
                Dictionary <string, ExpectedEventCount> _expectedEventCounts = new Dictionary <string, ExpectedEventCount>()
                {
                    { "Microsoft-Windows-DotNETRuntime", -1 },
                    { "Microsoft-Windows-DotNETRuntimeRundown", -1 }
                };

                var providers = new List <Provider>()
                {
                    //ThreadingKeyword (0x10000): 0b10000_0000_0000_0000
                    new Provider("Microsoft-Windows-DotNETRuntime", 0b10000_0000_0000_0000, EventLevel.Informational)
                };

                Action _eventGeneratingAction = () =>
                {
                    Task[] taskArray = new Task[1000];
                    for (int i = 0; i < 1000; i++)
                    {
                        if (i % 10 == 0)
                        {
                            Logger.logger.Log($"Create new task {i} times...");
                        }
                        taskArray[i] = Task.Run(() => TestTask());
                    }
                    Task.WaitAll(taskArray);
                };

                void TestTask()
                {
                    Thread.Sleep(100);
                }

                Func <EventPipeEventSource, Func <int> > _DoesTraceContainEvents = (source) =>
                {
                    int ThreadStartEvents = 0;
                    source.Clr.ThreadPoolWorkerThreadStart += (eventData) => ThreadStartEvents += 1;

                    int ThreadPoolWorkerThreadAdjustmentSampleEvents       = 0;
                    int ThreadPoolWorkerThreadAdjustmentAdjustmentEvents   = 0;
                    source.Clr.ThreadPoolWorkerThreadAdjustmentSample     += (eventData) => ThreadPoolWorkerThreadAdjustmentSampleEvents += 1;
                    source.Clr.ThreadPoolWorkerThreadAdjustmentAdjustment += (eventData) => ThreadPoolWorkerThreadAdjustmentAdjustmentEvents += 1;

                    return(() => {
                        Logger.logger.Log("Event counts validation");

                        Logger.logger.Log("ThreadStartEvents: " + ThreadStartEvents);
                        bool ThreadStartStopResult = ThreadStartEvents >= 1;
                        Logger.logger.Log("ThreadStartStopResult check: " + ThreadStartStopResult);

                        Logger.logger.Log("ThreadPoolWorkerThreadAdjustmentSampleEvents: " + ThreadPoolWorkerThreadAdjustmentSampleEvents);
                        Logger.logger.Log("ThreadPoolWorkerThreadAdjustmentAdjustmentEvents: " + ThreadPoolWorkerThreadAdjustmentAdjustmentEvents);
                        bool ThreadAdjustmentResult = ThreadPoolWorkerThreadAdjustmentSampleEvents >= 1 && ThreadPoolWorkerThreadAdjustmentAdjustmentEvents >= 1;
                        Logger.logger.Log("ThreadAdjustmentResult check: " + ThreadAdjustmentResult);

                        return ThreadStartStopResult && ThreadAdjustmentResult ? 100 : -1;
                    });
                };

                var config = new SessionConfiguration(circularBufferSizeMB: (uint)Math.Pow(2, 10), format: EventPipeSerializationFormat.NetTrace, providers: providers);

                var ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, config, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }