ctf: Fix lost events timestamp in CTFPacketReader
authorPatrick Tasse <patrick.tasse@gmail.com>
Mon, 30 Nov 2015 20:56:19 +0000 (15:56 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 8 Dec 2015 17:31:52 +0000 (12:31 -0500)
The lost events should be inserted after the last event in the packet,
not before the first event in the packet.

This was a regression where the changes to CTFStreamInputPacketReader
from https://git.eclipse.org/r/50683 were not ported to CTFPacketReader.

Change-Id: I055887b02212bd43052d36fbbd0dde3ca36edb6e
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/61598
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
ctf/org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFPacketReaderTest.java
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/CTFPacketReader.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventStatisticsTest.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java

index 8d76ee260d6d089b4a3fc253cea45867e5d06a1c..7defd85c7d58a2c4f3083fbac2f601603ba86f4c 100644 (file)
@@ -212,17 +212,17 @@ public class CTFPacketReaderTest {
         assertTrue(cpr.hasMoreEvents());
         EventDefinition event = cpr.readNextEvent();
         assertEquals(0L, event.getTimestamp());
-        assertEquals(event.getDeclaration().getName(), CTFStrings.LOST_EVENT_NAME);
-        assertEquals(512L, ((IntegerDefinition) event.getFields().getDefinition(CTFStrings.LOST_EVENTS_FIELD)).getValue());
-        assertTrue(cpr.hasMoreEvents());
-        event = cpr.readNextEvent();
-        assertEquals(0L, event.getTimestamp());
         assertEquals(1L, ((IntegerDefinition) event.getFields().getDefinition("field")).getValue());
         assertNotNull(cpr);
         assertTrue(cpr.hasMoreEvents());
         event = cpr.readNextEvent();
         assertEquals(256L, event.getTimestamp());
         assertEquals(0x5a, ((IntegerDefinition) event.getFields().getDefinition("field")).getValue());
+        assertTrue(cpr.hasMoreEvents());
+        event = cpr.readNextEvent();
+        assertEquals(256L, event.getTimestamp());
+        assertEquals(event.getDeclaration().getName(), CTFStrings.LOST_EVENT_NAME);
+        assertEquals(512L, ((IntegerDefinition) event.getFields().getDefinition(CTFStrings.LOST_EVENTS_FIELD)).getValue());
         assertFalse(cpr.hasMoreEvents());
     }
 
index 940490a80ee0f66c6c1257e56df5cebc93e0d8cf..36e73697c5fb3c4129a359a227958bb22c0763f0 100644 (file)
@@ -114,7 +114,7 @@ public final class CTFPacketReader implements IPacketReader, IDefinitionScope {
 
     @Override
     public boolean hasMoreEvents() {
-        return fInput.position() < fPacketContext.getContentSizeBits();
+        return fHasLost || (fInput.position() < fPacketContext.getContentSizeBits());
     }
 
     @Override
@@ -125,7 +125,7 @@ public final class CTFPacketReader implements IPacketReader, IDefinitionScope {
          * Return the Lost Event after all other events in this packet. We need
          * to check if the bytebuffer is at the beginning too.
          */
-        if (fHasLost && (posStart == fPacketContext.getPayloadStartBits())) {
+        if (fHasLost && (posStart >= fPacketContext.getContentSizeBits())) {
             fHasLost = false;
             return createLostEvent(fPacketContext);
         }
index fd4b642c75d594ba3192faa3259d1c665d6f1935..0cfedc29709129360501e28e8eadc8adc501d146 100644 (file)
@@ -157,6 +157,6 @@ public class CtfTmfLostEventStatisticsTest {
         Map<String, Long> eventsInRange = fStats.getEventTypesInRange(rangeStart, rangeEnd);
         Long lostEventsInRange = eventsInRange.get(CTFStrings.LOST_EVENT_NAME);
         assertNotNull(lostEventsInRange);
-        assertEquals(363494L, lostEventsInRange.longValue());
+        assertEquals(365752L, lostEventsInRange.longValue());
     }
 }
index 96a0295766379acb2df8c6db760febb21b4db952..81c1d6769575b128955ee4b800d6db6b5a8aaf5e 100644 (file)
@@ -129,10 +129,10 @@ public class CtfTmfLostEventsTest {
      */
     @Test
     public void testFirstLostEvent() {
-        final long rank = 152;
-        final long startTime = 1376592664828848222L;
+        final long rank = 190;
+        final long startTime = 1376592664828900165L;
         final ITmfTimestamp start = new TmfNanoTimestamp(startTime);
-        final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 554854L);
+        final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 502911L);
         final long nbLost = 859;
 
         validateLostEvent(rank, start, end, nbLost);
@@ -143,10 +143,10 @@ public class CtfTmfLostEventsTest {
      */
     @Test
     public void testSecondLostEvent() {
-        final long rank = 191;
-        final long startTime = 1376592664829402521L;
+        final long rank = 229;
+        final long startTime = 1376592664829477058L;
         final ITmfTimestamp start = new TmfNanoTimestamp(startTime);
-        final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 421993L);
+        final ITmfTimestamp end = new TmfNanoTimestamp(startTime + 347456L);
         final long nbLost = 488;
 
         validateLostEvent(rank, start, end, nbLost);
@@ -173,8 +173,8 @@ public class CtfTmfLostEventsTest {
      */
     @Test
     public void testNormalEvent() {
-        final long rank = 193;
-        final ITmfTimestamp ts = new TmfNanoTimestamp(1376592664829411423L);
+        final long rank = 200;
+        final ITmfTimestamp ts = new TmfNanoTimestamp(1376592664829425780L);
 
         final CtfTmfEvent event = getOneEventTime(ts);
         /* Make sure seeking by rank yields the same event */
@@ -195,9 +195,9 @@ public class CtfTmfLostEventsTest {
         trace.setTimestampTransform(TimestampTransformFactory.createWithOffset(offset));
         trace.indexTrace(true);
 
-        final long rank = 152;
-        final ITmfTimestamp start = new TmfNanoTimestamp(1376592664828848222L + offset);
-        final ITmfTimestamp end = new TmfNanoTimestamp(1376592664828848222L + 554854L + offset);
+        final long rank = 190;
+        final ITmfTimestamp start = new TmfNanoTimestamp(1376592664828900165L + offset);
+        final ITmfTimestamp end = new TmfNanoTimestamp(1376592664828900165L + 502911L + offset);
         final long nbLost = 859;
 
         ITmfContext context = trace.seekEvent(rank);
@@ -268,7 +268,7 @@ public class CtfTmfLostEventsTest {
         public OneEventRequestPerTs(@NonNull ITmfTimestamp ts) {
             super(CtfTmfEvent.class,
                     new TmfTimeRange(ts, ts),
-                    0, 1, ExecutionType.FOREGROUND);
+                    0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
         }
 
         @Override
This page took 0.029406 seconds and 5 git commands to generate.