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
.Assume
.assumeTrue
;
20 import java
.io
.IOException
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.CtfKernelStateInput
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.IStateChangeInput
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateSystem
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.StateSystemManager
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.CtfTmfTestTraces
;
28 import org
.junit
.BeforeClass
;
29 import org
.junit
.Test
;
32 * State system tests using a full history back-end and the LTTng kernel state
35 * @author Alexandre Montplaisir
37 public class StateSystemFullHistoryTest
extends StateSystemTest
{
39 private static File stateFile
;
40 private static File stateFileBenchmark
;
43 * Initialize the test cases (build the history file once for all tests).
46 public static void initialize() {
47 assumeTrue(CtfTmfTestTraces
.tracesExist());
49 stateFile
= File
.createTempFile("test", ".ht"); //$NON-NLS-1$ //$NON-NLS-2$
50 stateFileBenchmark
= File
.createTempFile("test", ".ht.benchmark"); //$NON-NLS-1$ //$NON-NLS-2$
52 input
= new CtfKernelStateInput(CtfTmfTestTraces
.getTestTrace(TRACE_INDEX
));
53 ssq
= StateSystemManager
.loadStateHistory(stateFile
, input
, true);
54 } catch (IOException e
) {
56 } catch (TmfTraceException e
) {
59 stateFile
.deleteOnExit();
60 stateFileBenchmark
.deleteOnExit();
64 // ------------------------------------------------------------------------
65 // Tests specific to a full-history
66 // ------------------------------------------------------------------------
69 * Rebuild independently so we can benchmark it. Too bad JUnit doesn't allow
70 * us to @Test the @BeforeClass...
72 * @throws TmfTraceException
76 public void testBuild() throws TmfTraceException
{
77 IStateChangeInput input2
;
80 input2
= new CtfKernelStateInput(CtfTmfTestTraces
.getTestTrace(TRACE_INDEX
));
81 ssb2
= StateSystemManager
.loadStateHistory(stateFileBenchmark
, input2
, true);
83 assertEquals(startTime
, ssb2
.getStartTime());
84 assertEquals(endTime
, ssb2
.getCurrentEndTime());
88 * Test re-opening the existing file.
90 * @throws TmfTraceException
94 public void testOpenExistingStateFile() throws TmfTraceException
{
97 /* 'newStateFile' should have already been created */
98 ssb2
= StateSystemManager
.loadStateHistory(stateFile
, null, true);
101 assertEquals(startTime
, ssb2
.getStartTime());
102 assertEquals(endTime
, ssb2
.getCurrentEndTime());