Extract the linux-kernel-specific things into their own plugin
[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.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
17 import static org.junit.Assert.assertTrue;
18 import static org.junit.Assert.fail;
19
20 import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider;
21 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
22 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
23 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
24 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
25 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
26 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
27 import org.junit.AfterClass;
28 import org.junit.BeforeClass;
29
30 /**
31 * State system tests using the in-memory back-end.
32 *
33 * @author Alexandre Montplaisir
34 */
35 public class StateSystemInMemoryTest extends StateSystemTest {
36
37 private static TestLttngKernelAnalysisModule module;
38
39 /**
40 * Test class setup
41 */
42 @BeforeClass
43 public static void initialize() {
44 if (!testTrace.exists()) {
45 traceIsPresent = false;
46 return;
47 }
48 traceIsPresent = true;
49
50 module = new TestLttngKernelAnalysisModule();
51 try {
52 module.setTrace(testTrace.getTrace());
53 } catch (TmfAnalysisException e) {
54 fail();
55 }
56 module.schedule();
57 assertTrue(module.waitForCompletion());
58
59 fixture = module.getStateSystem();
60 }
61
62 /**
63 * Class cleanup
64 */
65 @AfterClass
66 public static void cleanup() {
67 if (module != null) {
68 module.dispose();
69 }
70 if (fixture != null) {
71 fixture.dispose();
72 }
73 module = null;
74 fixture = null;
75 }
76
77 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
78
79 /**
80 * Constructor adding the views to the analysis
81 */
82 public TestLttngKernelAnalysisModule() {
83 super();
84 }
85
86 @Override
87 public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
88 if (!(trace instanceof CtfTmfTrace)) {
89 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
90 }
91 super.setTrace(trace);
92 }
93
94 @Override
95 protected ITmfStateProvider createStateProvider() {
96 return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
97 }
98
99 @Override
100 protected StateSystemBackendType getBackendType() {
101 return StateSystemBackendType.INMEM;
102 }
103 }
104 }
This page took 0.033827 seconds and 5 git commands to generate.