X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.ctf.core.tests%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Fctf%2Fcore%2Ftests%2Ftrace%2FCTFTraceReaderTest.java;h=1e7f7b6b490a12fe3190279cdd40f03dc78ee2e1;hb=ce2388e0117a0d5a1bc3392fe90e45a50e8e9a34;hp=5c8b9282c162224ce5069bf3e10ee19667e7261d;hpb=ff1ccee656bd50f3a301656b7eec9b9aaece8f3e;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java index 5c8b9282c1..1e7f7b6b49 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java @@ -1,5 +1,6 @@ package org.eclipse.linuxtools.ctf.core.tests.trace; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -36,7 +37,7 @@ public class CTFTraceReaderTest { /** * Perform pre-test initialization. - * @throws CTFReaderException + * @throws CTFReaderException */ @Before public void setUp() throws CTFReaderException { @@ -54,7 +55,7 @@ public class CTFTraceReaderTest { /** * Run the CTFTraceReader(CTFTrace) constructor test. Open a known good * trace. - * @throws CTFReaderException + * @throws CTFReaderException */ @Test public void testOpen_existing() throws CTFReaderException { @@ -141,7 +142,7 @@ public class CTFTraceReaderTest { * * Both trace reader are different objects, so they shouldn't "equals" each * other. - * @throws CTFReaderException + * @throws CTFReaderException */ @Test public void testEquals() throws CTFReaderException { @@ -198,9 +199,10 @@ public class CTFTraceReaderTest { @Test public void testGoToLastEvent() throws CTFReaderException { fixture.goToLastEvent(); - long ts1 = fixture.getCurrentEventDef().timestamp; + long ts1 = getTimestamp(); long ts2 = fixture.getEndTime(); - assertTrue(ts1 == ts2); + // the end time can be later than the last event. + assertTrue(ts1 <= ts2); } /** @@ -279,4 +281,41 @@ public class CTFTraceReaderTest { boolean result = fixture.seek(timestamp); assertTrue(result); } + + + /** + * Run the boolean seek(long) method test. + * @throws CTFReaderException + */ + @Test + public void testSeekIndex() throws CTFReaderException { + long rank = 30000L; + long first, second = 0, third , fourth; + /* + * we need to read the trace before seeking + */ + first = getTimestamp(); + for( int i = 0 ; i < 60000; i++ ) + { + if( i == rank) { + second = getTimestamp(); + } + fixture.advance(); + } + boolean result= fixture.seekIndex(0); + third = getTimestamp(); + boolean result2 = fixture.seekIndex(rank); + fourth = getTimestamp(); + assertTrue(result); + assertTrue(result2); + assertEquals( first , third); + assertEquals( second , fourth); + } + + /** + * @return + */ + private long getTimestamp() { + return fixture.getCurrentEventDef().timestamp; + } }