From eefa5914aa465f0ef164ae6f21dc0d048b03be2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Wed, 11 Jan 2017 16:43:37 -0500 Subject: [PATCH] tmf: Add an XML trace stub with timestamps in seconds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://git.eclipse.org/r/88514 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- .../graph/TmfGraphBuilderModuleTest.java | 3 +- .../stubs/trace/TmfXmlKernelTraceStub.java | 4 +- .../statistics/AbstractStatsAnalysisTest.java | 15 ++-- .../tests/StandardImportAndReadSmokeTest.java | 2 +- .../core/tests/common/TmfXmlTestFiles.java | 6 +- .../analysis/xml/core/tests/Activator.java | 7 +- .../xml/core/tests/module/XmlUtilsTest.java | 10 +-- .../test_traces/testTrace1.xml | 8 +-- .../test_traces/testTrace3.xml | 8 +-- .../test_traces/testTrace4.xml | 8 +-- .../test_traces/testTrace5.xml | 8 +-- .../module/XmlAnalysisOutputSourceTest.java | 4 +- .../plugin.xml | 11 ++- .../StateSystemAnalysisModuleTest.java | 3 +- .../core/tests/trace/TmfExperimentTest.java | 6 +- .../tests/trace/stub/XmlStubTraceTest.java | 12 ++-- .../trace/xml/TmfXmlDevelopmentTrace.xsd | 1 + ...Trace.xml => TmfXmlDevelopmentTraceNs.xml} | 0 .../trace/xml/TmfXmlDevelopmentTraceSec.xml | 57 ++++++++++++++++ .../stubs/trace/xml/TmfXmlTraceStub.java | 37 +++------- .../stubs/trace/xml/TmfXmlTraceStubNs.java | 68 +++++++++++++++++++ .../stubs/trace/xml/TmfXmlTraceStubSec.java | 68 +++++++++++++++++++ .../viewers/events/FilterViewerTest.java | 2 +- 23 files changed, 263 insertions(+), 85 deletions(-) rename tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/{TmfXmlDevelopmentTrace.xml => TmfXmlDevelopmentTraceNs.xml} (100%) create mode 100644 tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceSec.xml create mode 100644 tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubNs.java create mode 100644 tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubSec.java diff --git a/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphBuilderModuleTest.java b/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphBuilderModuleTest.java index 382878ae74..8fc07dcd74 100644 --- a/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphBuilderModuleTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.graph.core.tests/src/org/eclipse/tracecompass/analysis/graph/core/tests/graph/TmfGraphBuilderModuleTest.java @@ -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(); diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/stubs/org/eclipse/tracecompass/analysis/os/linux/core/tests/stubs/trace/TmfXmlKernelTraceStub.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/stubs/org/eclipse/tracecompass/analysis/os/linux/core/tests/stubs/trace/TmfXmlKernelTraceStub.java index 0a158deda7..0f0694690d 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/stubs/org/eclipse/tracecompass/analysis/os/linux/core/tests/stubs/trace/TmfXmlKernelTraceStub.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core.tests/stubs/org/eclipse/tracecompass/analysis/os/linux/core/tests/stubs/trace/TmfXmlKernelTraceStub.java @@ -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; diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.core.tests/src/org/eclipse/tracecompass/analysis/timing/core/tests/segmentstore/statistics/AbstractStatsAnalysisTest.java b/analysis/org.eclipse.tracecompass.analysis.timing.core.tests/src/org/eclipse/tracecompass/analysis/timing/core/tests/segmentstore/statistics/AbstractStatsAnalysisTest.java index bc7f6a7a45..a42c21c967 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.core.tests/src/org/eclipse/tracecompass/analysis/timing/core/tests/segmentstore/statistics/AbstractStatsAnalysisTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.core.tests/src/org/eclipse/tracecompass/analysis/timing/core/tests/segmentstore/statistics/AbstractStatsAnalysisTest.java @@ -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); diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java b/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java index 77916f0d60..d318827229 100644 --- a/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java +++ b/ctf/org.eclipse.tracecompass.tmf.ctf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ctf/ui/swtbot/tests/StandardImportAndReadSmokeTest.java @@ -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); diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java index 9d6afb9d93..132b7e1bcb 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/common/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/common/TmfXmlTestFiles.java @@ -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)); } /** diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/Activator.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/Activator.java index 6061d107c7..5c941776bc 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/Activator.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/Activator.java @@ -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); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java index ab163ae6f4..175ff50c0f 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/core/tests/module/XmlUtilsTest.java @@ -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; } diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace1.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace1.xml index 6d7bd2cffc..e4df2fe95a 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace1.xml +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace1.xml @@ -10,12 +10,12 @@ * Geneviève Bastien - Initial API and implementation *************************************************************************** --> - + - + - + - + \ No newline at end of file diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml index eff953c095..04bc4f5218 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace3.xml @@ -8,15 +8,15 @@ *************************************************************************** --> - + - + - + - + \ No newline at end of file diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace4.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace4.xml index 978e6df81f..6447568b77 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace4.xml +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace4.xml @@ -10,20 +10,20 @@ * Geneviève Bastien - Initial API and implementation *************************************************************************** --> - + - + - + - + diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace5.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace5.xml index 066e492bbd..3894724587 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace5.xml +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_traces/testTrace5.xml @@ -7,16 +7,16 @@ * http://www.eclipse.org/legal/epl-v10.html *************************************************************************** --> - + - + - + - + \ No newline at end of file diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/tests/module/XmlAnalysisOutputSourceTest.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/tests/module/XmlAnalysisOutputSourceTest.java index eb37dea420..dbd34d4cf7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/tests/module/XmlAnalysisOutputSourceTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui.tests/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/tests/module/XmlAnalysisOutputSourceTest.java @@ -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)); diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/plugin.xml b/tmf/org.eclipse.tracecompass.tmf.core.tests/plugin.xml index 3c56bb2668..ae18c7c727 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/plugin.xml +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/plugin.xml @@ -141,8 +141,15 @@ 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"> + + 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.xsd b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xsd index b2f20bf796..4739c629ee 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xsd +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xsd @@ -46,6 +46,7 @@ + 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/TmfXmlDevelopmentTraceNs.xml similarity index 100% rename from tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTrace.xml rename to tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceNs.xml 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 index 0000000000..1cd1aa7e07 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlDevelopmentTraceSec.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +T + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java index 844d784a97..4670eeca58 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java @@ -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> fAdditionalAspects = new HashSet<>(); private final Collection 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 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 index 0000000000..a667944bac --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubNs.java @@ -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 + * 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 index 0000000000..4e44508617 --- /dev/null +++ b/tmf/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStubSec.java @@ -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 + * 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; + } + +} diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterViewerTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterViewerTest.java index 7b67467d88..6c2023e9ef 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterViewerTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterViewerTest.java @@ -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 "; -- 2.34.1