LTTng: CPU usage analysis from the LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / statistics / TmfStateStatisticsTest.java
index a409d46afcd016d42804562da2ac17e6b867c6b5..e6b8c6460594bd32631e8c7128185a0ee4cf7536 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
+ * Copyright (c) 2012, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
 
 package org.eclipse.linuxtools.tmf.core.tests.statistics;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
-import java.io.File;
-import java.io.IOException;
-
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
 import org.eclipse.linuxtools.tmf.core.statistics.TmfStateStatistics;
-import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
+import org.eclipse.linuxtools.tmf.core.statistics.TmfStatisticsEventTypesModule;
+import org.eclipse.linuxtools.tmf.core.statistics.TmfStatisticsTotalsModule;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.BeforeClass;
 
 /**
@@ -30,21 +34,51 @@ import org.junit.BeforeClass;
  */
 public class TmfStateStatisticsTest extends TmfStatisticsTest {
 
+    private ITmfTrace fTrace;
+
     /**
-     * Set up the fixture (build the state history, etc.) once for all tests.
+     * Class setup
      */
     @BeforeClass
     public static void setUpClass() {
-        assumeTrue(CtfTmfTestTraces.tracesExist());
+        assumeTrue(testTrace.exists());
+    }
+
+    /**
+     * Test setup
+     */
+    @Before
+    public void setUp() {
+        fTrace = testTrace.getTrace();
+
+        /* Prepare the two analysis-backed state systems */
+        TmfStatisticsTotalsModule totalsMod = new TmfStatisticsTotalsModule();
+        TmfStatisticsEventTypesModule eventTypesMod = new TmfStatisticsEventTypesModule();
         try {
-            File htFile = File.createTempFile("stats-test", ".ht");
-            htFile.deleteOnExit();
-            CtfTmfTrace trace = CtfTmfTestTraces.getTestTrace(TRACE_INDEX);
-            backend = new TmfStateStatistics(trace, htFile);
-        } catch (TmfTraceException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
+            totalsMod.setTrace(fTrace);
+            eventTypesMod.setTrace(fTrace);
+        } catch (TmfAnalysisException e) {
+            fail();
         }
+
+        totalsMod.schedule();
+        eventTypesMod.schedule();
+        assertTrue(totalsMod.waitForCompletion());
+        assertTrue(eventTypesMod.waitForCompletion());
+
+        ITmfStateSystem totalsSS = totalsMod.getStateSystem();
+        ITmfStateSystem eventTypesSS = eventTypesMod.getStateSystem();
+        assertNotNull(totalsSS);
+        assertNotNull(eventTypesSS);
+
+        backend = new TmfStateStatistics(totalsSS, eventTypesSS);
+    }
+
+    /**
+     * Test cleanup
+     */
+    @After
+    public void tearDown() {
+        fTrace.dispose();
     }
 }
This page took 0.074552 seconds and 5 git commands to generate.