--- /dev/null
+/*******************************************************************************
+ * 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"),
+ /** Trace synchronization: source trace */
+ SYNC_SRC("../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_src"),
+ /** Trace synchronization: destination trace */
+ SYNC_DEST("../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_dest");
+
+
+ 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;
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * 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",
- "../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_src",
- "../org.eclipse.linuxtools.ctf.core.tests/traces/synctraces/scp_dest"
- };
-
- 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;
- }
-}
import java.util.TreeSet;
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;
*/
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",
@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) {
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;
@SuppressWarnings("javadoc")
public class CTFTraceReaderTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private CTFTraceReader fixture;
*/
@Before
public void setUp() throws CTFReaderException {
- assumeTrue(CtfTestTraces.tracesExist());
- fixture = new CTFTraceReader(CtfTestTraces.getTestTrace(TRACE_INDEX));
+ assumeTrue(testTrace.exists());
+ fixture = new CTFTraceReader(testTrace.getTrace());
}
/**
*/
@Test
public void testOpen_existing() throws CTFReaderException {
- CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX);
+ CTFTrace trace = testTrace.getTrace();
CTFTraceReader result = new CTFTraceReader(trace);
assertNotNull(result);
*/
@Test
public void testEquals() throws CTFReaderException {
- CTFTraceReader fixture2 = new CTFTraceReader(CtfTestTraces.getTestTrace(TRACE_INDEX));
+ CTFTraceReader fixture2 = new CTFTraceReader(testTrace.getTrace());
assertEquals(fixture, fixture2);
}
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;
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;
*/
@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));
*/
@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();
+ }
}
/**
// 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) {
*/
@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();
+ }
}
/**
/**
* Test for getCallsite(eventName, ip)
+ * @throws CTFReaderException not expected
*/
@Test
- public void callsitePosition(){
+ public void callsitePosition() throws CTFReaderException{
long ip1 = 2;
long ip2 = 5;
long ip3 = 7;
- CTFTrace callsiteTest = CtfTestTraces.getTestTraceFromFile(TRACE_INDEX);
+ CTFTrace callsiteTest = testTrace.getTraceFromFile();
callsiteTest.addCallsite("testEvent", null, ip1, null, 23);
callsiteTest.addCallsite("testEvent", null, ip2, null, 50);
callsiteTest.addCallsite("testEvent", null, ip3, null, 15);
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;
@SuppressWarnings("javadoc")
public class MetadataTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private Metadata fixture;
*/
@Before
public void setUp() throws CTFReaderException {
- assumeTrue(CtfTestTraces.tracesExist());
- fixture = new Metadata(CtfTestTraces.getTestTrace(TRACE_INDEX));
+ assumeTrue(testTrace.exists());
+ fixture = new Metadata(testTrace.getTrace());
}
/**
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;
@SuppressWarnings("javadoc")
public class StreamInputReaderTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private StreamInputReader fixture;
}
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> streamInput = s.getStreamInputs();
StreamInputReader retVal = null;
@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);
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;
@SuppressWarnings("javadoc")
public class StreamInputTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private StreamInput fixture;
*/
@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);
}
@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);
}
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;
@SuppressWarnings("javadoc")
public class StreamTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private Stream fixture;
*/
@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("")));
}
/**
*/
@Test
public void testStream() throws CTFReaderException {
- CTFTrace trace = CtfTestTraces.getTestTrace(TRACE_INDEX);
+ CTFTrace trace = testTrace.getTrace();
Stream result = new Stream(trace);
assertNotNull(result);
}
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;
@SuppressWarnings("javadoc")
public class EventDeclarationTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private EventDeclaration fixture;
*/
@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("");
}
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));
*/
@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);
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;
*/
public class VariantDeclarationTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
private VariantDeclaration fixture;
}
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 = "";
import org.eclipse.linuxtools.tmf.core.synchronization.ITmfTimestampTransform;
import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
import org.eclipse.linuxtools.tmf.core.synchronization.TmfTimestampTransform;
-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.TmfExperiment;
import org.junit.After;
*/
@Before
public void setUp() {
- CtfTmfTrace trace1 = CtfTmfTestTraces.getTestTrace(3);
- CtfTmfTrace trace2 = CtfTmfTestTraces.getTestTrace(4);
+ CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
+ CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();
fTraces = new CtfTmfTrace[2];
fTraces[0] = trace1;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching;
import org.eclipse.linuxtools.tmf.core.event.matching.TmfNetworkEventMatching;
-import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
+import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
import org.junit.Test;
/**
@Test
public void testMatching() {
final String cr = System.getProperty("line.separator");
- CtfTmfTrace trace1 = CtfTmfTestTraces.getTestTrace(3);
- CtfTmfTrace trace2 = CtfTmfTestTraces.getTestTrace(4);
+ CtfTmfTrace trace1 = CtfTmfTestTrace.SYNC_SRC.getTrace();
+ CtfTmfTrace trace2 = CtfTmfTestTrace.SYNC_DEST.getTrace();
CtfTmfTrace[] tracearr = new CtfTmfTrace[2];
tracearr[0] = trace1;
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.
/* 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);
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
*/
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 = " ";
* 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;
}
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<ITmfStateInterval> fullState = ssq.queryFullState(targetTimestamp);
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;
*/
public class LttngKernelStateProviderTest {
- private final static int TRACE_INDEX = 1;
+ private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.TRACE2;
private static ITmfStateProvider input;
*/
@BeforeClass
public static void initialize() {
- assumeTrue(CtfTmfTestTraces.tracesExist());
- input = new LttngKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ assumeTrue(testTrace.exists());
+ input = new LttngKernelStateProvider(testTrace.getTrace());
}
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;
*/
@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();
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;
*/
@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();
@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());
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;
/**
*/
@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);
}
}
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;
/**
@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;
--- /dev/null
+/*******************************************************************************
+ * 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,
+ /** Trace synchronization: source trace */
+ SYNC_SRC,
+ /** Trace synchronization: destination trace */
+ SYNC_DEST;
+
+
+ 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();
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * 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[5];
-
- /**
- * 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();
- }
-
-}
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;
*/
public class CtfIteratorTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
private CtfIterator fixture;
*/
@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();
}
}
- 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);
}
*/
@Test
public void testCtfIterator_init() {
- CtfTmfTrace trace = getTrace();
+ CtfTmfTrace trace = testTrace.getTrace();
trace.init("test");
CtfIterator result = new CtfIterator(trace);
*/
@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);
*/
@Test
public void testCompareTo() {
- CtfIterator o = new CtfIterator(getTrace());
+ CtfIterator o = new CtfIterator(testTrace.getTrace());
int result = fixture.compareTo(o);
assertEquals(1L, result);
*/
@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();
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;
*/
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 */
*/
@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);
}
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;
*/
public class CtfTmfEventTest {
- private static final int TRACE_INDEX = 0;
+ private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.KERNEL;
private static CtfTmfEvent nullEvent;
private CtfTmfEvent fixture;
*/
@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();
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;
*/
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;
*/
@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);
}
/**
@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());
}
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;
// ------------------------------------------------------------------------
/* 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;
*/
@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();
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;
/**
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;
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;
// 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;
*/
@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();
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;
/**
*/
@BeforeClass
public static void setUpClass() {
- assumeTrue(CtfTmfTestTraces.tracesExist());
- backend = new TmfEventsStatistics(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
+ assumeTrue(testTrace.exists());
+ backend = new TmfEventsStatistics(testTrace.getTrace());
}
}
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;
/**
*/
@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) {
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;
/**
*/
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;
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;
*/
@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);
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;
/** 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
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());
* @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();
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;
*/
@Before
public void setUp() {
- assumeTrue(CtfTmfTestTraces.tracesExist());
+ assumeTrue(CtfTmfTestTrace.KERNEL.exists());
try {
fixture = ProjectModelTestData.getFilledProject();
} catch (CoreException e) {