test: Make CtfTmfTrace stubs of the right class
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 2 Dec 2016 22:40:53 +0000 (17:40 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 8 Dec 2016 14:12:49 +0000 (09:12 -0500)
Kernel and UST traces created with CtfTestTraceUtils were not of the
right type, which prevented the corresponding analyses to execute.

Add LttngKernelTestTraceUtils and LttngUstTestTraceUtils which create
similar stubs of the right type (LttngKernelTrace and LttngUstTrace).

Change-Id: I8a873b5ff7c558f68ffbc3141c66b8a35e6053c1
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/86297
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
14 files changed:
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/shared/org/eclipse/tracecompass/tmf/ctf/core/tests/shared/CtfTmfTestTraceUtils.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/stubs/org/eclipse/tracecompass/tmf/ctf/core/tests/stubs/CtfTmfTraceStub.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/stubs/org/eclipse/tracecompass/tmf/ctf/core/tests/stubs/ITmfTraceStub.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/.classpath
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/build.properties
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/LttngKernelTestTraceUtils.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/src/org/eclipse/tracecompass/lttng2/kernel/core/tests/synchronization/UstKernelSyncTest.java
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/stubs/org/eclipse/tracecompass/lttng2/kernel/core/tests/stubs/LttngKernelTraceStub.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/.classpath
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/build.properties
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/shared/org/eclipse/tracecompass/lttng2/ust/core/tests/shared/LttngUstTestTraceUtils.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/stubs/org/eclipse/tracecompass/lttng2/ust/core/tests/stubs/LttngUstTraceStub.java [new file with mode: 0644]

index d627c675f1ce014d782294ad889ca27e3abb5638..a34c80979c5fdfeccf025aca78d59bcdbc37550b 100644 (file)
@@ -29,11 +29,14 @@ import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
  * @author Alexandre Montplaisir
  */
 @NonNullByDefault
-public final class CtfTmfTestTraceUtils {
+public class CtfTmfTestTraceUtils {
 
     private static final Map<CtfTestTrace, CtfTmfTrace> CTF_TMF_TRACES = new HashMap<>();
 
-    private CtfTmfTestTraceUtils() {}
+    /**
+     * Constructor
+     */
+    protected CtfTmfTestTraceUtils() {}
 
     /**
      * Return a CtfTmfTraceStub object of this test trace. It will be already
@@ -47,6 +50,25 @@ public final class CtfTmfTestTraceUtils {
      * @return A CtfTmfTrace reference to this trace
      */
     public static synchronized CtfTmfTrace getTrace(CtfTestTrace ctfTrace) {
+        return new CtfTmfTestTraceUtils().internalGetTrace(ctfTrace, CTF_TMF_TRACES, new CtfTmfTraceStub());
+    }
+
+    /**
+     * Return a CtfTmfTraceStub object of this test trace. It will be already
+     * initTrace()'ed.
+     *
+     * After being used by unit tests, traces should be properly disposed by
+     * calling the {@link #dispose(CtfTestTrace)} method.
+     *
+     * @param ctfTrace
+     *            The test trace to initialize
+     * @param map
+     *            the trace map
+     * @param trace
+     *            the trace stub instance
+     * @return A CtfTmfTrace reference to this trace
+     */
+    protected synchronized CtfTmfTrace internalGetTrace(CtfTestTrace ctfTrace, Map<CtfTestTrace, CtfTmfTrace> map, CtfTmfTrace trace) {
         String tracePath;
         try {
             tracePath = FileLocator.toFileURL(ctfTrace.getTraceURL()).getPath();
@@ -54,15 +76,14 @@ public final class CtfTmfTestTraceUtils {
             throw new IllegalStateException();
         }
 
-        dispose(ctfTrace);
-        CtfTmfTrace trace = new CtfTmfTraceStub();
+        internalDispose(ctfTrace, map);
         try {
             trace.initTrace(null, tracePath, CtfTmfEvent.class);
         } catch (TmfTraceException e) {
             /* Should not happen if tracesExist() passed */
             throw new RuntimeException(e);
         }
-        CTF_TMF_TRACES.put(ctfTrace, trace);
+        map.put(ctfTrace, trace);
         return trace;
     }
 
@@ -73,7 +94,19 @@ public final class CtfTmfTestTraceUtils {
      *            Trace to dispose
      */
     public static synchronized void dispose(CtfTestTrace ctfTrace) {
-        CtfTmfTrace trace = CTF_TMF_TRACES.remove(ctfTrace);
+        new CtfTmfTestTraceUtils().internalDispose(ctfTrace, CTF_TMF_TRACES);
+    }
+
+    /**
+     * Dispose of the trace
+     *
+     * @param ctfTrace
+     *            Trace to dispose
+     * @param map
+     *            the trace map
+     */
+    protected synchronized void internalDispose(CtfTestTrace ctfTrace, Map<CtfTestTrace, CtfTmfTrace> map) {
+        CtfTmfTrace trace = map.remove(ctfTrace);
         if (trace != null) {
             trace.dispose();
         }
index 30f8838700ffdd54ad0ee35d46d9c0fab722d45a..8538e28563db5589acf4b4ac99b2535863194e49 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2014 École Polytechnique de Montréal
+ * Copyright (c) 2013, 2016 École Polytechnique de Montréal and others
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
 
 package org.eclipse.tracecompass.tmf.ctf.core.tests.stubs;
 
-import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
 
 /**
- * Dummy test ctf trace
+ * Generic CTF trace stub
  */
-public class CtfTmfTraceStub extends CtfTmfTrace {
-
-    /**
-     * Simulate trace opening, to be called by tests who need an actively opened
-     * trace
-     */
-    public void openTrace() {
-        TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, this, null));
-        selectTrace();
-    }
-
-    /**
-     * Simulate selecting the trace
-     */
-    public void selectTrace() {
-        TmfSignalManager.dispatchSignal(new TmfTraceSelectedSignal(this, this));
-    }
-
+public class CtfTmfTraceStub extends CtfTmfTrace implements ITmfTraceStub {
 }
diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/stubs/org/eclipse/tracecompass/tmf/ctf/core/tests/stubs/ITmfTraceStub.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/stubs/org/eclipse/tracecompass/tmf/ctf/core/tests/stubs/ITmfTraceStub.java
new file mode 100644 (file)
index 0000000..96bb789
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2016 École Polytechnique de Montréal and others
+ *
+ * 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
+ *
+ * Contributors:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ctf.core.tests.stubs;
+
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * Interface for trace stubs
+ */
+public interface ITmfTraceStub extends ITmfTrace {
+
+    /**
+     * Simulate trace opening, to be called by tests who need an actively opened
+     * trace
+     */
+    default void openTrace() {
+        TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, this, null));
+        selectTrace();
+    }
+
+    /**
+     * Simulate selecting the trace
+     */
+    default void selectTrace() {
+        TmfSignalManager.dispatchSignal(new TmfTraceSelectedSignal(this, this));
+    }
+}
index 53e85dc7445821f05b0333055aa13b9118f4f086..1caae5640f7f5b602c3a7b15a7920fb652884ec4 100644 (file)
@@ -13,5 +13,6 @@
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="perf"/>
        <classpathentry kind="src" path="shared"/>
+       <classpathentry kind="src" path="stubs"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 4426e5e387e976e0a9e2cfcfcc688be87678211f..2927f6203a7c56c67334c2204709f3842c86912e 100644 (file)
@@ -35,6 +35,7 @@ Export-Package: org.eclipse.tracecompass.lttng2.kernel.core.tests,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.syscall,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.tid,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.event.matching,
+ org.eclipse.tracecompass.lttng2.kernel.core.tests.stubs,
  org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm
 Import-Package: com.google.common.collect,
  org.eclipse.test.performance,
index 9a8ad77ccc8cdb763b818f3a7a6dfa724e985ada..1913561b8363a21f4fb7772d507e229ef2b94af3 100644 (file)
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2013, 2015 Ericsson
+# Copyright (c) 2013, 2016 Ericsson
 #
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
@@ -12,7 +12,8 @@
 
 source.. = src/,\
            perf/,\
-           shared/
+           shared/,\
+           stubs/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/LttngKernelTestTraceUtils.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/shared/org/eclipse/tracecompass/lttng2/lttng/kernel/core/tests/shared/LttngKernelTestTraceUtils.java
new file mode 100644 (file)
index 0000000..fd6e853
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.lttng2.lttng.kernel.core.tests.shared;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.tracecompass.lttng2.kernel.core.tests.stubs.LttngKernelTraceStub;
+import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+
+/**
+ * Wrapper for the LTTng Kernel test traces, instantiating
+ * {@link LttngKernelTrace} objects from them.
+ */
+@NonNullByDefault
+public final class LttngKernelTestTraceUtils extends CtfTmfTestTraceUtils {
+
+    private static final Map<CtfTestTrace, CtfTmfTrace> LTTNG_KERNEL_TRACES = new HashMap<>();
+
+    private LttngKernelTestTraceUtils() {
+        super();
+    }
+
+    /**
+     * Return a LttngKernelTraceStub object of this test trace. It will be
+     * already initTrace()'ed.
+     *
+     * After being used by unit tests, traces should be properly disposed by
+     * calling the {@link #dispose(CtfTestTrace)} method.
+     *
+     * @param ctfTrace
+     *            The test trace to initialize
+     * @return A LttngKernelTrace reference to this trace
+     */
+    public static synchronized LttngKernelTrace getTrace(CtfTestTrace ctfTrace) {
+        return (LttngKernelTrace) new LttngKernelTestTraceUtils().internalGetTrace(ctfTrace, LTTNG_KERNEL_TRACES, new LttngKernelTraceStub());
+    }
+
+    /**
+     * Dispose of the trace
+     *
+     * @param ctfTrace
+     *            Trace to dispose
+     */
+    public static synchronized void dispose(CtfTestTrace ctfTrace) {
+        new LttngKernelTestTraceUtils().internalDispose(ctfTrace, LTTNG_KERNEL_TRACES);
+    }
+}
index bf5c589a0997b7d14570406e114eb553156a5437..9b901534159ba14eb591549a5aa6561ddcaa6d15 100644 (file)
@@ -11,7 +11,6 @@ package org.eclipse.tracecompass.lttng2.kernel.core.tests.synchronization;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 
 import java.util.Objects;
 import java.util.concurrent.TimeUnit;
@@ -20,10 +19,9 @@ import java.util.function.Predicate;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
 import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelThreadInformationProvider;
-import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.LttngKernelTestTraceUtils;
 import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
@@ -57,7 +55,6 @@ public class UstKernelSyncTest {
     private static final @NonNull CtfTestTrace UST_TRACE = CtfTestTrace.CONTEXT_SWITCHES_UST;
 
     private TmfExperiment fExperiment;
-    private ITmfTrace fKernelTrace;
     private ITmfTrace fUstTrace;
     private KernelAnalysisModule fKernelModule;
 
@@ -67,19 +64,7 @@ public class UstKernelSyncTest {
     @Before
     public void setup() {
         ITmfTrace ustTrace = CtfTmfTestTraceUtils.getTrace(UST_TRACE);
-
-        /*
-         * We need to initialize the kernel trace to the "LttngKernelTrace"
-         * type ourselves, so the kernel analysis can run on it.
-         */
-        String kernelTracePath = CtfTmfTestTraceUtils.getTrace(KERNEL_TRACE).getPath();
-        ITmfTrace kernelTrace = new LttngKernelTrace();
-
-        try {
-            kernelTrace.initTrace(null, kernelTracePath, CtfTmfEvent.class);
-        } catch (TmfTraceException e) {
-            fail(e.getMessage());
-        }
+        ITmfTrace kernelTrace = LttngKernelTestTraceUtils.getTrace(KERNEL_TRACE);
 
         TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class,
                 "test-exp",
@@ -88,10 +73,6 @@ public class UstKernelSyncTest {
                 null);
 
         /* Simulate experiment being opened */
-        // We have to "open" the sub-traces too, or their analyses are
-        // never initialized. Is that on purpose?
-        TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, ustTrace, null));
-        TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, kernelTrace, null));
         TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, experiment, null));
         TmfSignalManager.dispatchSignal(new TmfTraceSelectedSignal(this, experiment));
 
