lttng: Add interface to abstract the event layout away
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / analysis / kernel / statesystem / StateSystemInMemoryTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
11 * Bernd Hufmann - Use state system analysis module instead of factory
12 ******************************************************************************/
13
14 package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
15
16 import static org.junit.Assert.assertTrue;
17 import static org.junit.Assert.fail;
18
19 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
20 import org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel.LttngKernelStateProvider;
21 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
22 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
23 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
24 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
25 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
26 import org.junit.AfterClass;
27 import org.junit.BeforeClass;
28
29 /**
30 * State system tests using the in-memory back-end.
31 *
32 * @author Alexandre Montplaisir
33 */
34 public class StateSystemInMemoryTest extends StateSystemTest {
35
36 private static TestLttngKernelAnalysisModule module;
37
38 /**
39 * Test class setup
40 */
41 @BeforeClass
42 public static void initialize() {
43 if (!testTrace.exists()) {
44 traceIsPresent = false;
45 return;
46 }
47 traceIsPresent = true;
48
49 module = new TestLttngKernelAnalysisModule();
50 try {
51 module.setTrace(testTrace.getTrace());
52 } catch (TmfAnalysisException e) {
53 fail();
54 }
55 module.schedule();
56 assertTrue(module.waitForCompletion());
57
58 fixture = module.getStateSystem();
59 }
60
61 /**
62 * Class cleanup
63 */
64 @AfterClass
65 public static void cleanup() {
66 if (module != null) {
67 module.dispose();
68 }
69 if (fixture != null) {
70 fixture.dispose();
71 }
72 module = null;
73 fixture = null;
74 }
75
76 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
77
78 /**
79 * Constructor adding the views to the analysis
80 */
81 public TestLttngKernelAnalysisModule() {
82 super();
83 }
84
85 @Override
86 public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
87 if (!(trace instanceof CtfTmfTrace)) {
88 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
89 }
90 super.setTrace(trace);
91 }
92
93 @Override
94 protected ITmfStateProvider createStateProvider() {
95 return new LttngKernelStateProvider(getTrace(), LttngEventLayout.getInstance());
96 }
97
98 @Override
99 protected StateSystemBackendType getBackendType() {
100 return StateSystemBackendType.INMEM;
101 }
102 }
103 }
This page took 0.034784 seconds and 6 git commands to generate.