From 5fbe0b849c84be2b1e6b051108e9f7d3b3daa220 Mon Sep 17 00:00:00 2001 From: Francois Chouinard Date: Fri, 15 Jan 2010 16:54:40 +0000 Subject: [PATCH] [156247] Preparation work for LTTng/TMF automated testing in Linux Tools build system. --- .../build.properties | 5 +- .../lttng/tests/event/AllLttngTests.java | 5 +- .../tests/event/LttngEventContentTest.java | 164 +++--------------- .../tests/event/LttngEventFieldTest.java | 40 ++--- .../tests/event/LttngEventReferenceTest.java | 83 ++------- .../lttng/tests/event/LttngEventTest.java | 37 +--- .../lttng/tests/event/LttngEventTypeTest.java | 64 +++---- .../lttng/tests/event/LttngTimestampTest.java | 67 ++----- .../lttng/tests/jni/JniEventTest.java | 29 ++-- .../lttng/tests/jni/JniMarkerFieldTest.java | 2 +- .../lttng/tests/jni/JniMarkerTest.java | 2 +- .../lttng/tests/jni/JniTraceTest.java | 23 ++- .../lttng/tests/jni/JniTracefileTest.java | 16 +- .../lttng/tests/trace/LTTngTextTraceTest.java | 71 +++----- 14 files changed, 160 insertions(+), 448 deletions(-) diff --git a/org.eclipse.linuxtools.lttng.tests/build.properties b/org.eclipse.linuxtools.lttng.tests/build.properties index aa1a008269..341bdbfa2e 100644 --- a/org.eclipse.linuxtools.lttng.tests/build.properties +++ b/org.eclipse.linuxtools.lttng.tests/build.properties @@ -2,4 +2,7 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.properties + plugin.properties,\ + test2.xml,\ + traceset/,\ + test.xml diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/AllLttngTests.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/AllLttngTests.java index a14db9a859..23f90e78f1 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/AllLttngTests.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/AllLttngTests.java @@ -2,11 +2,12 @@ package org.eclipse.linuxtools.lttng.tests.event; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.linuxtools.lttng.tests.trace.LTTngTextTraceTest;; + +import org.eclipse.linuxtools.lttng.tests.trace.LTTngTextTraceTest; public final class AllLttngTests extends TestCase { public static TestSuite suite() { - TestSuite suite = new TestSuite("Testing LTTng (trace in text format)"); + TestSuite suite = new TestSuite("Testing JNI"); suite.addTestSuite(LTTngTextTraceTest.class); suite.addTestSuite(LttngTimestampTest.class); diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventContentTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventContentTest.java index 1c4da03553..66b85d49fa 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventContentTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventContentTest.java @@ -1,38 +1,23 @@ package org.eclipse.linuxtools.lttng.tests.event; -import java.io.File; -import java.net.URL; -import java.util.HashMap; - import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.linuxtools.lttng.event.*; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; + +import org.eclipse.linuxtools.lttng.event.LttngEvent; +import org.eclipse.linuxtools.lttng.event.LttngEventContent; +import org.eclipse.linuxtools.lttng.event.LttngEventField; +import org.eclipse.linuxtools.lttng.event.LttngTimestamp; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; /* Functions tested here : - - public LttngEventContent() - public LttngEventContent(LttngEvent thisParent) - public LttngEventContent(LttngEvent thisParent, HashMap thisContent) + public LttngEventContent(LttngEventFormat thisFormat) + public LttngEventContent(LttngEventFormat thisFormat, String thisParsedContent, LttngEventField[] thisFields) public LttngEventContent(LttngEventContent oldContent) - - public void emptyContent() - - public LttngEventField[] getFields() - public LttngEventField getField(int position) - public LttngEventField getField(String name) - public LttngEvent getEvent() - public LttngEventType getType() - public Object[] getContent() - public HashMap getRawContent() - - public void setType(LttngEventType newType) - public void setEvent(LttngEvent newParent) - + public TmfEventField[] getFields() + public LttngEventField getField(int id) + public TmfEventField[] getFields(LttngEvent thisEvent) + public LttngEventField getField(int id, LttngEvent thisEvent) public String toString() */ @@ -41,35 +26,20 @@ public class LttngEventContentTest extends TestCase { private final static boolean skipIndexing=true; private final static String firstEventContentFirstField = "alignment:0"; - private final static String firstEventContentFirstFieldName = "alignment"; - private final static String firstEventContentType = "metadata/0/core_marker_id"; - private final static String secondEventContentSecondField = "string:LTT state dump begin"; - private final static String secondEventContentSecondFieldName = "string"; - private final static String secondEventContentType = "kernel/0/vprintk"; private final static long timestampAfterMetadata = 13589760262237L; - private static LTTngTextTrace testStream = null; - private LTTngTextTrace initializeEventStream() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath()); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } + LTTngTextTrace tmpStream = null; + try { + tmpStream = new LTTngTextTrace(tracepath1, skipIndexing); + } + catch (Exception e) { + fail("ERROR : Could not open " + tracepath1 + ". Test failed!" ); } - else { - testStream.seekEvent(0); - } - - return testStream; + + return tmpStream; } @@ -78,7 +48,6 @@ public class LttngEventContentTest extends TestCase { // This trace should be valid try { - testStream = null; LTTngTextTrace tmpStream = initializeEventStream(); tmpEventContent = (LttngEventContent)tmpStream.getNextEvent( new TmfTraceContext(0L, new LttngTimestamp(0L), 0) ).getContent(); } @@ -104,7 +73,7 @@ public class LttngEventContentTest extends TestCase { fail("Construction with format failed!"); } - // Construction with good parameters (parent event) + // Construction with good parameters try { testContent = new LttngEventContent(testEvent); } @@ -112,16 +81,6 @@ public class LttngEventContentTest extends TestCase { fail("Construction with format, content and fields failed!"); } - // Construction with good parameters (parent event and pre-parsed content) - try { - HashMap parsedContent = new HashMap(); - testContent = new LttngEventContent(testEvent, parsedContent); - } - catch( Exception e) { - fail("Construction with format, content and fields failed!"); - } - - // Copy constructor with correct parameters try { testContent = new LttngEventContent(testEvent); @@ -135,7 +94,7 @@ public class LttngEventContentTest extends TestCase { public void testGetter() { - LttngEventContent testContent = null; + LttngEventContent testContent = null; LTTngTextTrace tmpStream = null; LttngEvent tmpEvent = null; TmfTraceContext tmpContext = null; @@ -144,29 +103,16 @@ public class LttngEventContentTest extends TestCase { tmpStream = initializeEventStream(); tmpContext = new TmfTraceContext(0L, new LttngTimestamp(0L), 0); tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); + testContent = prepareToTest(); // getFieldS() assertNotSame("getFields() returned null!",null,testContent.getFields() ); - - // *** FIXME *** - // Depending from the Java version because of the "hashcode()" on String. - // We can't really test that safetly - // // getField(int) - //assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString()); - assertNotSame("getField(int) returned unexpected result!",null, testContent.getField(0).toString()); + assertEquals("getField(int) returned unexpected result!",firstEventContentFirstField, testContent.getField(0).toString()); - // getField(name) - assertEquals("getField(name) returned unexpected result!",firstEventContentFirstField, testContent.getField(firstEventContentFirstFieldName).toString()); - // getRawContent - assertNotSame("getRawContent() returned null!",null, testContent.getRawContent()); - // Test that get event return the correct event - assertTrue("getEvent() returned unexpected result!", tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue()); - // getType() - assertEquals("getType() returned unexpected result!",firstEventContentType, testContent.getType().toString()); - //*** To test getFields with a fields number >0, we need to move to an event that have some more + //*** To test getFiels with a fields number >0, we need to move to an event that have some more tmpStream = initializeEventStream(); tmpContext = new TmfTraceContext(0L, new LttngTimestamp(0L), 0); // Skip first events and seek to event pass metadata @@ -179,74 +125,12 @@ public class LttngEventContentTest extends TestCase { // Get the content testContent = tmpEvent.getContent(); - // Test that get event return the correct event - assertTrue("getEvent() returned unexpected result!",tmpEvent.getTimestamp().getValue() == testContent.getEvent().getTimestamp().getValue()); - // getType() - assertEquals("getType() returned unexpected result!",secondEventContentType, testContent.getType().toString()); - - // getFieldS() assertNotSame("getFields() returned null!",null,testContent.getFields() ); // getField(int) assertEquals("getField(int) returned unexpected result!",secondEventContentSecondField, testContent.getField(1).toString()); - // getField(name) - assertEquals("getField(name) returned unexpected result!",secondEventContentSecondField, testContent.getField(secondEventContentSecondFieldName).toString()); - // getRawContent - assertNotSame("getRawContent() returned null!",null, testContent.getRawContent()); } - - public void testSetter() { - // Not much to test here, we will just make sure the set does not fail for any reason. - // It's pointless to test with a getter... - LTTngTextTrace tmpStream = null; - LttngEvent tmpEvent = null; - TmfTraceContext tmpContext = null; - - // Require an event - tmpStream = initializeEventStream(); - tmpContext = new TmfTraceContext(0L, new LttngTimestamp(0L), 0); - tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); - - LttngEventContent tmpContent = prepareToTest(); - try { - tmpContent.setEvent(tmpEvent); - } - catch( Exception e) { - fail("setEvent(event) failed!"); - } - - - LttngEventType testType = new LttngEventType(); - try { - tmpContent.setType(testType); - } - catch( Exception e) { - fail("setType(type) failed!"); - } - } - - public void testEmptyContent() { - LttngEventContent testContent = null; - LTTngTextTrace tmpStream = null; - LttngEvent tmpEvent = null; - TmfTraceContext tmpContext = null; - - // Require an event - tmpStream = initializeEventStream(); - tmpContext = new TmfTraceContext(0L, new LttngTimestamp(0L), 0); - tmpEvent = (LttngEvent)tmpStream.getNextEvent(tmpContext); - // Get the content - testContent = tmpEvent.getContent(); - // Get all the fields to make sure there is something in the HashMap - testContent.getFields(); - // Just making sure there is something in the HashMap - assertNotSame("HashMap is empty but should not!", 0, testContent.getRawContent().size() ); - - // This is the actual test - testContent.emptyContent(); - assertSame("HashMap is not empty but should be!", 0, testContent.getRawContent().size() ); - } public void testToString() { LttngEventContent tmpContent = prepareToTest(); diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventFieldTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventFieldTest.java index 5094955a79..beaf7bf97d 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventFieldTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventFieldTest.java @@ -2,17 +2,11 @@ package org.eclipse.linuxtools.lttng.tests.event; -import java.io.File; -import java.net.URL; - import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.lttng.event.LttngEventContent; import org.eclipse.linuxtools.lttng.event.LttngEventField; import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; @@ -32,26 +26,18 @@ public class LttngEventFieldTest extends TestCase { private final static String firstEventName = "alignment"; private final static String firstEventValue = "0"; - private static LTTngTextTrace testStream = null; private LTTngTextTrace initializeEventStream() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath(), skipIndexing); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } - } - else { - testStream.seekEvent(0); + LTTngTextTrace tmpStream = null; + try { + tmpStream = new LTTngTextTrace(tracepath1, skipIndexing); + } + catch (Exception e) { + fail("ERROR : Could not open " + tracepath1 + ". Test failed!" ); } - return testStream; - } + return tmpStream; + } + private LttngEventField prepareToTest() { LttngEventField tmpField = null; @@ -101,13 +87,7 @@ public class LttngEventFieldTest extends TestCase { LttngEventField testField = (LttngEventField)tmpStream.getNextEvent( new TmfTraceContext(0, new LttngTimestamp(0L), 0) ).getContent().getField(0); assertNotSame("getField is null!",null,testField); - // *** FIXME *** - // Depending from the Java version because of the "hashcode()" on String. - // We can't really test that safetly - // - //assertTrue("getName() returned unexpected result!",firstEventName.equals(testField.getId().toString())); - assertNotSame("getName() returned unexpected result!",null, testField.getId()); - + assertTrue("getName() returned unexpected result!",firstEventName.equals(testField.getId().toString())); assertTrue("getValue() returned unexpected result!",firstEventValue.equals(testField.getValue().toString())); diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventReferenceTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventReferenceTest.java index 303f970138..e0f4dd07ab 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventReferenceTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventReferenceTest.java @@ -1,29 +1,18 @@ package org.eclipse.linuxtools.lttng.tests.event; -import java.io.File; -import java.net.URL; - import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; + import org.eclipse.linuxtools.lttng.event.LttngEventReference; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; /* Functions tested here : - public LttngEventReference(String newTraceName) - public LttngEventReference(String newTracefilePath, String newTraceName) - public LttngEventReference(LttngEventReference oldReference) - - public String getTracepath() - public String getValue() - - public void setTracepath(String tracename) - public void setValue(String newReference) - - public String toString() + public LttngEventReference(String newTracefilePath, String newTracePath) + public LttngEventReference(LttngEventReference oldReference) + public String getTracepath() + public void setTracepath(String tracepath) + public String toString() */ public class LttngEventReferenceTest extends TestCase { @@ -32,26 +21,19 @@ public class LttngEventReferenceTest extends TestCase { private final static String firstEventReference = "metadata_0"; - private static LTTngTextTrace testStream = null; + private LTTngTextTrace initializeEventStream() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath(), skipIndexing); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } - } - else { - testStream.seekEvent(0); - } - - return testStream; - } + LTTngTextTrace tmpStream = null; + try { + tmpStream = new LTTngTextTrace(tracepath1, skipIndexing); + } + catch (Exception e) { + fail("ERROR : Could not open " + tracepath1 + ". Test failed!" ); + } + + return tmpStream; + } + private LttngEventReference prepareToTest() { LttngEventReference tmpEventRef = null; @@ -73,15 +55,7 @@ public class LttngEventReferenceTest extends TestCase { @SuppressWarnings("unused") LttngEventReference testRef2 = null; - // Default construction with good argument (newTracefilePath) - try { - testRef = new LttngEventReference("test"); - } - catch( Exception e) { - fail("Construction failed!"); - } - - // Default construction with good arguments (newTracefilePath, newTraceName) + // Default construction with good argument try { testRef = new LttngEventReference("test", "test"); } @@ -107,25 +81,6 @@ public class LttngEventReferenceTest extends TestCase { assertEquals("Content not what expected!",firstEventReference,tmpRef.getTracepath()); } - public void testSetter() { - // Not much to do here, we will just make sure the setter does not throw - LttngEventReference tmpRef = prepareToTest(); - - try { - tmpRef.setTracepath("test"); - } - catch( Exception e) { - fail("setTracepath(string) failed!"); - } - - try { - tmpRef.setValue("test"); - } - catch( Exception e) { - fail("setTracepath(string) failed!"); - } - } - public void testToString() { LttngEventReference tmpRef = prepareToTest(); diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTest.java index 71c668b317..441c317487 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTest.java @@ -1,19 +1,13 @@ package org.eclipse.linuxtools.lttng.tests.event; -import java.io.File; -import java.net.URL; - import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; import org.eclipse.linuxtools.lttng.event.LttngEvent; import org.eclipse.linuxtools.lttng.event.LttngEventContent; import org.eclipse.linuxtools.lttng.event.LttngEventReference; import org.eclipse.linuxtools.lttng.event.LttngEventType; import org.eclipse.linuxtools.lttng.event.LttngTimestamp; import org.eclipse.linuxtools.lttng.jni.JniEvent; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; import org.eclipse.linuxtools.tmf.event.TmfEventSource; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; @@ -52,32 +46,11 @@ public class LttngEventTest extends TestCase { private final static String eventReference = eventChannel + "_" + eventCpu; - private static LTTngTextTrace testStream = null; - private LTTngTextTrace initializeEventStream() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath(), skipIndexing); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } - } - else { - testStream.seekEvent(0); - } - - return testStream; - } - private LttngEvent prepareToTest() { LttngEvent tmpEvent = null; try { - LTTngTextTrace tmpStream = initializeEventStream(); + LTTngTextTrace tmpStream = new LTTngTextTrace(tracepath1, skipIndexing); tmpEvent = (LttngEvent)tmpStream.getNextEvent(new TmfTraceContext(0, new LttngTimestamp(0L), 0) ); } catch (Exception e) { @@ -156,13 +129,7 @@ public class LttngEventTest extends TestCase { assertEquals("Channel not what expected!",eventChannel,testEvent.getChannelName()); assertEquals("CpuId not what expected!",eventCpu,testEvent.getCpuId()); assertEquals("Marker not what expected!",eventMarker,testEvent.getMarkerName()); - - // *** FIXME *** - // Depending from the Java version because of the "hashcode()" on String. - // We can't really test that safetly - // - //assertEquals("Content not what expected!",eventContent,testEvent.getContent().toString()); - assertNotSame("Content is null!", null,testEvent.getContent()); + assertEquals("Content not what expected!",eventContent,testEvent.getContent().toString()); } public void testSetter() { diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTypeTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTypeTest.java index b1ed838d91..5f58981d3c 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTypeTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngEventTypeTest.java @@ -1,27 +1,19 @@ package org.eclipse.linuxtools.lttng.tests.event; -import java.io.File; -import java.net.URL; - import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; + import org.eclipse.linuxtools.lttng.event.LttngEventType; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; /* Functions tested here : - public LttngEventType() - public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, String[] thisMarkerfieldsName) - public LttngEventType(LttngEventType oldType) - - public String getTracefileName() - public Long getCpuId() - public String getMarkerName() - - public String toString() + public LttngEventType(String thisChannelName, long thisCpuId, String thisMarkerName, LttngEventFormat thisFormat) + public LttngEventType(LttngEventType oldType) + public String getChannelName() + public long getCpuId() + public String getMarkerName() + public String toString() */ public class LttngEventTypeTest extends TestCase { @@ -32,26 +24,18 @@ public class LttngEventTypeTest extends TestCase { private final static long firstEventCpu = 0; private final static String firstEventMarker = "core_marker_id"; - private static LTTngTextTrace testStream = null; private LTTngTextTrace initializeEventStream() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath(), skipIndexing); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } - } - else { - testStream.seekEvent(0); - } - - return testStream; - } + LTTngTextTrace tmpStream = null; + try { + tmpStream = new LTTngTextTrace(tracepath1, skipIndexing); + } + catch (Exception e) { + fail("ERROR : Could not open " + tracepath1 + ". Test failed!" ); + } + + return tmpStream; + } + private LttngEventType prepareToTest() { LttngEventType tmpEventType = null; @@ -73,15 +57,7 @@ public class LttngEventTypeTest extends TestCase { @SuppressWarnings("unused") LttngEventType tmpEventType2 = null; - // Default construction, no argument - try { - tmpEventType = new LttngEventType(); - } - catch( Exception e) { - fail("Construction failed!"); - } - - // Default construction with good arguments + // Default construction with good argument try { tmpEventType = new LttngEventType("test", 0L, "test", new String[1]); } @@ -107,7 +83,7 @@ public class LttngEventTypeTest extends TestCase { assertTrue("Cpu Id not what was expected!",firstEventCpu == tmpEventType.getCpuId() ); assertTrue("Marker Name not what was expected!",firstEventMarker.equals((String)tmpEventType.getMarkerName()) ); // Just test the non-nullity of labels - assertNotSame("getLabels returned null",null, tmpEventType.getLabels() ); + assertNotSame("getFormat returned null",null, tmpEventType.getLabels() ); } public void testToString() { diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngTimestampTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngTimestampTest.java index b3849d3226..0a64c9e163 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngTimestampTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/event/LttngTimestampTest.java @@ -1,29 +1,18 @@ package org.eclipse.linuxtools.lttng.tests.event; -import java.io.File; -import java.net.URL; - import junit.framework.TestCase; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; + import org.eclipse.linuxtools.lttng.event.LttngTimestamp; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; /* Functions tested here : - public LttngTimestamp() - public LttngTimestamp(long newEventTime) - public LttngTimestamp(TmfTimestamp oldEventTime) - - public long getValue() - public String getSeconds() - public String getNanoSeconds() - - public void setValue(long newValue) - - public String toString() + public LttngTimestamp(TmfTimestamp newEventTime) + public LttngTimestamp(long newEventTime) + public String getSeconds() + public String getNanoSeconds() + public String toString() */ public class LttngTimestampTest extends TestCase { @@ -34,23 +23,19 @@ public class LttngTimestampTest extends TestCase { private final static String firstEventTimeNano = "759412127"; private final static long firstEventTimeFull = 13589759412127L; - private static LTTngTextTrace testStream = null; private LTTngTextTrace initializeEventStream() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath(), skipIndexing); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } - } - return testStream; - } - + LTTngTextTrace tmpStream = null; + try { + tmpStream = new LTTngTextTrace(tracepath1, skipIndexing); + } + catch (Exception e) { + fail("ERROR : Could not open " + tracepath1 + ". Test failed!" ); + } + + return tmpStream; + } + + private LttngTimestamp prepareToTest() { LttngTimestamp tmpTime = null; @@ -71,14 +56,6 @@ public class LttngTimestampTest extends TestCase { @SuppressWarnings("unused") LttngTimestamp tmpTime2 = null; - // Default construction with no argument - try { - tmpTime = new LttngTimestamp(); - } - catch( Exception e) { - fail("Construction failed!"); - } - // Default construction with good argument try { tmpTime = new LttngTimestamp(1); @@ -107,14 +84,6 @@ public class LttngTimestampTest extends TestCase { assertEquals("Full time is wrong", firstEventTimeFull, tmpTime.getValue() ); } - public void testSetter() { - LttngTimestamp tmpTime = prepareToTest(); - - // We will set a time and we will make sure the set is working then - tmpTime.setValue(1); - assertEquals("Full time is wrong after set", 1, tmpTime.getValue() ); - } - public void testToString() { LttngTimestamp tmpTime = prepareToTest(); diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniEventTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniEventTest.java index 71cbacd946..f5887c1714 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniEventTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniEventTest.java @@ -43,39 +43,39 @@ public class JniEventTest extends TestCase { private final static boolean printLttDebug = false; - private final static String tracepath="traceset/trace-15316events_nolost_newformat"; + private final static String tracepath="traceset/trace-618339events-1293lost-1cpu"; private final static String eventName="kernel0"; - private final static int numberOfMarkersInTracefile = 45; + private final static int numberOfMarkersInTracefile = 46; private final static int numberOfparsedFieldsFirstEvent = 1; private final static int numberOfparsedFieldsSecondEvent = 3; private final static int chosenPositionOfFieldsFirstEvent = 1; private final static int chosenPositionOfFieldsSecondEvent = 0; - private final static int chosenPositionOfFieldsAfterSeekEvent = 1; + private final static int chosenPositionOfFieldsAfterSeekEvent = 0; private final static String chosenNameOfFieldsFirstEvent = "string"; private final static String chosenNameOfFieldsSecondEvent = "ip"; - private final static String chosenNameOfFieldsThirdEvent = "syscall_id"; + private final static String chosenNameOfFieldsThirdEvent = "ret"; private final static String contentOfFieldsFirstEvent = "LTT state dump begin"; - private final static String contentOfFieldsSecondEvent = "0xc142176d"; + private final static long contentOfFieldsSecondEvent = 3222386054L; private final static long contentOfFieldsThirdEvent = 3L; private final static int numberOfByteInContent = 4; - private final static long firstEventTimestamp = 13589760262237L; - private final static long secondEventTimestamp = 13589762149621L; - private final static long thirdEventTimestamp = 13589762917527L; + private final static long firstEventTimestamp = 952090116049L; + private final static long secondEventTimestamp = 952092222957L; + private final static long thirdEventTimestamp = 952102730748L; - private final static long timestampToSeekTest1 = 13589807108560L; - private final static long timestampAfterSeekTest1 = 13589807116344L; + private final static long timestampToSeekTest1 = 953852206193L; + private final static long timestampAfterSeekTest1 = 953852212349L; - private final static long timestampToSeekLast = 13589906758692L; + private final static long timestampToSeekLast = 960386638531L; private final static long timestampToSeekTooFarAway = Long.MAX_VALUE; - + private JniEvent prepareEventToTest() { JniEvent tmpEvent = null; @@ -329,8 +329,9 @@ public class JniEventTest extends TestCase // Test #1 readNextEvent() testEvent.readNextEvent(); assertNotNull("parseFieldById returned null",testEvent.parseFieldById(chosenPositionOfFieldsSecondEvent) ); - assertEquals("Content return by parseFieldById is invalid", contentOfFieldsSecondEvent, testEvent.parseFieldById(chosenPositionOfFieldsSecondEvent).toString() ); - assertEquals("Content return by parseFieldByName is invalid",contentOfFieldsSecondEvent, testEvent.parseFieldByName(chosenNameOfFieldsSecondEvent).toString() ); + assertEquals("Content return by parseFieldById is invalid",contentOfFieldsSecondEvent, testEvent.parseFieldById(chosenPositionOfFieldsSecondEvent) ); + assertEquals("Content return by parseFieldByName is invalid",contentOfFieldsSecondEvent, testEvent.parseFieldByName(chosenNameOfFieldsSecondEvent) ); + // Test #1 of seekToTime() testEvent.seekToTime(new JniTime(timestampToSeekTest1) ); diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerFieldTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerFieldTest.java index 03788b0cbf..003600133e 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerFieldTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerFieldTest.java @@ -26,7 +26,7 @@ public class JniMarkerFieldTest extends TestCase { private final static boolean printLttDebug = false; - private final static String tracepath="traceset/trace-15316events_nolost_newformat"; + private final static String tracepath="traceset/trace-618339events-1293lost-1cpu"; private final static String eventName="kernel0"; private JniMarkerField prepareMarkerFieldToTest() { diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerTest.java index 465550e0d5..7db7a9ad11 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniMarkerTest.java @@ -28,7 +28,7 @@ public class JniMarkerTest extends TestCase { private final static boolean printLttDebug = false; - private final static String tracepath="traceset/trace-15316events_nolost_newformat"; + private final static String tracepath="traceset/trace-618339events-1293lost-1cpu"; private final static String eventName="kernel0"; private final static int numberOfMarkersFieldInMarker = 3; diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTraceTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTraceTest.java index 08ec9d75b1..04bfa449bf 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTraceTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTraceTest.java @@ -57,36 +57,36 @@ public class JniTraceTest extends TestCase { private final static boolean printLttDebug = false; - private final static String tracepath1="traceset/trace-15316events_nolost_newformat"; - private final static String tracepath2="traceset/trace-15471events_nolost_newformat"; + private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu"; + private final static String tracepath2="traceset/trace-1021events-nolost-1cpu"; private final static String wrongTracePath="/somewhere/that/does/not/exist"; private final static String correctTracefileName="kernel0"; private final static String wrongTracefileName="somethingThatDoesNotExists"; - private final static int numberOfTracefilesInTrace = 16; + private final static int numberOfTracefilesInTrace = 18; - private final static long firstEventTimestamp = 13589759412128L; + private final static long firstEventTimestamp = 952088954601L; private final static String firstEventTracefilename = "metadata0"; - private final static long secondEventTimestamp = 13589759419903L; + private final static long secondEventTimestamp = 952088959952L; private final static String secondEventName = "metadata"; - private final static long thirdEventTimestamp = 13589759422785L; + private final static long thirdEventTimestamp = 952088965599L; - private final static long eventTimestampAfterMetadata = 13589760262237L; + private final static long eventTimestampAfterMetadata = 952090116049L; private final static String eventTracefilenameAfterMetadata = "kernel0"; - private final static long timestampToSeekTest1 = 13589821608319L; + private final static long timestampToSeekTest1 = 953852206193L; private final static String eventNameAfterSeekTest1 = "kernel"; private final static String eventTracefilenameAfterSeekTest1 = "kernel0"; - private final static String nextEventNameAfterSeekTest1 = "vm_state"; + private final static String nextEventNameAfterSeekTest1 = "fs"; - private final static long timestampToSeekTest2 = 13589861889350L; + private final static long timestampToSeekTest2 = 953852210706L; private final static String eventNameAfterSeekTest2 = "fs"; private final static String nextEventNameAfterSeekTest2 = "kernel"; - private final static long timestampToSeekLast = 13589906758692L; + private final static long timestampToSeekLast = 960386638531L; private final static String eventNameAfterSeekLast = "kernel"; @@ -96,7 +96,6 @@ public class JniTraceTest extends TestCase // This trace should be valid try { tmpTrace = new JniTrace(tracepath1, printLttDebug); - //tmpTrace.seekToTime(new JniTime(0L)); } catch( JniException e) { } diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTracefileTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTracefileTest.java index 9f6c23e748..db020d6f5d 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTracefileTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/jni/JniTracefileTest.java @@ -56,19 +56,19 @@ public class JniTracefileTest extends TestCase { private final static boolean printLttDebug = false; - private final static String tracepath1="traceset/trace-15316events_nolost_newformat"; + private final static String tracepath1="traceset/trace-618339events-1293lost-1cpu"; private final static String tracefileName1="kernel0"; - private final static int numberOfMarkersInTracefile = 45; + private final static int numberOfMarkersInTracefile = 46; - private final static long firstEventTimestamp = 13589760262237L; - private final static long secondEventTimestamp = 13589762149621L; - private final static long thirdEventTimestamp = 13589762917527L; + private final static long firstEventTimestamp = 952090116049L; + private final static long secondEventTimestamp = 952092222957L; + private final static long thirdEventTimestamp = 952102730748L; - private final static long timestampToSeekTest1 = 13589807108560L; - private final static long timestampAfterSeekTest1 = 13589807116344L; + private final static long timestampToSeekTest1 = 953852206193L; + private final static long timestampAfterSeekTest1 = 953852212349L; - private final static long timestampToSeekLast = 13589906758692L; + private final static long timestampToSeekLast = 960386638531L; private JniTracefile prepareTracefileToTest() { diff --git a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngTextTraceTest.java b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngTextTraceTest.java index bf7fba9302..c7484dc828 100644 --- a/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngTextTraceTest.java +++ b/org.eclipse.linuxtools.lttng.tests/src/org/eclipse/linuxtools/lttng/tests/trace/LTTngTextTraceTest.java @@ -1,33 +1,24 @@ package org.eclipse.linuxtools.lttng.tests.trace; -import org.eclipse.linuxtools.tmf.event.TmfEvent; -import java.io.File; -import java.net.URL; - -import junit.framework.TestCase; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.linuxtools.lttng.tests.LTTngCoreTestPlugin; import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace; +import org.eclipse.linuxtools.tmf.event.TmfEvent; import org.eclipse.linuxtools.tmf.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.trace.TmfTraceContext; +import junit.framework.TestCase; /* Functions tested here : - public LTTngTextTrace(String path) throws Exception - public LTTngTextTrace(String path, boolean skipIndexing) throws Exception - - public TmfTraceContext seekLocation(Object location) { - public TmfTraceContext seekEvent(TmfTimestamp timestamp) { - public TmfTraceContext seekEvent(long position) { + public LTTngTextTrace(String path) throws Exception + + public TmfTraceContext seekLocation(Object location) + public TmfTraceContext seekEvent(TmfTimestamp timestamp) + public TmfTraceContext seekEvent(long position) - public TmfEvent getNextEvent(TmfTraceContext context) { - public Object getCurrentLocation() { + public TmfEvent getNextEvent(TmfTraceContext context) - public LttngEvent parseEvent(TmfTraceContext context) { + public Object getCurrentLocation() - public int getCpuNumber() { + public LttngEvent parseEvent(TmfTraceContext context) */ public class LTTngTextTraceTest extends TestCase { @@ -35,8 +26,6 @@ public class LTTngTextTraceTest extends TestCase { private final static String tracepath1="traceset/trace-15316events_nolost_newformat.txt"; private final static String wrongTracePath="/somewhere/that/does/not/exist"; - private final static int traceCpuNumber=1; - private final static boolean skipIndexing=true; private final static long firstEventTimestamp = 13589759412127L; @@ -62,30 +51,22 @@ public class LTTngTextTraceTest extends TestCase { private final static long locationToSeekLast = 3410544; private final static long contextValueAfterSeekLast = 13589906758691L; private final static String seekLastEventReference = tracename + "/kernel_0"; + + private LTTngTextTrace prepareStreamToTest() { + LTTngTextTrace tmpStream = null; - private static LTTngTextTrace testStream = null; - private LTTngTextTrace prepareStreamToTest() { - if (testStream == null) { - try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - LTTngTextTrace tmpStream = new LTTngTextTrace(testfile.getPath()); - testStream = tmpStream; - } - catch (Exception e) { - System.out.println("ERROR : Could not open " + tracepath1); - testStream = null; - } + // This trace should be valid + try { + tmpStream = new LTTngTextTrace(tracepath1); + } + catch (Exception e) { + System.out.println("ERROR : Could not open " + tracepath1); } - else { - testStream.seekEvent(0); - } - - - return testStream; - } - public void testTraceConstructors() { + return tmpStream; + } + + public void testTraceConstructors() { @SuppressWarnings("unused") LTTngTextTrace testStream1 = null; @@ -100,9 +81,7 @@ public class LTTngTextTraceTest extends TestCase { // Test constructor with argument on a correct tracepath, skipping indexing try { - URL location = FileLocator.find(LTTngCoreTestPlugin.getPlugin().getBundle(), new Path(tracepath1), null); - File testfile = new File(FileLocator.toFileURL(location).toURI()); - testStream1 = new LTTngTextTrace(testfile.getPath(), skipIndexing); + testStream1 = new LTTngTextTrace(tracepath1, skipIndexing); } catch( Exception e) { fail("Construction with correct tracepath failed!"); @@ -244,8 +223,6 @@ public class LTTngTextTraceTest extends TestCase { assertNotSame("tmpContext is null after first seekEvent()",null,testStream1.getCurrentLocation() ); assertEquals("tmpContext has wrong timestamp after first seekEvent()",locationAfterFirstEvent,(Long)testStream1.getCurrentLocation() ); - // Test CPU number of the trace - assertSame("getCpuNumber() return wrong number of cpu",traceCpuNumber ,testStream1.getCpuNumber() ); } public void testToString() { -- 2.34.1