@@ -101,7 +82,6 @@ public class UstKernelSyncTest {
         module.waitForCompletion();
 
         fExperiment = experiment;
-        fKernelTrace = kernelTrace;
         fUstTrace = ustTrace;
         fKernelModule = module;
     }
@@ -114,12 +94,8 @@ public class UstKernelSyncTest {
         if (fExperiment != null) {
             fExperiment.dispose();
         }
-        if (fKernelTrace != null) {
-            fKernelTrace.dispose();
-        }
-
-        CtfTmfTestTraceUtils.dispose(KERNEL_TRACE);
         CtfTmfTestTraceUtils.dispose(UST_TRACE);
+        LttngKernelTestTraceUtils.dispose(KERNEL_TRACE);
     }
 
     /**
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/stubs/org/eclipse/tracecompass/lttng2/kernel/core/tests/stubs/LttngKernelTraceStub.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/stubs/org/eclipse/tracecompass/lttng2/kernel/core/tests/stubs/LttngKernelTraceStub.java
new file mode 100644 (file)
index 0000000..76e5757
--- /dev/null
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.lttng2.kernel.core.tests.stubs;
+
+import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.stubs.ITmfTraceStub;
+
+/**
+ * LTTng Kernel trace stub
+ */
+public class LttngKernelTraceStub extends LttngKernelTrace implements ITmfTraceStub {
+}
index 5480bc80152d9604a26638ad3345b275e8994da7..c471fd9cd6cbeedd6c2590b096632216f8bf6899 100644 (file)
@@ -11,5 +11,7 @@
                </attributes>
        </classpathentry>
        <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="shared"/>
