6033f5f26c375fd20ca819bad5291296b85ceba2
[deliverable/tracecompass.git] / lttng / org.lttng.scope.lttng.kernel.core.tests / src / org / lttng / scope / lttng / kernel / core / analysis / os / statesystem / StateSystemInMemoryTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 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.lttng.scope.lttng.kernel.core.analysis.os.statesystem;
15
16 import static org.junit.Assert.assertTrue;
17 import static org.junit.Assert.fail;
18
19 import org.eclipse.tracecompass.ctf.tmf.core.tests.shared.CtfTmfTestTraceUtils;
20 import org.eclipse.tracecompass.ctf.tmf.core.trace.CtfTmfTrace;
21 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
22 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
23 import org.junit.AfterClass;
24 import org.junit.BeforeClass;
25 import org.lttng.scope.lttng.kernel.core.analysis.os.KernelAnalysisModule;
26
27 /**
28 * State system tests using the in-memory back-end.
29 *
30 * @author Alexandre Montplaisir
31 */
32 public class StateSystemInMemoryTest extends StateSystemTest {
33
34 private static CtfTmfTrace trace;
35 private static TestLttngKernelAnalysisModule module;
36
37 /**
38 * Test class setup
39 */
40 @BeforeClass
41 public static void initialize() {
42 CtfTmfTrace thetrace = CtfTmfTestTraceUtils.getTrace(testTrace);
43 trace = thetrace;
44
45 module = new TestLttngKernelAnalysisModule();
46 try {
47 assertTrue(module.setTrace(thetrace));
48 } catch (TmfAnalysisException e) {
49 fail();
50 }
51 module.schedule();
52 assertTrue(module.waitForCompletion());
53
54 fixture = module.getStateSystem();
55 }
56
57 /**
58 * Class cleanup
59 */
60 @AfterClass
61 public static void cleanup() {
62 if (module != null) {
63 module.dispose();
64 }
65 if (fixture != null) {
66 fixture.dispose();
67 }
68 if (trace != null) {
69 trace.dispose();
70 }
71 module = null;
72 fixture = null;
73 trace = null;
74 }
75
76 private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
77
78 /**
79 * Constructor adding the views to the analysis
80 */
81 public TestLttngKernelAnalysisModule() {
82 super();
83 }
84
85 @Override
86 public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException {
87 if (!(trace instanceof CtfTmfTrace)) {
88 return false;
89 }
90 return super.setTrace(trace);
91 }
92
93 @Override
94 protected StateSystemBackendType getBackendType() {
95 return StateSystemBackendType.INMEM;
96 }
97 }
98 }
This page took 0.031774 seconds and 4 git commands to generate.