ctf: Depend on the tracecompass-test-traces project
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.core.tests / src / org / eclipse / tracecompass / tmf / ctf / core / tests / event / CtfTmfLostEventsTest.java
index 2eed62ac3dd8f24186cdeb7900fd78dfb9164560..cfac0ae9ceefafef7cf19ab6ba80354bec9801bf 100644 (file)
@@ -15,9 +15,9 @@ package org.eclipse.tracecompass.tmf.ctf.core.tests.event;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
@@ -25,9 +25,8 @@ import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
 import org.junit.After;
 import org.junit.Before;
@@ -47,7 +46,7 @@ import org.junit.Test;
  */
 public class CtfTmfLostEventsTest {
 
-    private static final CtfTmfTestTrace testTrace = CtfTmfTestTrace.HELLO_LOST;
+    private static final @NonNull CtfTestTrace testTrace = CtfTestTrace.HELLO_LOST;
 
     private CtfTmfTrace fixture = null;
 
@@ -56,8 +55,7 @@ public class CtfTmfLostEventsTest {
      */
     @Before
     public void setUp() {
-        assumeTrue(testTrace.exists());
-        fixture = testTrace.getTrace();
+        fixture = CtfTmfTestTraceUtils.getTrace(testTrace);
         fixture.indexTrace(true);
     }
 
@@ -96,14 +94,42 @@ public class CtfTmfLostEventsTest {
         assertEquals(expectedLost, req.getLost());
     }
 
+    /**
+     * Test that the number of events is reported correctly (a range of lost
+     * events is counted as one event). Events could be wrongly counted as lost
+     * events in certain situations.
+     */
+    @Test
+    public void testNbEventsBug475007() {
+        final CtfTestTrace tmfTestTrace = CtfTestTrace.DYNSCOPE;
+        CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(tmfTestTrace);
+        trace.indexTrace(true);
+
+        final long expectedReal = 100003;
+        final long expectedLost = 1;
+
+        EventCountRequest req = new EventCountRequest();
+        trace.sendRequest(req);
+        try {
+            req.waitForCompletion();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(expectedReal, req.getReal());
+        assertEquals(expectedLost, req.getLost());
+
+        trace.dispose();
+    }
+
     /**
      * Test getting the first lost event from the trace.
      */
     @Test
     public void testFirstLostEvent() {
-        final long rank = 153;
-        final ITmfTimestamp start = new TmfNanoTimestamp(1376592664828848222L);
-        final ITmfTimestamp end   = new TmfNanoTimestamp(1376592664828848540L);
+        final long rank = 190;
+        final ITmfTimestamp start = new TmfNanoTimestamp(1376592664828900165L);
+        final ITmfTimestamp end   = new TmfNanoTimestamp(1376592664829403076L);
         final long nbLost = 859;
 
         final CtfTmfEvent ev = getOneEventTime(start);
@@ -125,9 +151,9 @@ public class CtfTmfLostEventsTest {
      */
     @Test
     public void testSecondLostEvent() {
-        final long rank = 191;
-        final ITmfTimestamp start = new TmfNanoTimestamp(1376592664829402521L);
-        final ITmfTimestamp end   = new TmfNanoTimestamp(1376592664829403076L);
+        final long rank = 229;
+        final ITmfTimestamp start = new TmfNanoTimestamp(1376592664829477058L);
+        final ITmfTimestamp end   = new TmfNanoTimestamp(1376592664829824514L);
         final long nbLost = 488;
 
         final CtfTmfEvent ev = getOneEventTime(start);
@@ -151,7 +177,7 @@ public class CtfTmfLostEventsTest {
     @Test
     public void testNormalEvent() {
         final long rank = 200;
-        final ITmfTimestamp ts = new TmfNanoTimestamp(1376592664829423928L);
+        final ITmfTimestamp ts = new TmfNanoTimestamp(1376592664829425780L);
 
         final CtfTmfEvent event = getOneEventTime(ts);
         /* Make sure seeking by rank yields the same event */
@@ -213,8 +239,8 @@ public class CtfTmfLostEventsTest {
 
         public OneEventRequestPerTs(@NonNull ITmfTimestamp ts) {
             super(CtfTmfEvent.class,
-                    new TmfTimeRange(ts, TmfTimestamp.BIG_CRUNCH),
-                    0, 1, ExecutionType.FOREGROUND);
+                    new TmfTimeRange(ts, ts),
+                    0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
         }
 
         @Override
This page took 0.026789 seconds and 5 git commands to generate.