os.tests: Move aspects to the kernel trace stub
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 1 Mar 2016 19:47:45 +0000 (14:47 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 3 Mar 2016 03:46:25 +0000 (22:46 -0500)
Change-Id: If23a66bb009b6d556c7db7eaa80412a9a5c577f1
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/67626
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Hudson CI
analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/src/org/eclipse/tracecompass/analysis/os/linux/core/tests/kernelanalysis/KernelTidAspectTest.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/stubs/org/eclipse/tracecompass/analysis/os/linux/core/tests/stubs/trace/TmfXmlKernelTraceStub.java

index 250df60d35864807e0c9b56876b517079723283f..a327617a1080e1a090c599590507bc3987e49444 100644 (file)
@@ -5,9 +5,6 @@
  * 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
- *
- * Contributors:
- *   Geneviève Bastien - Initial API and implementation
  *******************************************************************************/
 
 package org.eclipse.tracecompass.analysis.os.linux.core.tests.kernelanalysis;
@@ -24,14 +21,11 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelTidAspect;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.ThreadPriorityAspect;
 import org.eclipse.tracecompass.analysis.os.linux.core.tests.Activator;
 import org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
@@ -43,8 +37,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.ImmutableSet;
-
 /**
  * Test the {@link KernelTidAspect} class
  *
@@ -58,23 +50,6 @@ public class KernelTidAspectTest {
     // Test trace class definition
     // ------------------------------------------------------------------------
 
-    private static class TmfXmlTraceStubWithTidAspects extends TmfXmlKernelTraceStub {
-
-        public TmfXmlTraceStubWithTidAspects() {
-            super();
-        }
-
-        @Override
-        public Iterable<ITmfEventAspect> getEventAspects() {
-            ImmutableSet.Builder<ITmfEventAspect> builder = ImmutableSet.builder();
-            builder.addAll(super.getEventAspects());
-            builder.add(KernelTidAspect.INSTANCE);
-            builder.add(ThreadPriorityAspect.INSTANCE);
-            return NonNullUtils.checkNotNull(builder.build());
-        }
-
-    }
-
     private ITmfTrace fTrace;
 
     private static void deleteSuppFiles(ITmfTrace trace) {
@@ -90,7 +65,7 @@ public class KernelTidAspectTest {
      */
     @Before
     public void setUp() {
-        ITmfTrace trace = new TmfXmlTraceStubWithTidAspects();
+        ITmfTrace trace = new TmfXmlKernelTraceStub();
         IPath filePath = Activator.getAbsoluteFilePath(LTTNG_KERNEL_FILE);
         IStatus status = trace.validate(null, filePath.toOSString());
         if (!status.isOK()) {
index f8f2fa85fb90c93aa59cdec2ca74594df793f7f9..cc43ccfe620acdd29983e24966dffbdb94ab0ff5 100644 (file)
 package org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace;
 
 import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelTidAspect;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.ThreadPriorityAspect;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
 import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
 
+import com.google.common.collect.ImmutableSet;
+
 /**
  * A trace stub that implements a kernel trace. It can add an event layout to
  * the trace.
@@ -43,4 +48,17 @@ public class TmfXmlKernelTraceStub extends TmfXmlTraceStub implements IKernelTra
         fLayout = layout;
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        /*
+         * This method needs to fill the aspects dynamically because aspects in
+         * the parent class are not all present at the beginning of the trace
+         */
+        ImmutableSet.Builder<ITmfEventAspect> builder = ImmutableSet.builder();
+        builder.addAll(super.getEventAspects());
+        builder.add(KernelTidAspect.INSTANCE);
+        builder.add(ThreadPriorityAspect.INSTANCE);
+        return builder.build();
+    }
+
 }
This page took 0.028583 seconds and 5 git commands to generate.