Exemplo n.º 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);
        }
Exemplo n.º 2
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 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();
                        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 ret = IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, GCProviders, 1024, _DoesTraceContainEvents);
                Assert.Equal(100, ret);
            }, output);
        }
Exemplo n.º 3
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);
        }