[CTF] Events wrongly parsed as Lost Events
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Fri, 14 Aug 2015 18:27:54 +0000 (14:27 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 18 Aug 2015 22:49:03 +0000 (18:49 -0400)
In CTFStreamInputPacketReader, setCurrentPacket can be called multiple times
without necessarily calling readNextEvent, which means that the cached value
for fHasLost can be wrong the next time readNextEvent is called.

Bug: 475007
Change-Id: I36c22c22c144cb8307403f93c76c996c60ff52aa
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/53811
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInputPacketReader.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/shared/org/eclipse/tracecompass/tmf/ctf/core/tests/shared/CtfTmfTestTrace.java
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/event/CtfTmfLostEventsTest.java

index 4f82c1e7afef5941c291e2748cff64c0c3de0c03..88e1a9ea9a441c62cea32c8ced0b91a1208e5b06 100644 (file)
@@ -235,6 +235,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
      */
     public void setCurrentPacket(ICTFPacketDescriptor currentPacket) throws CTFException {
         fCurrentPacket = currentPacket;
+        fHasLost = false;
 
         if (fCurrentPacket != null) {
             /*
index 0b629b44c4ffe561a6a4a3f978d06933cc7df063..1abbdbd8fbc3742014393c4fbcc06d0bea6c9df0 100644 (file)
@@ -56,7 +56,9 @@ public enum CtfTmfTestTrace {
     /** Autogenerated Syntetic trace */
     SYNTHETIC_TRACE,
     /** Trace with non-standard field sizes */
-    FUNKY_TRACE;
+    FUNKY_TRACE,
+    /** Example dynamic scope, timestamp in field, empty stream trace */
+    DYNSCOPE;
 
 
     private final String fPath;
index 4baa894fd5e585d5092a9fe64abc351852021888..be188527cb1294b390f57e1272343c2c5a4a03e8 100644 (file)
@@ -95,6 +95,34 @@ 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 CtfTmfTestTrace tmfTestTrace = CtfTmfTestTrace.DYNSCOPE;
+        assumeTrue(tmfTestTrace.exists());
+        try (CtfTmfTrace trace = tmfTestTrace.getTrace()) {
+            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());
+        }
+    }
+
     /**
      * Test getting the first lost event from the trace.
      */
This page took 0.025942 seconds and 5 git commands to generate.