tmf: Rename StateSystemManager to TmfStateSystemFactory
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core.tests / src / org / eclipse / linuxtools / lttng2 / kernel / core / tests / stateprovider / StateSystemFullHistoryTest.java
CommitLineData
efc403bb 1/*******************************************************************************
94cce698 2 * Copyright (c) 2012, 2013 Ericsson
e743c3b8 3 *
efc403bb
AM
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
e743c3b8 8 *
f9a76cac
AM
9 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
efc403bb
AM
12
13package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider;
14
6e71ce46
AM
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.assertNotNull;
c4d139aa 17import static org.junit.Assert.fail;
92ba8466 18import static org.junit.Assume.assumeTrue;
efc403bb
AM
19
20import java.io.File;
92ba8466 21import java.io.IOException;
efc403bb 22
0fe46f2a 23import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.CtfKernelStateProvider;
1e4bb526 24import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
0fe46f2a 25import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
f1f86dfb 26import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
3f436e7c 27import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
92ba8466 28import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTraces;
6e71ce46
AM
29import org.junit.BeforeClass;
30import org.junit.Test;
efc403bb
AM
31
32/**
f9a76cac
AM
33 * State system tests using a full history back-end and the LTTng kernel state
34 * input.
e743c3b8 35 *
f9a76cac 36 * @author Alexandre Montplaisir
efc403bb 37 */
f9a76cac 38public class StateSystemFullHistoryTest extends StateSystemTest {
2359ecca 39
f9a76cac
AM
40 private static File stateFile;
41 private static File stateFileBenchmark;
efc403bb 42
f9a76cac
AM
43 /**
44 * Initialize the test cases (build the history file once for all tests).
45 */
efc403bb
AM
46 @BeforeClass
47 public static void initialize() {
92ba8466 48 assumeTrue(CtfTmfTestTraces.tracesExist());
efc403bb 49 try {
4e0b52e0
AM
50 stateFile = File.createTempFile("test", ".ht");
51 stateFileBenchmark = File.createTempFile("test", ".ht.benchmark");
f9a76cac 52
0fe46f2a 53 input = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
3f436e7c 54 ssq = TmfStateSystemFactory.newFullHistory(stateFile, input, true);
92ba8466 55 } catch (IOException e) {
efc403bb 56 e.printStackTrace();
92ba8466
AM
57 } catch (TmfTraceException e) {
58 e.printStackTrace();
59 } finally {
60 stateFile.deleteOnExit();
61 stateFileBenchmark.deleteOnExit();
ebd67b34 62 }
efc403bb
AM
63 }
64
f9a76cac
AM
65 // ------------------------------------------------------------------------
66 // Tests specific to a full-history
67 // ------------------------------------------------------------------------
68
efc403bb
AM
69 /**
70 * Rebuild independently so we can benchmark it. Too bad JUnit doesn't allow
71 * us to @Test the @BeforeClass...
72 */
73 @Test
c4d139aa
AM
74 public void testBuild() {
75 try {
0fe46f2a 76 ITmfStateProvider input2 = new CtfKernelStateProvider(CtfTmfTestTraces.getTestTrace(TRACE_INDEX));
3f436e7c 77 ITmfStateSystem ssb2 = TmfStateSystemFactory.newFullHistory(stateFileBenchmark, input2, true);
e743c3b8 78
c4d139aa
AM
79 assertEquals(startTime, ssb2.getStartTime());
80 assertEquals(endTime, ssb2.getCurrentEndTime());
1e4bb526 81
c4d139aa
AM
82 } catch (TmfTraceException e) {
83 fail();
84 }
efc403bb
AM
85 }
86
f9a76cac
AM
87 /**
88 * Test re-opening the existing file.
f9a76cac 89 */
efc403bb 90 @Test
c4d139aa
AM
91 public void testOpenExistingStateFile() {
92 try {
93 /* 'newStateFile' should have already been created */
3f436e7c 94 ITmfStateSystem ssb2 = TmfStateSystemFactory.newFullHistory(stateFile, null, true);
1e4bb526 95
c4d139aa
AM
96 assertNotNull(ssb2);
97 assertEquals(startTime, ssb2.getStartTime());
98 assertEquals(endTime, ssb2.getCurrentEndTime());
1e4bb526 99
c4d139aa
AM
100 } catch (TmfTraceException e) {
101 fail();
102 }
efc403bb
AM
103 }
104
efc403bb 105}
This page took 0.038119 seconds and 5 git commands to generate.