1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.tests
.stateprovider
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.fail
;
18 import static org
.junit
.Assume
.assumeTrue
;
21 import java
.io
.IOException
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.CtfKernelStateProvider
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateProvider
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateSystem
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.StateSystemManager
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.CtfTmfTestTraces
;
29 import org
.junit
.BeforeClass
;
30 import org
.junit
.Test
;
33 * State system tests using a full history back-end and the LTTng kernel state
36 * @author Alexandre Montplaisir
38 public class StateSystemFullHistoryTest
extends StateSystemTest
{
40 private static File stateFile
;
41 private static File stateFileBenchmark
;
44 * Initialize the test cases (build the history file once for all tests).
47 public static void initialize() {
48 assumeTrue(CtfTmfTestTraces
.tracesExist());
50 stateFile
= File
.createTempFile("test", ".ht");
51 stateFileBenchmark
= File
.createTempFile("test", ".ht.benchmark");
53 input
= new CtfKernelStateProvider(CtfTmfTestTraces
.getTestTrace(TRACE_INDEX
));
54 ssq
= StateSystemManager
.loadStateHistory(stateFile
, input
, true);
55 } catch (IOException e
) {
57 } catch (TmfTraceException e
) {
60 stateFile
.deleteOnExit();
61 stateFileBenchmark
.deleteOnExit();
65 // ------------------------------------------------------------------------
66 // Tests specific to a full-history
67 // ------------------------------------------------------------------------
70 * Rebuild independently so we can benchmark it. Too bad JUnit doesn't allow
71 * us to @Test the @BeforeClass...
74 public void testBuild() {
76 ITmfStateProvider input2
= new CtfKernelStateProvider(CtfTmfTestTraces
.getTestTrace(TRACE_INDEX
));
77 ITmfStateSystem ssb2
= StateSystemManager
.loadStateHistory(stateFileBenchmark
, input2
, true);
79 assertEquals(startTime
, ssb2
.getStartTime());
80 assertEquals(endTime
, ssb2
.getCurrentEndTime());
82 } catch (TmfTraceException e
) {
88 * Test re-opening the existing file.
91 public void testOpenExistingStateFile() {
93 /* 'newStateFile' should have already been created */
94 ITmfStateSystem ssb2
= StateSystemManager
.loadStateHistory(stateFile
, null, true);
97 assertEquals(startTime
, ssb2
.getStartTime());
98 assertEquals(endTime
, ssb2
.getCurrentEndTime());
100 } catch (TmfTraceException e
) {