+       <classpathentry kind="src" path="stubs"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 68de31f3878647728b28567f5ea8fc19554baed1..92d1e0eccb3c9e11c2ba8b76efbd852ff52815fb 100644 (file)
@@ -20,6 +20,8 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
 Export-Package: org.eclipse.tracecompass.lttng2.ust.core.tests,
  org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.debuginfo,
  org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.memory,
- org.eclipse.tracecompass.lttng2.ust.core.tests.callstack
+ org.eclipse.tracecompass.lttng2.ust.core.tests.callstack,
+ org.eclipse.tracecompass.lttng2.ust.core.tests.shared,
+ org.eclipse.tracecompass.lttng2.ust.core.tests.stubs
 Import-Package: com.google.common.collect,
  org.eclipse.tracecompass.testtraces.ctf;version="1.0.0"
index 64c09cdad354364ccd18b89108ac453b393e6fec..ff858ca0367d6ccc6d786da48b87939d70cee9df 100644 (file)
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2013, 2014 Ericsson
+# Copyright (c) 2013, 2016 Ericsson
 #
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
@@ -10,7 +10,9 @@
 #     Ericsson - Initial API and implementation
 ###############################################################################
 
-source.. = src/
+source.. = src/,\
+           stubs/,\
+           shared/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/shared/org/eclipse/tracecompass/lttng2/ust/core/tests/shared/LttngUstTestTraceUtils.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/shared/org/eclipse/tracecompass/lttng2/ust/core/tests/shared/LttngUstTestTraceUtils.java
new file mode 100644 (file)
index 0000000..63a7d49
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.lttng2.ust.core.tests.shared;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.tracecompass.lttng2.ust.core.tests.stubs.LttngUstTraceStub;
+import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+
+/**
+ * Wrapper for the LTTng UST test traces, instantiating
+ * {@link LttngUstTrace} objects from them.
+ */
+@NonNullByDefault
+public final class LttngUstTestTraceUtils extends CtfTmfTestTraceUtils {
+
+    private static final Map<CtfTestTrace, CtfTmfTrace> LTTNG_UST_TRACES = new HashMap<>();
+
+    private LttngUstTestTraceUtils() {
+        super();
+    }
+
+    /**
+     * Return a LttngUstTraceStub object of this test trace. It will be
+     * already initTrace()'ed.
+     *
+     * After being used by unit tests, traces should be properly disposed by
+     * calling the {@link #dispose(CtfTestTrace)} method.
+     *
+     * @param ctfTrace
+     *            The test trace to initialize
+     * @return A LttngUstTrace reference to this trace
+     */
+    public static synchronized LttngUstTrace getTrace(CtfTestTrace ctfTrace) {
+        return (LttngUstTrace) new LttngUstTestTraceUtils().internalGetTrace(ctfTrace, LTTNG_UST_TRACES, new LttngUstTraceStub());
+    }
+
+    /**
+     * Dispose of the trace
+     *
+     * @param ctfTrace
+     *            Trace to dispose
+     */
+    public static synchronized void dispose(CtfTestTrace ctfTrace) {
+        new LttngUstTestTraceUtils().internalDispose(ctfTrace, LTTNG_UST_TRACES);
+    }
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/stubs/org/eclipse/tracecompass/lttng2/ust/core/tests/stubs/LttngUstTraceStub.java b/lttng/org.eclipse.tracecompass.lttng2.ust.core.tests/stubs/org/eclipse/tracecompass/lttng2/ust/core/tests/stubs/LttngUstTraceStub.java
new file mode 100644 (file)
index 0000000..c4297b4
--- /dev/null
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.lttng2.ust.core.tests.stubs;
+
+import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.stubs.ITmfTraceStub;
+
+/**
+ * LTTng UST trace stub
+ */
+public class LttngUstTraceStub extends LttngUstTrace implements ITmfTraceStub {
+}
This page took 0.034612 seconds and 5 git commands to generate.