@RunWith(Suite.class)
@Suite.SuiteClasses({
CtfCorePluginTest.class,
- /* All the tests below depend on the CTF tests traces */
-// org.eclipse.linuxtools.ctf.core.tests.event.TestAll.class,
-// org.eclipse.linuxtools.ctf.core.tests.io.TestAll.class,
-// org.eclipse.linuxtools.ctf.core.tests.trace.TestAll.class,
-// org.eclipse.linuxtools.ctf.core.tests.types.TestAll.class
+ org.eclipse.linuxtools.ctf.core.tests.event.TestAll.class,
+ org.eclipse.linuxtools.ctf.core.tests.io.TestAll.class,
+ org.eclipse.linuxtools.ctf.core.tests.trace.TestAll.class,
+ org.eclipse.linuxtools.ctf.core.tests.types.TestAll.class
})
public class AllCtfCoreTests {
* Here are the definitions common to all the CTF parser tests.
*
* @author alexmont
- *
*/
-@SuppressWarnings("javadoc")
+@SuppressWarnings("nls")
public abstract class TestParams {
/*
* Path to test traces. Make sure you run the traces/get-traces.sh script
* first!
*/
- private static final String testTracePath1 = "traces/kernel"; //$NON-NLS-1$
+ private static final String testTracePath1 = "traces/kernel";
private static CTFTrace testTrace1 = null;
private static CTFTrace testTraceFromFile1 = null;
- private static final File testTraceFile1 = new File(testTracePath1+"/channel0_0"); //$NON-NLS-1$
+ private static final File testTraceFile1 = new File(testTracePath1 + "/channel0_0");
- private static final File emptyFile = new File(""); //$NON-NLS-1$
+ 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(""); //$NON-NLS-1$
+ emptyTrace = new CTFTrace("");
} catch (CTFReaderException e) {
- /* We know this trace should exist */
+ /* Should always work... */
throw new RuntimeException(e);
}
}
return emptyTrace;
}
+ /**
+ * Get a CTFTrace reference to test trace #1.
+ *
+ * Make sure {@link #tracesExist()} before calling this!
+ *
+ * @return Reference to test trace #1
+ * @throws CTFReaderException
+ * If the trace cannot be found
+ */
public static CTFTrace createTrace() throws CTFReaderException {
if (testTrace1 == null) {
testTrace1 = new CTFTrace(testTracePath1);
return testTrace1;
}
+ /**
+ * Same as {@link #createTrace()}, except the CTFTrace is create from the
+ * File object and not the path.
+ *
+ * Make sure {@link #tracesExist()} before calling this!
+ *
+ * @return Reference to test trace #1
+ */
public static CTFTrace createTraceFromFile() {
if (testTraceFromFile1 == null) {
try {
testTraceFromFile1 = new CTFTrace(new File(testTracePath1));
} catch (CTFReaderException e) {
- /* We know this trace should exist */
+ /* This trace should exist */
throw new RuntimeException(e);
}
}
return testTraceFromFile1;
}
+
+ /**
+ * 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() {
+ if (testTrace1 != null) {
+ return true;
+ }
+ try {
+ createTrace();
+ } catch (CTFReaderException e) {
+ return false;
+ }
+ return true;
+ }
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.util.List;
import java.util.Random;
@Before
public void setup() throws CTFReaderException, SecurityException,
IllegalArgumentException {
+ assumeTrue(TestParams.tracesExist());
fTrace = new CTFTrace(TestParams.getTraceFile().getParentFile());
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
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.TestParams;
*/
@Before
public void setUp() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
fixture = new CTFTraceReader(TestParams.createTrace());
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.nio.ByteOrder;
*/
@Before
public void setUp() {
+ assumeTrue(TestParams.tracesExist());
fixture = TestParams.createTraceFromFile();
fixture.setMinor(1L);
fixture.setUUID(UUID.randomUUID());
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assume.assumeTrue;
import java.nio.ByteOrder;
*/
@Before
public void setUp() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
fixture = new Metadata(TestParams.createTrace());
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.nio.channels.FileChannel;
import java.util.Set;
}
private static StreamInputReader getStreamInputReader() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
CTFTrace trace = TestParams.createTrace();
Stream s = trace.getStream((long) 0);
Set<StreamInput> streamInput = s.getStreamInputs();
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.io.IOException;
*/
@Before
public void setUp() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
fixture = new StreamInput(new Stream(TestParams.createTrace()),
(FileChannel) null, createFile());
fixture.setTimestampEnd(1L);
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
import java.nio.channels.FileChannel;
import java.util.HashMap;
*/
@Before
public void setUp() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
fixture = new Stream(TestParams.createTrace());
fixture.setEventContext(new StructDeclaration(1L));
fixture.setPacketContext(new StructDeclaration(1L));
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
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.event.types.StructDeclaration;
*/
@Before
public void setUp() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
fixture = new EventDeclaration();
fixture.setContext(new StructDeclaration(1L));
fixture.setId(1L);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeTrue;
import org.eclipse.linuxtools.ctf.core.event.types.IDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
}
private static IDefinitionScope createDefinitionScope() throws CTFReaderException {
+ assumeTrue(TestParams.tracesExist());
VariantDeclaration declaration = new VariantDeclaration();
declaration.setTag(""); //$NON-NLS-1$
VariantDeclaration variantDeclaration = new VariantDeclaration();