예제 #1
0
        public void LTTng_KernelEvents()
        {
            var assertValues = new Dictionary <string, List <int> >
            {
                // key: trace file name, value: {expected number of ProcessStart events, expected number of GCStart events}
                { "kernel-only.trace.zip", new List <int> {
                      20, 0
                  } },
                { "clr-only.trace.zip", new List <int> {
                      0, 11
                  } },
                { "kernel-clr.trace.zip", new List <int> {
                      19, 12
                  } }
            };

            foreach (string file in assertValues.Keys)
            {
                string path = Path.Combine(TestDataDirectory, file);
                using (CtfTraceEventSource ctfSource = new CtfTraceEventSource(path))
                {
                    var kernelParser = new LinuxKernelEventParser(ctfSource);

                    int processStartCount = 0;
                    int gcStartCount      = 0;
                    kernelParser.ProcessStart += delegate(ProcessStartTraceData data)
                    {
                        processStartCount++;
                        // Check payload fields
                        Assert.True(!string.IsNullOrEmpty(data.FileName));
                        Assert.True(data.PayloadThreadID != 0);
                        Assert.True(data.OldThreadID != 0);
                    };

                    kernelParser.ProcessStop += delegate(ProcessStopTraceData data)
                    {
                        // Check payload fields
                        Assert.True(!string.IsNullOrEmpty(data.Command));
                        Assert.True(data.PayloadThreadID != 0);
                        Assert.True(data.ThreadPriority != 0); // There's no event with priority 0 in this source
                    };

                    ctfSource.Clr.GCStart += delegate(GCStartTraceData data)
                    {
                        gcStartCount++;
                    };

                    ctfSource.Process();

                    Assert.Equal(assertValues[file][0], processStartCount);
                    Assert.Equal(assertValues[file][1], gcStartCount);
                }
            }
        }
 }                                                                    // not implemented
 public LinuxKernelParser(CtfTraceEventSource source)
 {
     parser = new LinuxKernelEventParser(source);
 }