From 9ac63b5b7d1887d843f145b9c3857fd7ba495b69 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Wed, 4 Sep 2013 15:12:58 -0400 Subject: [PATCH] tmf: Rework test trace classes Currently, test traces are accessed using array indices, which is simple but scales very badly. It's also very confusing when writing a new trace and wanting to decided which test trace to use. Rework the test trace classes by replacing them with enum's that do the same thing. Unfortunately, you cannot extend enums, so duplication of the names is needed, but everything else is centralized in one place. Change-Id: I6e598048531682428c1142c18d1760c21de5aeac Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/16143 Reviewed-by: Marc-Andre Laperle Tested-by: Hudson CI --- .../ctf/core/tests/shared/CtfTestTrace.java | 92 ++++++++++ .../ctf/core/tests/shared/CtfTestTraces.java | 161 ------------------ .../CTFTraceCallsitePerformanceTest.java | 8 +- .../core/tests/trace/CTFTraceReaderTest.java | 12 +- .../ctf/core/tests/trace/CTFTraceTest.java | 45 +++-- .../ctf/core/tests/trace/MetadataTest.java | 8 +- .../tests/trace/StreamInputReaderTest.java | 11 +- .../ctf/core/tests/trace/StreamInputTest.java | 18 +- .../ctf/core/tests/trace/StreamTest.java | 15 +- .../tests/types/EventDeclarationTest.java | 12 +- .../tests/types/VariantDeclarationTest.java | 8 +- .../headless/BasicStateSystemExample.java | 4 +- .../tests/headless/GenerateTestValues.java | 8 +- .../LttngKernelStateProviderTest.java | 8 +- .../stateprovider/PartialStateSystemTest.java | 5 +- .../StateSystemFullHistoryTest.java | 7 +- .../StateSystemInMemoryTest.java | 5 +- .../tests/stateprovider/StateSystemTest.java | 5 +- .../core/tests/shared/CtfTmfTestTrace.java | 82 +++++++++ .../core/tests/shared/CtfTmfTestTraces.java | 112 ------------ .../tests/ctfadaptor/CtfIteratorTest.java | 22 +-- .../tests/ctfadaptor/CtfTmfContextTest.java | 8 +- .../tests/ctfadaptor/CtfTmfEventTest.java | 8 +- .../tests/ctfadaptor/CtfTmfTraceTest.java | 12 +- .../tests/ctfadaptor/EventContextTest.java | 9 +- .../tests/request/TmfSchedulerBenchmark.java | 5 +- .../core/tests/request/TmfSchedulerTest.java | 9 +- .../statistics/TmfEventsStatisticsTest.java | 5 +- .../statistics/TmfStateStatisticsTest.java | 7 +- .../tests/statistics/TmfStatisticsTest.java | 5 +- .../core/tests/trace/TmfTraceManagerTest.java | 9 +- .../project/model/ProjectModelTestData.java | 9 +- .../project/model/ProjectModelTraceTest.java | 4 +- 33 files changed, 321 insertions(+), 417 deletions(-) create mode 100644 org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTrace.java delete mode 100644 org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTraces.java create mode 100644 org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTrace.java delete mode 100644 org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java diff --git a/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTrace.java b/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTrace.java new file mode 100644 index 0000000000..8250cabe66 --- /dev/null +++ b/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTrace.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * + * Contributors: + * Alexandre Montplaisir - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.ctf.core.tests.shared; + +import java.io.File; + +import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; +import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; + +/** + * Here is the list of the available test traces for the CTF parser. + * + * Make sure you run the traces/get-traces.xml Ant script (or get-traces.sh + * shell script) to download them first! + * + * @author Alexandre Montplaisir + */ +public enum CtfTestTrace { + /** Example kernel trace */ + KERNEL("../org.eclipse.linuxtools.ctf.core.tests/traces/kernel"), + /** Another kernel trace */ + TRACE2("../org.eclipse.linuxtools.ctf.core.tests/traces/trace2"), + /** Kernel trace with event contexts */ + KERNEL_VM("../org.eclipse.linuxtools.ctf.core.tests/traces/kernel_vm"); + + + private final String fPath; + private CTFTrace fTrace = null; + private CTFTrace fTraceFromFile = null; + + private CtfTestTrace(String path) { + fPath = path; + } + + /** @return The path to the test trace */ + public String getPath() { + return fPath; + } + + /** + * Get a CTFTrace instance of a test trace. Make sure + * {@link #exists()} before calling this! + * + * @return The CTFTrace object + * @throws CTFReaderException + * If the trace cannot be found. + */ + public CTFTrace getTrace() throws CTFReaderException { + if (fTrace == null) { + fTrace = new CTFTrace(fPath); + } + return fTrace; + } + + /** + * Get a CTFTrace instance created from a File. Make sure + * {@link #exists()} before calling this! + * + * @return The CTFTrace object + * @throws CTFReaderException + * If the trace cannot be found. + */ + public CTFTrace getTraceFromFile() throws CTFReaderException { + if (fTraceFromFile == null) { + fTraceFromFile = new CTFTrace(new File(fPath)); + } + return fTraceFromFile; + } + + /** + * Check if this test trace actually exists on disk. + * + * @return If the trace exists + */ + public boolean exists() { + try { + getTrace(); + } catch (CTFReaderException e) { + return false; + } + return true; + } +} diff --git a/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTraces.java b/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTraces.java deleted file mode 100644 index 1f8f14f99d..0000000000 --- a/org.eclipse.linuxtools.ctf.core.tests/shared/org/eclipse/linuxtools/ctf/core/tests/shared/CtfTestTraces.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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 - * - * Contributors: - * Alexandre Montplaisir - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.ctf.core.tests.shared; - -import java.io.File; - -import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; -import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; - -/** - * Here are the definitions common to all the CTF parser tests. - * - * @author alexmont - */ -public abstract class CtfTestTraces { - - /* - * Path to test traces. Make sure you run the traces/get-traces.sh script - * first! - */ - private static final String[] testTracePaths = { - "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel", - "../org.eclipse.linuxtools.ctf.core.tests/traces/trace2", - "../org.eclipse.linuxtools.ctf.core.tests/traces/kernel_vm" - }; - - private static CTFTrace[] testTraces = new CTFTrace[testTracePaths.length]; - private static CTFTrace[] testTracesFromFile = new CTFTrace[testTracePaths.length]; - - private static final File testTraceFile1 = new File(testTracePaths[0] + "/channel0_0"); - - private static final File emptyFile = new File(""); - private static CTFTrace emptyTrace = null; - - /** - * Return an empty file (new File("");) - * - * @return An empty file - */ - public static File getEmptyFile() { - return emptyFile; - } - - /** - * Return a file in test trace #1 (channel0_0). - * - * Make sure {@link #tracesExist()} before calling this! - * - * @return A file in a test trace - */ - public static File getTraceFile(){ - return testTraceFile1; - } - - /** - * Return a trace out of an empty file (new CTFTrace("");) - * - * @return An empty trace - */ - public static CTFTrace getEmptyTrace() { - if (emptyTrace == null) { - try { - emptyTrace = new CTFTrace(""); - } catch (CTFReaderException e) { - /* Should always work... */ - throw new RuntimeException(e); - } - } - return emptyTrace; - } - - /** - * Get a CTFTrace reference to the given test trace. - * - * Make sure {@link #tracesExist()} before calling this! - * - * @param idx - * The index of the trace among all the available ones - * @return Reference to test trace #1 - * @throws CTFReaderException - * If the trace cannot be found - */ - public static CTFTrace getTestTrace(int idx) throws CTFReaderException { - if (testTraces[idx] == null) { - testTraces[idx] = new CTFTrace(testTracePaths[idx]); - } - return testTraces[idx]; - } - - /** - * Get the (string) path to a given test trace. - * - * You should call {@link #tracesExist()} before calling this if you are - * going to use this trace for real. - * - * @param idx - * The index of the trace among all the available ones - * @return The path to the test trace - */ - public static String getTestTracePath(int idx) { - return testTracePaths[idx]; - } - - /** - * Same as {@link #getTestTrace}, except the CTFTrace is create from the - * File object and not the path. - * - * Make sure {@link #tracesExist()} before calling this! - * - * @param idx - * The index of the trace among all the available ones - * @return Reference to test trace #1 - */ - public static CTFTrace getTestTraceFromFile(int idx) { - if (testTracesFromFile[idx] == null) { - try { - testTracesFromFile[idx] = new CTFTrace(new File(testTracePaths[idx])); - } catch (CTFReaderException e) { - /* This trace should exist */ - throw new RuntimeException(e); - } - } - return testTracesFromFile[idx]; - } - - /** - * Check if the test traces are present in the tree. If not, you can get - * them by running traces/get-traces.sh or traces/get-traces.xml - * - * @return True if *all* the test files could be found, false otherwise. - */ - public static boolean tracesExist() { - for (int i = 0; i < testTracePaths.length; i++) { - if (!traceExists(i)) { - return false; - } - } - return true; - } - - private static boolean traceExists(int idx) { - if (testTraces[idx] != null) { - return true; - } - try { - getTestTrace(idx); - } catch (CTFReaderException e) { - return false; - } - return true; - } -} diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceCallsitePerformanceTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceCallsitePerformanceTest.java index c361ec2648..a34f883e50 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceCallsitePerformanceTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceCallsitePerformanceTest.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Random; import org.eclipse.linuxtools.ctf.core.event.CTFCallsite; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.junit.Before; @@ -32,6 +32,8 @@ import org.junit.Test; */ public class CTFTraceCallsitePerformanceTest { + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; + private static final int NUMBER_OF_SEEKS = 100000; private final String[] callsites = { "Alligator", "Bunny", "Cat", @@ -73,8 +75,8 @@ public class CTFTraceCallsitePerformanceTest { @Before public void setup() throws CTFReaderException, SecurityException, IllegalArgumentException { - assumeTrue(CtfTestTraces.tracesExist()); - fTrace = new CTFTrace(CtfTestTraces.getTraceFile().getParentFile()); + assumeTrue(testTrace.exists()); + fTrace = new CTFTrace(testTrace.getPath()); } private void addCallsites(int numCallsites) { diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java index 4b6b9cd298..1bc176645d 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import org.eclipse.linuxtools.ctf.core.event.EventDefinition; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader; @@ -35,7 +35,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class CTFTraceReaderTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private CTFTraceReader fixture; @@ -46,8 +46,8 @@ public class CTFTraceReaderTest { */ @Before public void setUp() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); - fixture = new CTFTraceReader(CtfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + fixture = new CTFTraceReader(testTrace.getTrace()); } /** @@ -58,7 +58,7 @@ public class CTFTraceReaderTest { */ @Test public void testOpen_existing() throws CTFReaderException { - CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); + CTFTrace trace = testTrace.getTrace(); CTFTraceReader result = new CTFTraceReader(trace); assertNotNull(result); @@ -155,7 +155,7 @@ public class CTFTraceReaderTest { */ @Test public void testEquals() throws CTFReaderException { - CTFTraceReader fixture2 = new CTFTraceReader(CtfTestTraces.getTestTrace(TRACE_INDEX)); + CTFTraceReader fixture2 = new CTFTraceReader(testTrace.getTrace()); assertEquals(fixture, fixture2); } diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java index 6d94600004..dc93c8974e 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java @@ -28,7 +28,7 @@ import java.util.UUID; import org.eclipse.linuxtools.ctf.core.event.CTFClock; import org.eclipse.linuxtools.ctf.core.event.types.Definition; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.Stream; @@ -48,7 +48,7 @@ public class CTFTraceTest { private static final String METADATA_FILENAME = "metadata"; - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private static final String CTF_VERSION_NUMBER = "1.8"; private static final String CTF_SUITE_TEST_DIRECTORY = "ctf-testsuite/tests/" + CTF_VERSION_NUMBER; @@ -60,8 +60,13 @@ public class CTFTraceTest { */ @Before public void setUp() { - assumeTrue(CtfTestTraces.tracesExist()); - fixture = CtfTestTraces.getTestTraceFromFile(TRACE_INDEX); + assumeTrue(testTrace.exists()); + try { + fixture = testTrace.getTraceFromFile(); + } catch (CTFReaderException e) { + /* If the assumeTrue() call passed, this should not happen. */ + fail(); + } fixture.setMinor(1L); fixture.setUUID(UUID.randomUUID()); fixture.setPacketHeader(new StructDeclaration(1L)); @@ -74,8 +79,12 @@ public class CTFTraceTest { */ @Test public void testOpen_existing() { - CTFTrace result = CtfTestTraces.getTestTraceFromFile(TRACE_INDEX); - assertNotNull(result.getUUID()); + try { + CTFTrace result = testTrace.getTraceFromFile(); + assertNotNull(result.getUUID()); + } catch (CTFReaderException e) { + fail(); + } } /** @@ -111,7 +120,7 @@ public class CTFTraceTest { // Add a stream try { - Stream stream = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)); + Stream stream = new Stream(testTrace.getTrace()); stream.setId(1234); fixture.addStream(stream); } catch (CTFReaderException e) { @@ -259,15 +268,19 @@ public class CTFTraceTest { */ @Test public void testPacketHeaderIsSet_invalid() { - CTFTrace fixture2 = CtfTestTraces.getTestTraceFromFile(TRACE_INDEX); - fixture2.setMinor(1L); - fixture2.setUUID(UUID.randomUUID()); - fixture2.setPacketHeader((StructDeclaration) null); /* it's null here! */ - fixture2.setMajor(1L); - fixture2.setByteOrder(ByteOrder.BIG_ENDIAN); - - boolean result = fixture2.packetHeaderIsSet(); - assertFalse(result); + try { + CTFTrace fixture2 = testTrace.getTraceFromFile(); + fixture2.setMinor(1L); + fixture2.setUUID(UUID.randomUUID()); + fixture2.setPacketHeader((StructDeclaration) null); /* it's null here! */ + fixture2.setMajor(1L); + fixture2.setByteOrder(ByteOrder.BIG_ENDIAN); + + boolean result = fixture2.packetHeaderIsSet(); + assertFalse(result); + } catch (CTFReaderException e) { + fail(); + } } /** diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java index 87b9702535..84e88d9be1 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/MetadataTest.java @@ -17,7 +17,7 @@ import static org.junit.Assume.assumeTrue; import java.nio.ByteOrder; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.Metadata; import org.junit.Before; @@ -33,7 +33,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class MetadataTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private Metadata fixture; @@ -44,8 +44,8 @@ public class MetadataTest { */ @Before public void setUp() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); - fixture = new Metadata(CtfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + fixture = new Metadata(testTrace.getTrace()); } /** diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputReaderTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputReaderTest.java index e9f0823d57..d269d01347 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputReaderTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputReaderTest.java @@ -16,12 +16,13 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; +import java.io.File; import java.nio.channels.FileChannel; import java.util.Set; import org.eclipse.linuxtools.ctf.core.event.EventDefinition; import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.Stream; @@ -41,7 +42,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class StreamInputReaderTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private StreamInputReader fixture; @@ -59,8 +60,8 @@ public class StreamInputReaderTest { } private static StreamInputReader getStreamInputReader() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); - CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); + assumeTrue(testTrace.exists()); + CTFTrace trace = testTrace.getTrace(); Stream s = trace.getStream((long) 0); Set streamInput = s.getStreamInputs(); StreamInputReader retVal = null; @@ -95,7 +96,7 @@ public class StreamInputReaderTest { @Test(expected = CTFReaderException.class) public void testStreamInputReader_invalid() throws CTFReaderException { StreamInput streamInput = new StreamInput( - new Stream(new CTFTrace("")), (FileChannel) null, CtfTestTraces.getEmptyFile()); + new Stream(new CTFTrace("")), (FileChannel) null, new File("")); StreamInputReader result = new StreamInputReader(streamInput); assertNotNull(result); diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java index 94007cf089..f9d0c79a75 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamInputTest.java @@ -22,7 +22,7 @@ import java.io.File; import java.nio.channels.FileChannel; import org.eclipse.linuxtools.ctf.core.event.types.Definition; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.Stream; import org.eclipse.linuxtools.ctf.core.trace.StreamInput; @@ -39,7 +39,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class StreamInputTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private StreamInput fixture; @@ -50,8 +50,8 @@ public class StreamInputTest { */ @Before public void setUp() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); - fixture = new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), + assumeTrue(testTrace.exists()); + fixture = new StreamInput(new Stream(testTrace.getTrace()), (FileChannel) null, createFile()); fixture.setTimestampEnd(1L); } @@ -137,30 +137,30 @@ public class StreamInputTest { @Test public void testEquals1() throws CTFReaderException{ - s1 = new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), + s1 = new StreamInput(new Stream(testTrace.getTrace()), (FileChannel) null, createFile()); assertFalse(s1.equals(null)); } @Test public void testEquals2() throws CTFReaderException{ - s1 = new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), + s1 = new StreamInput(new Stream(testTrace.getTrace()), (FileChannel) null, createFile()); assertFalse(s1.equals(new Long(23L))); } @Test public void testEquals3() throws CTFReaderException{ - s1 = new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), + s1 = new StreamInput(new Stream(testTrace.getTrace()), (FileChannel) null, createFile()); assertEquals(s1,s1); } @Test public void testEquals4() throws CTFReaderException{ - s1 = new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), + s1 = new StreamInput(new Stream(testTrace.getTrace()), (FileChannel) null, createFile()); - s2 = new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), + s2 = new StreamInput(new Stream(testTrace.getTrace()), (FileChannel) null, createFile()); assertEquals(s1,s2); } diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java index 89265db208..4826e66313 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java @@ -15,13 +15,14 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; +import java.io.File; import java.nio.channels.FileChannel; import java.util.Map; import java.util.Set; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.Stream; @@ -41,7 +42,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class StreamTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private Stream fixture; @@ -52,14 +53,14 @@ public class StreamTest { */ @Before public void setUp() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); - fixture = new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + fixture = new Stream(testTrace.getTrace()); fixture.setEventContext(new StructDeclaration(1L)); fixture.setPacketContext(new StructDeclaration(1L)); fixture.setEventHeader(new StructDeclaration(1L)); fixture.setId(1L); - fixture.addInput(new StreamInput(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX)), - (FileChannel) null, CtfTestTraces.getEmptyFile())); + fixture.addInput(new StreamInput(new Stream(testTrace.getTrace()), + (FileChannel) null, new File(""))); } /** @@ -69,7 +70,7 @@ public class StreamTest { */ @Test public void testStream() throws CTFReaderException { - CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); + CTFTrace trace = testTrace.getTrace(); Stream result = new Stream(trace); assertNotNull(result); } diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventDeclarationTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventDeclarationTest.java index df5aed5fd8..181c15c9b8 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventDeclarationTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventDeclarationTest.java @@ -20,7 +20,7 @@ import static org.junit.Assume.assumeTrue; import org.eclipse.linuxtools.ctf.core.event.EventDefinition; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader; @@ -39,7 +39,7 @@ import org.junit.Test; @SuppressWarnings("javadoc") public class EventDeclarationTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private EventDeclaration fixture; @@ -50,12 +50,12 @@ public class EventDeclarationTest { */ @Before public void setUp() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); fixture = new EventDeclaration(); fixture.setContext(new StructDeclaration(1L)); fixture.setId(1L); fixture.setFields(new StructDeclaration(1L)); - fixture.setStream(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX))); + fixture.setStream(new Stream(testTrace.getTrace())); fixture.setName(""); } @@ -99,7 +99,7 @@ public class EventDeclarationTest { obj.setContext(new StructDeclaration(1L)); obj.setId(1L); obj.setFields(new StructDeclaration(1L)); - obj.setStream(new Stream(CtfTestTraces.getTestTrace(TRACE_INDEX))); + obj.setStream(new Stream(testTrace.getTrace())); obj.setName(""); assertTrue(fixture.equals(fixture)); @@ -316,7 +316,7 @@ public class EventDeclarationTest { */ @Test public void testEventDefinition() throws CTFReaderException { - CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX); + CTFTrace trace = testTrace.getTrace(); CTFTraceReader tr = new CTFTraceReader(trace); tr.advance(); EventDefinition ed = new EventDefinition(null, null); diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDeclarationTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDeclarationTest.java index eee99b3dd2..dd91269274 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDeclarationTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDeclarationTest.java @@ -22,7 +22,7 @@ import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition; import org.eclipse.linuxtools.ctf.core.event.types.VariantDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.VariantDefinition; -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.junit.Before; import org.junit.Test; @@ -36,7 +36,7 @@ import org.junit.Test; */ public class VariantDeclarationTest { - private static final int TRACE_INDEX = 0; + private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL; private VariantDeclaration fixture; @@ -87,13 +87,13 @@ public class VariantDeclarationTest { } private static IDefinitionScope createDefinitionScope() throws CTFReaderException { - assumeTrue(CtfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); VariantDeclaration declaration = new VariantDeclaration(); declaration.setTag(""); VariantDeclaration variantDeclaration = new VariantDeclaration(); variantDeclaration.setTag(""); VariantDefinition variantDefinition = new VariantDefinition( - variantDeclaration, CtfTestTraces.getTestTrace(TRACE_INDEX), ""); + variantDeclaration, testTrace.getTrace(), ""); IDefinitionScope definitionScope = new StructDefinition( new StructDeclaration(1L), variantDefinition, ""); String fieldName = ""; diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java index 9c4d571313..b7fcc7b6e8 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/BasicStateSystemExample.java @@ -26,7 +26,7 @@ import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem; import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; /** * Simple example of how to use the state system using a CTF kernel trace. @@ -43,7 +43,7 @@ public class BasicStateSystemExample { /* Read a trace and build the state system */ try { File newStateFile = new File("/tmp/helloworldctf.ht"); - ITmfStateProvider input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(1)); + ITmfStateProvider input = new LttngKernelStateProvider(CtfTmfTestTrace.TRACE2.getTrace()); ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(newStateFile, input, true); requestExample(ss); diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/GenerateTestValues.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/GenerateTestValues.java index 9617a94fe1..44e71c04ad 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/GenerateTestValues.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/headless/GenerateTestValues.java @@ -23,7 +23,7 @@ import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem; import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory; import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; /** * Small program to regenerate the values used in "TestValues.java" from the @@ -36,7 +36,7 @@ import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; */ public class GenerateTestValues { - private static final int TRACE_INDEX = 1; + private static CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2; private static final long targetTimestamp = 18670067372290L + 1331649577946812237L; private static final String INDENT = " "; @@ -49,7 +49,7 @@ public class GenerateTestValues { * I'm messing with Exception. Come at me bro! */ public static void main(String[] args) throws Exception { - if (!CtfTmfTestTraces.tracesExist()) { + if (!testTrace.exists()) { System.err.println("Trace files not present."); return; } @@ -61,7 +61,7 @@ public class GenerateTestValues { PrintWriter writer = new PrintWriter(new FileWriter(logFile), true); /* Build and query the state system */ - ITmfStateProvider input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + ITmfStateProvider input = new LttngKernelStateProvider(testTrace.getTrace()); ITmfStateSystem ssq = TmfStateSystemFactory.newFullHistory(stateFile, input, true); List fullState = ssq.queryFullState(targetTimestamp); diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/LttngKernelStateProviderTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/LttngKernelStateProviderTest.java index c8dcbab688..a5e48548c0 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/LttngKernelStateProviderTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/LttngKernelStateProviderTest.java @@ -17,7 +17,7 @@ import static org.junit.Assume.assumeTrue; import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.junit.BeforeClass; import org.junit.Test; @@ -28,7 +28,7 @@ import org.junit.Test; */ public class LttngKernelStateProviderTest { - private final static int TRACE_INDEX = 1; + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2; private static ITmfStateProvider input; @@ -37,8 +37,8 @@ public class LttngKernelStateProviderTest { */ @BeforeClass public static void initialize() { - assumeTrue(CtfTmfTestTraces.tracesExist()); - input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + input = new LttngKernelStateProvider(testTrace.getTrace()); } diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java index dda24333ae..4431d99bd1 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/PartialStateSystemTest.java @@ -20,7 +20,6 @@ import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKer import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; import org.junit.BeforeClass; import org.junit.Test; @@ -36,13 +35,13 @@ public class PartialStateSystemTest extends StateSystemTest { */ @BeforeClass public static void initialize() { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); File stateFile = null; try { stateFile = File.createTempFile("test-partial", ".ht"); stateFile.deleteOnExit(); - input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + input = new LttngKernelStateProvider(testTrace.getTrace()); ssq = TmfStateSystemFactory.newPartialHistory(stateFile, input, true); } catch (IOException e) { e.printStackTrace(); diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java index f50f733b90..1dfc4a9f1e 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java @@ -25,7 +25,6 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem; import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; import org.junit.BeforeClass; import org.junit.Test; @@ -45,12 +44,12 @@ public class StateSystemFullHistoryTest extends StateSystemTest { */ @BeforeClass public static void initialize() { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); try { stateFile = File.createTempFile("test", ".ht"); stateFileBenchmark = File.createTempFile("test", ".ht.benchmark"); - input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + input = new LttngKernelStateProvider(testTrace.getTrace()); ssq = TmfStateSystemFactory.newFullHistory(stateFile, input, true); } catch (IOException e) { e.printStackTrace(); @@ -73,7 +72,7 @@ public class StateSystemFullHistoryTest extends StateSystemTest { @Test public void testBuild() { try { - ITmfStateProvider input2 = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + ITmfStateProvider input2 = new LttngKernelStateProvider(testTrace.getTrace()); ITmfStateSystem ssb2 = TmfStateSystemFactory.newFullHistory(stateFileBenchmark, input2, true); assertEquals(startTime, ssb2.getStartTime()); diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java index f76c5c2015..b4bff2f31d 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemInMemoryTest.java @@ -16,7 +16,6 @@ import static org.junit.Assume.assumeTrue; import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider; import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; import org.junit.BeforeClass; /** @@ -31,8 +30,8 @@ public class StateSystemInMemoryTest extends StateSystemTest { */ @BeforeClass public static void initialize() { - assumeTrue(CtfTmfTestTraces.tracesExist()); - input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + input = new LttngKernelStateProvider(testTrace.getTrace()); ssq = TmfStateSystemFactory.newInMemHistory(input, true); } } diff --git a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemTest.java b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemTest.java index 487e4b7542..a55729bceb 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemTest.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemTest.java @@ -27,6 +27,7 @@ import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem; import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.junit.Test; /** @@ -38,8 +39,8 @@ import org.junit.Test; @SuppressWarnings("javadoc") public abstract class StateSystemTest { - /** Index of the test trace used for these tests */ - protected static final int TRACE_INDEX = 1; + /** Test trace used for these tests */ + protected static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2; /** Expected start time of the test trace/state history */ protected static final long startTime = 1331668247314038062L; diff --git a/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTrace.java b/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTrace.java new file mode 100644 index 0000000000..6bd8d2ac04 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTrace.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * + * Contributors: + * Alexandre Montplaisir - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.core.tests.shared; + +import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace; +import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; +import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; +import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; + +/** + * Available CTF TMF test traces. Kind-of-extends {@link CtfTestTrace}. + * + * To run tests using these, you first need to run the "get-traces.[xml|sh]" + * script located under lttng/org.eclipse.linuxtools.ctf.core.tests/traces/ . + * + * @author Alexandre Montplaisir + */ +public enum CtfTmfTestTrace { + /** Example kernel trace */ + KERNEL, + /** Another kernel trace */ + TRACE2, + /** Kernel trace with event contexts */ + KERNEL_VM; + + + private final String fPath; + private CtfTmfTrace fTrace = null; + + private CtfTmfTestTrace() { + /* This makes my head spin */ + fPath = CtfTestTrace.valueOf(this.name()).getPath(); + } + + /** + * @return The path of this trace + */ + public String getPath() { + return fPath; + } + + /** + * Return a CtfTmfTrace object of this test trace. It will be already + * initTrace()'ed. + * + * Make sure you call {@link #exists()} before calling this! + * + * @return A CtfTmfTrace reference to this trace + */ + public CtfTmfTrace getTrace() { + if (fTrace == null) { + CtfTmfTrace trace = new CtfTmfTrace(); + try { + trace.initTrace(null, fPath, CtfTmfEvent.class); + } catch (TmfTraceException e) { + /* Should not happen if tracesExist() passed */ + throw new RuntimeException(e); + } + fTrace = trace; + } + return fTrace; + } + + /** + * Check if the trace actually exists on disk or not. + * + * @return If the trace is present + */ + public boolean exists() { + return CtfTestTrace.valueOf(this.name()).exists(); + } +} diff --git a/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java b/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java deleted file mode 100644 index 9f4146d9f2..0000000000 --- a/org.eclipse.linuxtools.tmf.core.tests/shared/org/eclipse/linuxtools/tmf/core/tests/shared/CtfTmfTestTraces.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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 - * - * Contributors: - * Alexandre Montplaisir - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.core.tests.shared; - -import java.io.File; - -import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTraces; -import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; -import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; -import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; - -/** - * Definitions used by all tests using CTF-TMF trace files. - * - * To run these tests, you will first need to run the "get-traces.sh" script - * located under lttng/org.eclipse.linuxtools.ctf.core.tests/traces/ . - * - * @author Alexandre Montplaisir - */ -public final class CtfTmfTestTraces { - - private CtfTmfTestTraces() {} - - private static final File emptyFile = new File(""); - private static CtfTmfTrace emptyTrace = new CtfTmfTrace(); - - private static CtfTmfTrace[] testTraces = new CtfTmfTrace[3]; - - /** - * Get an empty File (new File("");) - * - * @return An empty file - */ - public static File getEmptyFile() { - return emptyFile; - } - - /** - * Get an empty CtfTmfTrace (new CtfTmfTrace();) - * - * @return An empty trace - */ - public static CtfTmfTrace getEmptyTrace() { - return emptyTrace; - } - - /** - * Get a reference to the test trace used for the kernel event handler unit - * tests. - * - * Make sure you call {@link #tracesExist()} before calling this! - * - * @param idx - * The index of the test trace you want - * @return A CtfTmfTrace reference to the test trace - */ - public synchronized static CtfTmfTrace getTestTrace(int idx) { - if (testTraces[idx] == null) { - String tracePath = CtfTestTraces.getTestTracePath(idx); - testTraces[idx] = new CtfTmfTrace(); - try { - testTraces[idx].initTrace(null, tracePath, CtfTmfEvent.class); - } catch (TmfTraceException e) { - /* Should not happen if tracesExist() passed */ - testTraces[idx] = null; - throw new RuntimeException(e); - } - } - return testTraces[idx]; - } - - // ------------------------------------------------------------------------ - // Wrappers around direct CtfTestTraces methods - // ------------------------------------------------------------------------ - - /** - * Get the (string) path to a given test trace. - * - * You should call {@link #tracesExist()} before calling this if you are - * going to use this trace for real. - * - * @param idx - * The index of the trace among all the available ones - * @return The path to the test trace - */ - public static String getTestTracePath(int idx) { - return CtfTestTraces.getTestTracePath(idx); - } - - /** - * Check if the test traces are present before trying to open them. - * - * This should be called in unit tests within a asssumeTrue() call, to skip - * the test/test-class if the traces are not available. - * - * @return True if the trace is available, false if not - */ - public static boolean tracesExist() { - return CtfTestTraces.tracesExist(); - } - -} diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java index f5a001c62c..10a9be250f 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfIteratorTest.java @@ -24,7 +24,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -38,7 +38,7 @@ import org.junit.Test; */ public class CtfIteratorTest { - private static final int TRACE_INDEX = 0; + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; private CtfIterator fixture; @@ -47,8 +47,8 @@ public class CtfIteratorTest { */ @Before public void setUp() { - assumeTrue(CtfTmfTestTraces.tracesExist()); - fixture = new CtfIterator(getTrace()); + assumeTrue(testTrace.exists()); + fixture = new CtfIterator(testTrace.getTrace()); CtfLocation ctfLocation = new CtfLocation(new CtfLocationInfo(1, 0)); fixture.setLocation(ctfLocation); fixture.increaseRank(); @@ -64,16 +64,12 @@ public class CtfIteratorTest { } } - private static CtfTmfTrace getTrace() { - return CtfTmfTestTraces.getTestTrace(TRACE_INDEX); - } - /** * Run the CtfIterator(CtfTmfTrace) constructor on a non init'ed trace. */ @Test public void testCtfIterator_noinit() { - CtfTmfTrace trace = getTrace(); + CtfTmfTrace trace = testTrace.getTrace(); CtfIterator result = new CtfIterator(trace); assertNotNull(result); } @@ -83,7 +79,7 @@ public class CtfIteratorTest { */ @Test public void testCtfIterator_init() { - CtfTmfTrace trace = getTrace(); + CtfTmfTrace trace = testTrace.getTrace(); trace.init("test"); CtfIterator result = new CtfIterator(trace); @@ -96,7 +92,7 @@ public class CtfIteratorTest { */ @Test public void testCtfIterator_position() { - CtfTmfTrace trace = getTrace(); + CtfTmfTrace trace = testTrace.getTrace(); long timestampValue = 1L; long rank = 1L; CtfIterator result = new CtfIterator(trace, new CtfLocationInfo(timestampValue, 0), rank); @@ -128,7 +124,7 @@ public class CtfIteratorTest { */ @Test public void testCompareTo() { - CtfIterator o = new CtfIterator(getTrace()); + CtfIterator o = new CtfIterator(testTrace.getTrace()); int result = fixture.compareTo(o); assertEquals(1L, result); @@ -140,7 +136,7 @@ public class CtfIteratorTest { */ @Test public void testEquals_other() { - CtfIterator obj = new CtfIterator(getTrace()); + CtfIterator obj = new CtfIterator(testTrace.getTrace()); CtfLocation ctfLocation1 = new CtfLocation(new CtfLocationInfo(1, 0)); obj.setLocation(ctfLocation1); obj.increaseRank(); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContextTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContextTest.java index 528405f8cb..ee2a807e06 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContextTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfContextTest.java @@ -24,7 +24,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfContext; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.junit.Before; import org.junit.Test; @@ -36,7 +36,7 @@ import org.junit.Test; */ public class CtfTmfContextTest { - private static final int TRACE_INDEX = 0; + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; private static final long begin = 1332170682440133097L; /* Trace start time */ private static final long end = 1332170692664579801L; /* Trace end time */ @@ -58,9 +58,9 @@ public class CtfTmfContextTest { */ @Before public void setUp() throws TmfTraceException { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); trace = new CtfTmfTrace(); - String path = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX); + String path = testTrace.getPath(); trace.initTrace((IResource) null, path, CtfTmfEvent.class); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java index 1b6cb64061..e1bd22b466 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java @@ -28,7 +28,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEventFactory; import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; import org.eclipse.linuxtools.tmf.core.event.ITmfEventType; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.trace.ITmfContext; import org.junit.Before; import org.junit.BeforeClass; @@ -43,7 +43,7 @@ import org.junit.Test; */ public class CtfTmfEventTest { - private static final int TRACE_INDEX = 0; + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; private static CtfTmfEvent nullEvent; private CtfTmfEvent fixture; @@ -61,8 +61,8 @@ public class CtfTmfEventTest { */ @Before public void setUp() { - assumeTrue(CtfTmfTestTraces.tracesExist()); - CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX); + assumeTrue(testTrace.exists()); + CtfTmfTrace trace = testTrace.getTrace(); CtfIterator tr = new CtfIterator(trace); tr.advance(); fixture = tr.getCurrentEvent(); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java index 913e465d56..fe6430a19d 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java @@ -32,7 +32,7 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignal; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; @@ -50,8 +50,7 @@ import org.junit.Test; */ public class CtfTmfTraceTest { - private static final int TRACE_INDEX = 0; - private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX); + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; private CtfTmfTrace fixture; @@ -63,9 +62,9 @@ public class CtfTmfTraceTest { */ @Before public void setUp() throws TmfTraceException { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); fixture = new CtfTmfTrace(); - fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class); + fixture.initTrace((IResource) null, testTrace.getPath(), CtfTmfEvent.class); } /** @@ -345,8 +344,7 @@ public class CtfTmfTraceTest { @Test public void testValidate() { IProject project = null; - String path = PATH; - IStatus result = fixture.validate(project, path); + IStatus result = fixture.validate(project, testTrace.getPath()); assertTrue(result.isOK()); } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/EventContextTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/EventContextTest.java index 6aeb2b0154..1691e86189 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/EventContextTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/EventContextTest.java @@ -22,7 +22,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; @@ -42,8 +42,7 @@ public class EventContextTest { // ------------------------------------------------------------------------ /* We use test trace #2, kernel_vm, which has event contexts */ - private static final int TRACE_INDEX = 2; - private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX); + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL_VM; private static CtfTmfTrace fixture; private static long startTime; @@ -61,9 +60,9 @@ public class EventContextTest { */ @BeforeClass public static void setUp() throws TmfTraceException { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); fixture = new CtfTmfTrace(); - fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class); + fixture.initTrace((IResource) null, testTrace.getPath(), CtfTmfEvent.class); fixture.indexTrace(true); startTime = fixture.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerBenchmark.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerBenchmark.java index bbbb1f4506..e7f1405a5b 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerBenchmark.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerBenchmark.java @@ -18,7 +18,7 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; /** @@ -38,13 +38,12 @@ public class TmfSchedulerBenchmark { private static final int NUM_LOOPS = 10; private static final int NANOSECONDS_IN_MILLISECONDS = 1000000; private static final int NANOSECONDS_IN_SECONDS = 1000000000; - private static final int TRACE_INDEX = 0; // ------------------------------------------------------------------------ // Attributes // ------------------------------------------------------------------------ - private static CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX); + private static CtfTmfTrace trace = CtfTmfTestTrace.KERNEL.getTrace(); private static ForegroundRequest lastForegroundRequest = null; private static BackgroundRequest lastBackgroundRequest = null; diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerTest.java index 8573765caa..291fca6de3 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerTest.java @@ -28,7 +28,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; @@ -45,8 +45,7 @@ public class TmfSchedulerTest { // Constants // ------------------------------------------------------------------------ - private static final int TRACE_INDEX = 0; - private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX); + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; private static final int NB_EVENTS_TRACE = 695319; private static final int NB_EVENTS_TIME_RANGE = 155133; @@ -72,9 +71,9 @@ public class TmfSchedulerTest { */ @Before public void setUp() throws TmfTraceException { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); fixture = new CtfTmfTrace(); - fixture.initTrace((IResource) null, PATH, CtfTmfEvent.class); + fixture.initTrace((IResource) null, testTrace.getPath(), CtfTmfEvent.class); fixture.indexTrace(true); fStartTime = fixture.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); fEndTime = fixture.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfEventsStatisticsTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfEventsStatisticsTest.java index 3ce8111bb6..e841a2a1fc 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfEventsStatisticsTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfEventsStatisticsTest.java @@ -15,7 +15,6 @@ package org.eclipse.linuxtools.tmf.core.tests.statistics; import static org.junit.Assume.assumeTrue; import org.eclipse.linuxtools.tmf.core.statistics.TmfEventsStatistics; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; import org.junit.BeforeClass; /** @@ -30,7 +29,7 @@ public class TmfEventsStatisticsTest extends TmfStatisticsTest { */ @BeforeClass public static void setUpClass() { - assumeTrue(CtfTmfTestTraces.tracesExist()); - backend = new TmfEventsStatistics(CtfTmfTestTraces.getTestTrace(TRACE_INDEX)); + assumeTrue(testTrace.exists()); + backend = new TmfEventsStatistics(testTrace.getTrace()); } } diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStateStatisticsTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStateStatisticsTest.java index a409d46afc..0f4a166fa7 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStateStatisticsTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStateStatisticsTest.java @@ -17,10 +17,8 @@ import static org.junit.Assume.assumeTrue; import java.io.File; import java.io.IOException; -import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException; import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; import org.junit.BeforeClass; /** @@ -35,12 +33,11 @@ public class TmfStateStatisticsTest extends TmfStatisticsTest { */ @BeforeClass public static void setUpClass() { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(testTrace.exists()); try { File htFile = File.createTempFile("stats-test", ".ht"); htFile.deleteOnExit(); - CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX); - backend = new TmfStateStatistics(trace, htFile); + backend = new TmfStateStatistics(testTrace.getTrace(), htFile); } catch (TmfTraceException e) { e.printStackTrace(); } catch (IOException e) { diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStatisticsTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStatisticsTest.java index efcee736d0..138da80d72 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStatisticsTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/statistics/TmfStatisticsTest.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.junit.Test; /** @@ -28,8 +29,8 @@ import org.junit.Test; */ public abstract class TmfStatisticsTest { - /** The index of the test trace used for these tests */ - protected static final int TRACE_INDEX = 0; + /** Test trace used for these tests */ + protected static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; /** The statistics back-end object */ protected static ITmfStatistics backend; diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceManagerTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceManagerTest.java index 2b9b1e289a..720486a2fa 100644 --- a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceManagerTest.java +++ b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceManagerTest.java @@ -28,7 +28,7 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; @@ -67,9 +67,10 @@ public class TmfTraceManagerTest { */ @BeforeClass public static void setUpClass() { - assumeTrue(CtfTmfTestTraces.tracesExist()); - trace1 = CtfTmfTestTraces.getTestTrace(1); - trace2 = CtfTmfTestTraces.getTestTrace(0); + assumeTrue(CtfTmfTestTrace.TRACE2.exists()); + assumeTrue(CtfTmfTestTrace.KERNEL.exists()); + trace1 = CtfTmfTestTrace.TRACE2.getTrace(); + trace2 = CtfTmfTestTrace.KERNEL.getTrace(); trace1.indexTrace(true); trace2.indexTrace(true); diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java index 2aa4c76950..8eec93b643 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTestData.java @@ -23,7 +23,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfImportHelper; import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement; import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement; import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement; @@ -40,8 +40,7 @@ public class ProjectModelTestData { /** Default test project name */ public static final String PROJECT_NAME = "Test_Project"; - private static final int TRACE_INDEX = 0; - private static final String PATH = CtfTmfTestTraces.getTestTracePath(TRACE_INDEX); + private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL; /** * Gets a project element with traces all initialized @@ -56,7 +55,7 @@ public class ProjectModelTestData { IFolder traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME); /* Create a trace, if it exist, it will be replaced */ - File file = new File(PATH); + File file = new File(testTrace.getPath()); String path = file.getAbsolutePath(); final IPath pathString = Path.fromOSString(path); IResource linkedTrace = TmfImportHelper.createLink(traceFolder, pathString, pathString.lastSegment()); @@ -79,7 +78,7 @@ public class ProjectModelTestData { * @return The trace name */ public static String getTraceName() { - File file = new File(PATH); + File file = new File(testTrace.getPath()); String path = file.getAbsolutePath(); final IPath pathString = Path.fromOSString(path); return pathString.lastSegment(); diff --git a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTraceTest.java b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTraceTest.java index 0d45af30b3..ba3260d7d6 100644 --- a/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTraceTest.java +++ b/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/project/model/ProjectModelTraceTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; import org.eclipse.core.runtime.CoreException; -import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces; +import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager; import org.eclipse.linuxtools.tmf.ui.project.model.TmfOpenTraceHelper; @@ -41,7 +41,7 @@ public class ProjectModelTraceTest { */ @Before public void setUp() { - assumeTrue(CtfTmfTestTraces.tracesExist()); + assumeTrue(CtfTmfTestTrace.KERNEL.exists()); try { fixture = ProjectModelTestData.getFilledProject(); } catch (CoreException e) { -- 2.34.1