analysis: test System call analysis
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 9 Dec 2015 15:54:29 +0000 (10:54 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 19 May 2016 19:31:08 +0000 (15:31 -0400)
This tests the system call latency analysis without the UI.

Change-Id: I15b409a89de59cce4fc03596ab62790387dfea75
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/62323
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/latency/SyscallAnalysisTest.java [new file with mode: 0644]

diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/latency/SyscallAnalysisTest.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/latency/SyscallAnalysisTest.java
new file mode 100644 (file)
index 0000000..c8ad17d
--- /dev/null
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.analysis.os.linux.core.tests.latency;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.analysis.os.linux.core.latency.SystemCallLatencyAnalysis;
+import org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.KernelEventLayoutStub;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests for the system call analysis
+ *
+ * @author Matthew Khouzam
+ */
+public class SyscallAnalysisTest {
+
+    private static class KernelStubTrace extends CtfTmfTrace implements IKernelTrace {
+        public KernelStubTrace() {
+            super();
+        }
+
+        public static synchronized KernelStubTrace getTrace(CtfTestTrace ctfTrace) {
+            String tracePath;
+            try {
+                tracePath = FileLocator.toFileURL(ctfTrace.getTraceURL()).getPath();
+            } catch (IOException e) {
+                throw new IllegalStateException();
+            }
+
+            KernelStubTrace trace = new KernelStubTrace();
+            try {
+                trace.initTrace(null, tracePath, CtfTmfEvent.class);
+            } catch (TmfTraceException e) {
+                /* Should not happen if tracesExist() passed */
+                throw new RuntimeException(e);
+            }
+            return trace;
+        }
+
+        @Override
+        public @NonNull IKernelAnalysisEventLayout getKernelEventLayout() {
+            return KernelEventLayoutStub.getInstance();
+        }
+    }
+
+    private SystemCallLatencyAnalysis fSyscallModule;
+
+    /**
+     * Test setup
+     */
+    @Before
+    public void setUp() {
+        ITmfTrace trace = KernelStubTrace.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
+        /* Make sure the Kernel analysis has run */
+        ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
+        for (IAnalysisModule mod : TmfTraceUtils.getAnalysisModulesOfClass(trace, SystemCallLatencyAnalysis.class)) {
+            fSyscallModule = (SystemCallLatencyAnalysis) mod;
+        }
+        assertNotNull(fSyscallModule);
+        fSyscallModule.schedule();
+        fSyscallModule.waitForCompletion();
+    }
+
+    /**
+     * Dispose everything
+     */
+    @After
+    public void cleanup() {
+        final SystemCallLatencyAnalysis syscallModule = fSyscallModule;
+        if( syscallModule != null) {
+            syscallModule.dispose();
+        }
+    }
+
+    /**
+     * This will load the analysis and test it. as it depends on Kernel, this
+     * test runs the kernel trace first then the analysis
+     */
+    @Test
+    public void testSmallTraceSequential() {
+        final SystemCallLatencyAnalysis syscallModule = fSyscallModule;
+        assertNotNull(syscallModule);
+        ISegmentStore<@NonNull ISegment> segmentStore = syscallModule.getSegmentStore();
+        assertNotNull(segmentStore);
+        assertEquals(1801, segmentStore.size());
+    }
+}
This page took 0.026033 seconds and 5 git commands to generate.