lttng: Check for correct start/end times in the tests
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 30 Apr 2012 20:19:32 +0000 (16:19 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 30 Apr 2012 20:19:32 +0000 (16:19 -0400)
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/CtfTestFiles.java
org.eclipse.linuxtools.lttng2.kernel.core.tests/src/org/eclipse/linuxtools/lttng2/kernel/core/tests/stateprovider/StateSystemFullHistoryTest.java

index 661c0bd538d3d8a9193ec8a464b289b4e2503aa8..5be75a3472dc95e836c6ed6113510d999ce919fc 100644 (file)
@@ -32,6 +32,7 @@ public abstract class CtfTestFiles {
      */
     public final static String traceFile = "../org.eclipse.linuxtools.ctf.core.tests/traces/trace2"; //$NON-NLS-1$
     public final static long startTime = 1331668247314038062L;
+    public final static long endTime = 1331668259054285979L; /* Expected end time of history */
 
     private static CtfTmfTrace trace = null;
 
index 41e9a1dc4c9e399eb28bfaf5c9f7a8a957d36d69..1fb93b0b8ed5b246ebb6a8b1da02ffbdaa1cf32b 100644 (file)
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.List;
 
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
 import org.eclipse.linuxtools.tmf.core.statesystem.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.statesystem.StateHistorySystem;
@@ -88,36 +89,38 @@ public class StateSystemFullHistoryTest {
     /**
      * Rebuild independently so we can benchmark it. Too bad JUnit doesn't allow
      * us to @Test the @BeforeClass...
+     * 
+     * @throws IOException 
+     * @throws TmfTraceException 
      */
     @Test
-    public void testBuild() {
+    public void testBuild() throws IOException, TmfTraceException {
         HistoryBuilder zebuilder;
         IStateChangeInput zeinput;
-        IStateHistoryBackend zehp;
+        IStateHistoryBackend zehp = null;
 
-        try {
-            zeinput = new CtfKernelStateInput(CtfTestFiles.getTestTrace());
-            zehp = new HistoryTreeBackend(stateFileBenchmark,
-                    zeinput.getStartTime());
-            zebuilder = new HistoryBuilder(zeinput, zehp);
-            zebuilder.run();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+        zeinput = new CtfKernelStateInput(CtfTestFiles.getTestTrace());
+        zehp = new HistoryTreeBackend(stateFileBenchmark, zeinput.getStartTime());
+        zebuilder = new HistoryBuilder(zeinput, zehp);
+        zebuilder.run();
+        zebuilder.close();
+
+        assertEquals(CtfTestFiles.startTime, zehp.getStartTime());
+        assertEquals(CtfTestFiles.endTime, zehp.getEndTime());
     }
 
     @Test
-    public void testOpenExistingStateFile() {
+    public void testOpenExistingStateFile() throws IOException {
         IStateHistoryBackend hp2 = null;
         StateHistorySystem shs2 = null;
-        try {
-            /* 'newStateFile' should have already been created */
-            hp2 = new HistoryTreeBackend(stateFile);
-            shs2 = new StateHistorySystem(hp2, false);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        assertTrue(shs2 != null);
+
+        /* 'newStateFile' should have already been created */
+        hp2 = new HistoryTreeBackend(stateFile);
+        shs2 = new StateHistorySystem(hp2, false);
+
+        assertNotNull(shs2);
+        assertEquals(CtfTestFiles.startTime, hp2.getStartTime());
+        assertEquals(CtfTestFiles.endTime, hp2.getEndTime());
     }
 
     @Test
This page took 0.025745 seconds and 5 git commands to generate.