tmf: Add an XML trace stub with timestamps in seconds
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 11 Jan 2017 21:43:37 +0000 (16:43 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 25 Jan 2017 18:54:21 +0000 (13:54 -0500)
This trace takes exactly the same format as the original TmfXmlTraceStub, but
in this case, the timestamps are interpreted as seconds instead of nano.
This will allow to test analyses with various time units and make sure they
have the appropriate results.

Change-Id: I8cf90d39507cb0733872d8551e189b6ffa1103cc
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/88514
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
24 files changed:
analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphBuilderModuleTest.java
analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/stubs/org/eclipse/tracecompass/analysis/os/linux/core/tests/stubs/trace/TmfXmlKernelTraceStub.java
analysis/org.eclipse.tracecompass.analysis.timing.core.tests/src/org/eclipse/tracecompass/analysis/timing/core/tests/segmentstore/statistics/AbstractStatsAnalysisTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/Activator.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace1.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace4.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace5.xml
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/tests/module/XmlAnalysisOutputSourceTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/plugin.xml
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/StateSystemAnalysisModuleTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/TmfExperimentTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/trace/stub/XmlStubTraceTest.java
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xml [deleted file]
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xsd
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceNs.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceSec.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubNs.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubSec.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterViewerTest.java

index 382878ae74f22b9e427839c3088d7069716dcb54..8fc07dcd74d50d17ee26d72d1563916fd9d3b6de 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.Test;
 
 /**
@@ -65,7 +66,7 @@ public class TmfGraphBuilderModuleTest {
      */
     @Test
     public void testBuildGraph() {
-        TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
+        TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(Activator.getAbsoluteFilePath(STUB_TRACE_FILE));
 
         TmfGraphBuilderModule module = getModule(trace);
         module.schedule();
index 0a158deda79929e24736cb7e3bf17f4a594de79f..0f0694690df2fc718b8a0221712bd6fa9a450312 100644 (file)
@@ -15,7 +15,7 @@ import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelTidAspect;
 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 org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 
 import com.google.common.collect.ImmutableSet;
 
@@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet;
  *
  * @author Geneviève Bastien
  */
-public class TmfXmlKernelTraceStub extends TmfXmlTraceStub implements IKernelTrace {
+public class TmfXmlKernelTraceStub extends TmfXmlTraceStubNs implements IKernelTrace {
 
     private @Nullable IKernelAnalysisEventLayout fLayout;
 
index bc7f6a7a4539fb92c7bf3b2fe0df9d5210d56f0f..a42c21c96786d07d5c902c53420030f4b9316d19 100644 (file)
@@ -24,6 +24,7 @@ import org.eclipse.tracecompass.analysis.timing.core.segmentstore.statistics.Seg
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableSet;
@@ -57,7 +58,7 @@ public class AbstractStatsAnalysisTest {
     @Test
     public void testExecuteNoDepend() throws TmfAnalysisException {
         StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         fixture.setTrace(trace);
         assertFalse(fixture.executeAnalysis(new NullProgressMonitor()));
         trace.dispose();
@@ -73,7 +74,7 @@ public class AbstractStatsAnalysisTest {
     @Test
     public void testExecute() throws TmfAnalysisException {
         StubSegmentStatisticsAnalysis fixture = new StubSegmentStatisticsAnalysis();
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         fixture.setTrace(trace);
         fixture.getDependentAnalyses();
         assertTrue(fixture.executeAnalysis(new NullProgressMonitor()));
@@ -90,7 +91,7 @@ public class AbstractStatsAnalysisTest {
      */
     @Test
     public void testTotalStats() throws TmfAnalysisException {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
         SegmentStoreStatistics totalStats = fixture.getTotalStats();
         assertNotNull(totalStats);
@@ -109,7 +110,7 @@ public class AbstractStatsAnalysisTest {
      */
     @Test
     public void testPerTypeStats() throws TmfAnalysisException {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
         Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStats();
         assertNotNull(perTypeStats);
@@ -133,7 +134,7 @@ public class AbstractStatsAnalysisTest {
      */
     @Test
     public void testPartialStats() throws TmfAnalysisException {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
         SegmentStoreStatistics totalStats = fixture.getTotalStatsForRange(100, 1100, new NullProgressMonitor());
         assertNotNull(totalStats);
@@ -155,7 +156,7 @@ public class AbstractStatsAnalysisTest {
      */
     @Test
     public void testPartialPerTypeStats() throws TmfAnalysisException {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
         Map<@NonNull String, @NonNull SegmentStoreStatistics> perTypeStats = fixture.getPerSegmentTypeStatsForRange(100, 1100, new NullProgressMonitor());
         assertNotNull(perTypeStats);
@@ -178,7 +179,7 @@ public class AbstractStatsAnalysisTest {
      */
     @Test
     public void testPartialPerTypeStatsCancel() throws TmfAnalysisException {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStub trace = new TmfXmlTraceStubNs();
         StubSegmentStatisticsAnalysis fixture = getValidSegmentStats(trace);
         NullProgressMonitor monitor = new NullProgressMonitor();
         monitor.setCanceled(true);
index 77916f0d606aef5744f3de869ba0a183f42d9cc0..d31882722961bf27de75a1caac1dd9928fa1e38b 100644 (file)
@@ -450,7 +450,7 @@ public class StandardImportAndReadSmokeTest extends AbstractImportAndReadSmokeTe
         SWTBotImportWizardUtils.selectImportFromArchive(fBot, absolutePath.toOSString());
         String subFolderName = IS_WIN32 ? "folder_colon" : "folder:colon";
         selectFolder(ARCHIVE_ROOT_ELEMENT_NAME, subFolderName);
-        SWTBotImportWizardUtils.setOptions(fBot, 0, "Test trace : XML Trace Stub");
+        SWTBotImportWizardUtils.setOptions(fBot, 0, "Test trace : XML Trace Stub (ns)");
         importFinish();
 
         TmfProjectElement tmfProject = TmfProjectRegistry.getProject(getProjectResource(), true);
index 9d6afb9d9370e947c853808b099b025067f2c3d0..132b7e1bcb531b22ac974e56a3cb1bcaad2933dd 100644 (file)
@@ -69,11 +69,7 @@ public enum TmfXmlTestFiles {
      * @return The absolute path of this test file
      */
     public IPath getPath() {
-        IPath absPath = Activator.getAbsolutePath(new Path(fPath));
-        if (absPath == null) {
-            fail("Cannot find file path for '" + fPath + "'");
-        }
-        return absPath;
+        return Activator.getAbsolutePath(new Path(fPath));
     }
 
     /**
index 6061d107c7281e361bafe81bfade86270d391b8d..5c941776bcb4efdca06a2ba98dabdb2f9311ff14 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jdt.annotation.NonNull;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -68,21 +69,21 @@ public class Activator extends Plugin {
      *            The path relative to this plugin
      * @return The absolute path corresponding to this relative path
      */
-    public static IPath getAbsolutePath(Path relativePath) {
+    public static @NonNull IPath getAbsolutePath(Path relativePath) {
         Activator plugin2 = getDefault();
         if (plugin2 == null) {
             /*
              * Shouldn't happen but at least throw something to get the test to
              * fail early
              */
-            return null;
+            throw new IllegalStateException();
         }
         URL location = FileLocator.find(plugin2.getBundle(), relativePath, null);
         try {
             IPath path = new Path(FileLocator.toFileURL(location).getPath());
             return path;
         } catch (IOException e) {
-            return null;
+            throw new IllegalStateException(e);
         }
     }
 
index ab163ae6f44380fe3b9f2a1e7821683e0a29f367..175ff50c0f5c49c8d20f2812dfb0284cc48c7f4c 100644 (file)
@@ -43,10 +43,9 @@ import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.Activator;
 import org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestFiles;
-import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.After;
 import org.junit.Test;
 import org.w3c.dom.Document;
@@ -225,12 +224,7 @@ public class XmlUtilsTest {
      */
     public static @NonNull ITmfTrace initializeTrace(String traceFile) {
         /* Initialize the trace */
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
-        try {
-            trace.initTrace(null, Activator.getAbsolutePath(new Path(traceFile)).toOSString(), TmfEvent.class);
-        } catch (TmfTraceException e1) {
-            fail(e1.getMessage());
-        }
+        TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(Activator.getAbsolutePath(new Path(traceFile)));
         return trace;
     }
 
index 6d7bd2cffc0f1d152aaea8a65b625e0a56815c61..e4df2fe95af3c7cc75ee136627de9a6ecdd3885d 100644 (file)
        * Geneviève Bastien - Initial API and implementation
 *************************************************************************** -->
 <trace>
-<event timestamp="1" name="test" source="0">
+<event timestamp="1" name="test">
 </event>
-<event timestamp="3" name="test1" source="0">
+<event timestamp="3" name="test1">
 </event>
-<event timestamp="5" name="test" source="0">
+<event timestamp="5" name="test">
 </event>
-<event timestamp="7" name="test1" source="0">
+<event timestamp="7" name="test1">
 </event>
 </trace>
\ No newline at end of file
index eff953c0957aaf1b13db5e00d9bebb946afbb16c..04bc4f5218629f366941a673ef0b85e1bd919efc 100644 (file)
@@ -8,15 +8,15 @@
 *************************************************************************** -->
 <trace>
 <event timestamp="1" name="x">
-<field name="testField" type="double" value="3.141592" />
+<field name="testField" type="string" value="3.141592" />
 </event>
 <event timestamp="3" name="x">
-<field name="testField" type="double" value="2.71828" />
+<field name="testField" type="string" value="2.71828" />
 </event>
 <event timestamp="5" name="x">
-<field name="testField" type="double" value="1.41421" />
+<field name="testField" type="string" value="1.41421" />
 </event>
 <event timestamp="7" name="x">
-<field name="testField" type="double" value="2.68545" />
+<field name="testField" type="string" value="2.68545" />
 </event>
 </trace>
\ No newline at end of file
index 978e6df81f16fb1eec8667be57d8ced815a2481b..6447568b770a056c85b17c41bbcc1299bda046d0 100644 (file)
        * Geneviève Bastien - Initial API and implementation
 *************************************************************************** -->
 <trace>
-<event timestamp="1" name="entry" source="0">
+<event timestamp="1" name="entry">
 <field name="cpu" type="int" value="0" />
 <field name="op" type="string" value="op1" />
 </event>
-<event timestamp="3" name="exit" source="0">
+<event timestamp="3" name="exit">
 <field name="cpu" type="int" value="0" />
 <field name="curState" type="string" value="GOOD" />
 <field name="op" type="string" value="op1" />
 </event>
-<event timestamp="5" name="entry" source="0">
+<event timestamp="5" name="entry">
 <field name="cpu" type="int" value="0" />
 <field name="op" type="string" value="op1" />
 </event>
-<event timestamp="7" name="exit" source="0">
+<event timestamp="7" name="exit">
 <field name="cpu" type="int" value="0" />
 <field name="curState" type="string" value="BAD" />
 <field name="op" type="string" value="op1" />
index 066e492bbd338a1a7ad96c87e7fdabff93a18e86..3894724587c664b80d83631aeed727845dc1ae19 100644 (file)
@@ -7,16 +7,16 @@
 * http://www.eclipse.org/legal/epl-v10.html
 *************************************************************************** -->
 <trace>
-<event timestamp="1" name="entry" source="0">
+<event timestamp="1" name="entry">
 <field name="cpu" type="int" value="0" />
 </event>
-<event timestamp="3" name="entry" source="0">
+<event timestamp="3" name="entry">
 <field name="cpu" type="int" value="0" />
 </event>
-<event timestamp="5" name="entry" source="0">
+<event timestamp="5" name="entry">
 <field name="cpu" type="int" value="0" />
 </event>
-<event timestamp="7" name="exit" source="0">
+<event timestamp="7" name="exit">
 <field name="cpu" type="int" value="0" />
 </event>
 </trace>
\ No newline at end of file
index eb37dea42098a322b6653754f3ccc4c72968b30a..dbd34d4cf78be3e94ad0cdb47d485b534a021120 100644 (file)
@@ -20,7 +20,7 @@ import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.Test;
 
 /**
@@ -40,7 +40,7 @@ public class XmlAnalysisOutputSourceTest {
     @Test
     public void testBuiltinOutput() {
 
-        TmfTrace trace = new TmfXmlTraceStub();
+        TmfTrace trace = new TmfXmlTraceStubNs();
         try {
             trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
 
index 3c56bb2668929350eb94d120e7f208ca3f14fdf9..ae18c7c72721a3379c618dcbc979fe556e5413cd 100644 (file)
             category="org.eclipse.linuxtools.tmf.core.tests.category"
             event_type="org.eclipse.tracecompass.tmf.core.event.TmfEvent"
             id="org.eclipse.linuxtools.tmf.core.tests.xmlstub"
-            name="XML Trace Stub"
-            trace_type="org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub">
+            name="XML Trace Stub (ns)"
+            trace_type="org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs">
+      </type>
+      <type
+            category="org.eclipse.linuxtools.tmf.core.tests.category"
+            event_type="org.eclipse.tracecompass.tmf.core.event.TmfEvent"
+            id="org.eclipse.linuxtools.tmf.core.tests.xmlstubsec"
+            name="XML Trace Stub (sec)"
+            trace_type="org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubSec">
       </type>
    </extension>
    <extension
index 98899b2e80448758ddef872c33fd8a1d2e57c32e..d2ff0b4301928574d7fe8602cc630984fa2f08b7 100644 (file)
@@ -33,6 +33,7 @@ import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestStateSystemModule;
 import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestStateSystemProvider;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -64,7 +65,7 @@ public class StateSystemAnalysisModuleTest {
      */
     @Before
     public void setupTraces() {
-        TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(XML_TRACE));
+        TmfXmlTraceStub trace = TmfXmlTraceStubNs.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(XML_TRACE));
         trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
         fTrace = trace;
 
index e0ccd766ae3e5e2e1bd3a6d694d84229e0788267..92041fc0510b1f3f1c6c17383f3be83fca17b32a 100644 (file)
@@ -60,7 +60,7 @@ import org.eclipse.tracecompass.tmf.core.trace.location.TmfLongLocation;
 import org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestExperimentAnalysis;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfExperimentStub;
 import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -1006,7 +1006,7 @@ public class TmfExperimentTest {
         assertTrue("isCancelled", request.isCancelled());
     }
 
-    private static abstract class TestTrace extends TmfXmlTraceStub implements ITmfPropertiesProvider {
+    private static abstract class TestTrace extends TmfXmlTraceStubNs implements ITmfPropertiesProvider {
 
     }
 
@@ -1099,7 +1099,7 @@ public class TmfExperimentTest {
         };
         t2.setTimestampTransform(tt2);
 
-        ITmfTrace t3 = new TmfXmlTraceStub() {
+        ITmfTrace t3 = new TmfXmlTraceStubNs() {
             @Override
             public @NonNull String getHostId() {
                 return hostId2;
index ad707bfcf89695adfcf67ae8bc3424c59de86933..24eb6c0adefc3aac00ced74bf7b8cdd66f8fdc83 100644 (file)
@@ -31,11 +31,11 @@ import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStub;
+import org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs;
 import org.junit.Test;
 
 /**
- * Test suite for the {@link TmfXmlTraceStub} class
+ * Test suite for the {@link TmfXmlTraceStubNs} class
  *
  * @author Geneviève Bastien
  */
@@ -52,12 +52,12 @@ public class XmlStubTraceTest {
 
     /**
      * Test the
-     * {@link TmfXmlTraceStub#validate(org.eclipse.core.resources.IProject, String)}
+     * {@link TmfXmlTraceStubNs#validate(org.eclipse.core.resources.IProject, String)}
      * method
      */
     @Test
     public void testValidate() {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
+        TmfXmlTraceStubNs trace = new TmfXmlTraceStubNs();
         File[] invalidFiles = TmfCoreTestPlugin.getAbsoluteFilePath(INVALID_PATH).toFile().listFiles();
         assertTrue(invalidFiles.length > 0);
         for (File f : invalidFiles) {
@@ -79,7 +79,7 @@ public class XmlStubTraceTest {
      */
     @Test
     public void testDevelopmentTrace() {
-        TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
+        TmfXmlTraceStubNs trace = TmfXmlTraceStubNs.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
 
         CustomEventRequest req = new CustomEventRequest(trace);
         trace.sendRequest(req);
@@ -101,7 +101,7 @@ public class XmlStubTraceTest {
      */
     @Test
     public void testAspects() {
-        TmfXmlTraceStub trace = TmfXmlTraceStub.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
+        TmfXmlTraceStubNs trace = TmfXmlTraceStubNs.setupTrace(TmfCoreTestPlugin.getAbsoluteFilePath(VALID_FILE));
 
         ITmfEventAspect<?> cpuAspect = null;
         ITmfEventAspect<?> testAspect = null;
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xml b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xml
deleted file mode 100644 (file)
index fb9e333..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<CustomXMLTraceDefinitionList>
-<Definition name="set_aspects">
-<InputElement name="trace">
-<InputElement logentry="true" name="set_aspects">
-<InputData action="0" format="" name="Ignore"/>
-<InputElement name="field">
-<InputData action="0" format="" name="Ignore"/>
-<Attribute name="name">
-<InputData action="2" format="" name="fields"/>
-</Attribute>
-<Attribute name="type">
-<InputData action="2" format="" name="type"/>
-</Attribute>
-<Attribute name="value">
-<InputData action="2" format="" name="values"/>
-</Attribute>
-</InputElement>
-</InputElement>
-</InputElement>
-<OutputColumn name="fields"/>
-<OutputColumn name="values"/>
-<OutputColumn name="type"/>
-</Definition>
-<Definition name="events">
-<TimeStampOutputFormat>Tn</TimeStampOutputFormat>
-<InputElement name="trace">
-<InputElement logentry="true" name="event">
-<InputData action="0" format="" name="Ignore"/>
-<Attribute name="name">
-<InputData action="0" format="" name="Message"/>
-</Attribute>
-<Attribute name="timestamp">
-<InputData action="0" format="Tn" name="Time Stamp"/>
-</Attribute>
-<InputElement name="field">
-<InputData action="0" format="" name="Ignore"/>
-<Attribute name="name">
-<InputData action="2" format="" name="fields"/>
-</Attribute>
-<Attribute name="type">
-<InputData action="2" format="" name="type"/>
-</Attribute>
-<Attribute name="value">
-<InputData action="2" format="" name="values"/>
-</Attribute>
-</InputElement>
-</InputElement>
-</InputElement>
-<OutputColumn name="Time Stamp"/>
-<OutputColumn name="Message"/>
-<OutputColumn name="source"/>
-<OutputColumn name="fields"/>
-<OutputColumn name="values"/>
-<OutputColumn name="type"/>
-</Definition>
-</CustomXMLTraceDefinitionList>
index b2f20bf796a07eba9f0d861594b60d4d6086b053..4739c629ee406151ee624e27666d5fd135620bf3 100644 (file)
@@ -46,6 +46,7 @@
                                        <xs:enumeration value="int"/>
                                        <xs:enumeration value="long"/>
                                        <xs:enumeration value="string"/>
+                                       <xs:enumeration value="double"/>
                                </xs:restriction>
                        </xs:simpleType>
                </xs:attribute>
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceNs.xml b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceNs.xml
new file mode 100644 (file)
index 0000000..fb9e333
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<CustomXMLTraceDefinitionList>
+<Definition name="set_aspects">
+<InputElement name="trace">
+<InputElement logentry="true" name="set_aspects">
+<InputData action="0" format="" name="Ignore"/>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+<Definition name="events">
+<TimeStampOutputFormat>Tn</TimeStampOutputFormat>
+<InputElement name="trace">
+<InputElement logentry="true" name="event">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="0" format="" name="Message"/>
+</Attribute>
+<Attribute name="timestamp">
+<InputData action="0" format="Tn" name="Time Stamp"/>
+</Attribute>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="Time Stamp"/>
+<OutputColumn name="Message"/>
+<OutputColumn name="source"/>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+</CustomXMLTraceDefinitionList>
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceSec.xml b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceSec.xml
new file mode 100644 (file)
index 0000000..1cd1aa7
--- /dev/null
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<CustomXMLTraceDefinitionList>
+<Definition name="set_aspects">
+<InputElement name="trace">
+<InputElement logentry="true" name="set_aspects">
+<InputData action="0" format="" name="Ignore"/>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+<Definition name="events">
+<TimeStampOutputFormat>T</TimeStampOutputFormat>
+<InputElement name="trace">
+<InputElement logentry="true" name="event">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="0" format="" name="Message"/>
+</Attribute>
+<Attribute name="timestamp">
+<InputData action="0" format="T" name="Time Stamp"/>
+</Attribute>
+<InputElement name="field">
+<InputData action="0" format="" name="Ignore"/>
+<Attribute name="name">
+<InputData action="2" format="" name="fields"/>
+</Attribute>
+<Attribute name="type">
+<InputData action="2" format="" name="type"/>
+</Attribute>
+<Attribute name="value">
+<InputData action="2" format="" name="values"/>
+</Attribute>
+</InputElement>
+</InputElement>
+</InputElement>
+<OutputColumn name="Time Stamp"/>
+<OutputColumn name="Message"/>
+<OutputColumn name="source"/>
+<OutputColumn name="fields"/>
+<OutputColumn name="values"/>
+<OutputColumn name="type"/>
+</Definition>
+</CustomXMLTraceDefinitionList>
index 844d784a9740cfe071794a41074f9bc7d07c48c2..4670eeca5846d893733974fc8015a5da6dd7a621 100644 (file)
@@ -14,7 +14,6 @@
 package org.eclipse.tracecompass.tmf.tests.stubs.trace.xml;
 
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
@@ -34,7 +33,6 @@ import javax.xml.validation.Validator;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jdt.annotation.DefaultLocation;
@@ -87,9 +85,8 @@ import com.google.common.collect.Iterables;
  *
  * @author Geneviève Bastien
  */
-public class TmfXmlTraceStub extends TmfTrace {
+public abstract class TmfXmlTraceStub extends TmfTrace {
 
-    private static final String DEVELOPMENT_TRACE_PARSER_PATH = "TmfXmlDevelopmentTrace.xml"; //$NON-NLS-1$
     private static final String DEVELOPMENT_TRACE_XSD = "TmfXmlDevelopmentTrace.xsd"; //$NON-NLS-1$
     private static final String EMPTY = ""; //$NON-NLS-1$
 
@@ -110,28 +107,6 @@ public class TmfXmlTraceStub extends TmfTrace {
     private final Collection<ITmfEventAspect<?>> fAdditionalAspects = new HashSet<>();
     private final Collection<IAnalysisModule> fAdditionalModules = new HashSet<>();
 
-    /**
-     * Validate and initialize a {@link TmfXmlTraceStub} object
-     *
-     * @param absolutePath
-     *            The absolute file path of the trace file
-     * @return The trace
-     */
-    public static TmfXmlTraceStub setupTrace(IPath absolutePath) {
-        TmfXmlTraceStub trace = new TmfXmlTraceStub();
-        IStatus status = trace.validate(null, absolutePath.toOSString());
-        if (!status.isOK()) {
-            fail(status.getException().getMessage());
-        }
-        try {
-            trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
-        } catch (TmfTraceException e) {
-            trace.dispose();
-            fail(e.getMessage());
-        }
-        return trace;
-    }
-
     /**
      * Constructor. Constructs the custom XML trace with the appropriate
      * definition.
@@ -139,7 +114,7 @@ public class TmfXmlTraceStub extends TmfTrace {
     public TmfXmlTraceStub() {
         boolean nonNullTraceIsNonNull = false;
         /* Load custom XML definition */
-        try (InputStream in = TmfXmlTraceStub.class.getResourceAsStream(DEVELOPMENT_TRACE_PARSER_PATH);) {
+        try (InputStream in = TmfXmlTraceStub.class.getResourceAsStream(getParserFileName());) {
             CustomXmlTraceDefinition[] definitions = CustomXmlTraceDefinition.loadAll(in);
             if (definitions.length < 2) {
                 throw new IllegalStateException("The custom trace definition does not exist"); //$NON-NLS-1$
@@ -165,6 +140,14 @@ public class TmfXmlTraceStub extends TmfTrace {
 
     }
 
+    /**
+     * Get the name of the file that contains the XML parser for this trace
+     * stub. The file should be located in this class's package.
+     *
+     * @return The name of the file
+     */
+    protected abstract String getParserFileName();
+
     @Override
     @NonNullByDefault({DefaultLocation.TYPE_ARGUMENT})
     public void initTrace(@Nullable IResource resource, @Nullable String path, @Nullable Class<? extends ITmfEvent> type) throws TmfTraceException {
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubNs.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubNs.java
new file mode 100644 (file)
index 0000000..a667944
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * 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.tmf.tests.stubs.trace.xml;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+
+/**
+ * An XML development trace using a custom XML trace definition and schema.
+ *
+ * This class will typically be used to build custom traces to unit test more
+ * complex functionalities like analyzes or to develop and test data-driven
+ * analyzes.
+ *
+ * This class wraps a custom XML trace and rewrites the returned events in the
+ * getNext() method so that event's fields are the ones defined in <field ... />
+ * elements instead of those defined in the custom XML parser. This way, each
+ * event can have a different set of fields. This class can, for example, mimic
+ * a CTF trace.
+ *
+ * The timestamps of this trace will be in nanoseconds
+ *
+ * @author Geneviève Bastien
+ */
+public class TmfXmlTraceStubNs extends TmfXmlTraceStub {
+
+    private static final String DEVELOPMENT_TRACE_PARSER_PATH = "TmfXmlDevelopmentTraceNs.xml"; //$NON-NLS-1$
+
+    /**
+     * Validate and initialize a {@link TmfXmlTraceStubNs} object
+     *
+     * @param absolutePath
+     *            The absolute file path of the trace file
+     * @return The trace
+     */
+    public static TmfXmlTraceStubNs setupTrace(IPath absolutePath) {
+        TmfXmlTraceStubNs trace = new TmfXmlTraceStubNs();
+        IStatus status = trace.validate(null, absolutePath.toOSString());
+        if (!status.isOK()) {
+            fail(status.getException().getMessage());
+        }
+        try {
+            trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
+        } catch (TmfTraceException e) {
+            trace.dispose();
+            fail(e.getMessage());
+        }
+        return trace;
+    }
+
+    @Override
+    protected @NonNull String getParserFileName() {
+        return DEVELOPMENT_TRACE_PARSER_PATH;
+    }
+
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubSec.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubSec.java
new file mode 100644 (file)
index 0000000..4e44508
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * 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.tmf.tests.stubs.trace.xml;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+
+/**
+ * An XML development trace using a custom XML trace definition and schema.
+ *
+ * This class will typically be used to build custom traces to unit test more
+ * complex functionalities like analyzes or to develop and test data-driven
+ * analyzes.
+ *
+ * This class wraps a custom XML trace and rewrites the returned events in the
+ * getNext() method so that event's fields are the ones defined in <field ... />
+ * elements instead of those defined in the custom XML parser. This way, each
+ * event can have a different set of fields. This class can, for example, mimic
+ * a CTF trace.
+ *
+ * The timestamps of this trace will be in seconds
+ *
+ * @author Geneviève Bastien
+ */
+public class TmfXmlTraceStubSec extends TmfXmlTraceStub {
+
+    private static final String DEVELOPMENT_TRACE_PARSER_PATH = "TmfXmlDevelopmentTraceSec.xml"; //$NON-NLS-1$
+
+    /**
+     * Validate and initialize a {@link TmfXmlTraceStubSec} object
+     *
+     * @param absolutePath
+     *            The absolute file path of the trace file
+     * @return The trace
+     */
+    public static TmfXmlTraceStubSec setupTrace(IPath absolutePath) {
+        TmfXmlTraceStubSec trace = new TmfXmlTraceStubSec();
+        IStatus status = trace.validate(null, absolutePath.toOSString());
+        if (!status.isOK()) {
+            fail(status.getException().getMessage());
+        }
+        try {
+            trace.initTrace(null, absolutePath.toOSString(), TmfEvent.class);
+        } catch (TmfTraceException e) {
+            trace.dispose();
+            fail(e.getMessage());
+        }
+        return trace;
+    }
+
+    @Override
+    protected @NonNull String getParserFileName() {
+        return DEVELOPMENT_TRACE_PARSER_PATH;
+    }
+
+}
index 7b67467d8827009890c5caaa2cab6cb67925a3ad..6c2023e9ef7e7863c842276ec9614f531ae1563a 100644 (file)
@@ -59,7 +59,7 @@ public class FilterViewerTest {
     private static final String COMPARE = "COMPARE";
     private static final String CONTAINS = "CONTAINS";
     private static final String XMLSTUB_ID = "org.eclipse.linuxtools.tmf.core.tests.xmlstub";
-    private static final String TRACETYPE = "Test trace : XML Trace Stub";
+    private static final String TRACETYPE = "Test trace : XML Trace Stub (ns)";
     private static final String AND = "AND";
     private static final String WITH_TRACETYPE = "WITH TRACETYPE " + TRACETYPE;
     private static final String FILTER_TEST = "FILTER ";
This page took 0.04224 seconds and 5 git commands to generate.