Commit | Line | Data |
---|---|---|
f9a76cac | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2013, 2015 Ericsson |
f9a76cac AM |
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 | |
6a769f6a | 11 | * Bernd Hufmann - Use state system analysis module instead of factory |
f9a76cac AM |
12 | ******************************************************************************/ |
13 | ||
42d5b5f2 | 14 | package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem; |
f9a76cac | 15 | |
d0c7e4ba | 16 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; |
6a769f6a BH |
17 | import static org.junit.Assert.assertTrue; |
18 | import static org.junit.Assert.fail; | |
92ba8466 | 19 | |
e363eae1 | 20 | import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelStateProvider; |
7411cd67 | 21 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout; |
2bdf0193 AM |
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; | |
9722e5d7 | 26 | import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace; |
392bf486 AM |
27 | import org.junit.AfterClass; |
28 | import org.junit.BeforeClass; | |
f9a76cac AM |
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 | ||
392bf486 AM |
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; | |
bd64ee73 | 49 | |
bd64ee73 | 50 | module = new TestLttngKernelAnalysisModule(); |
6a769f6a | 51 | try { |
f479550c | 52 | assertTrue(module.setTrace(testTrace.getTrace())); |
6a769f6a BH |
53 | } catch (TmfAnalysisException e) { |
54 | fail(); | |
55 | } | |
56 | module.schedule(); | |
7d6122fc | 57 | assertTrue(module.waitForCompletion()); |
392bf486 AM |
58 | |
59 | fixture = module.getStateSystem(); | |
6a769f6a BH |
60 | } |
61 | ||
bd64ee73 AM |
62 | /** |
63 | * Class cleanup | |
64 | */ | |
392bf486 AM |
65 | @AfterClass |
66 | public static void cleanup() { | |
edbdb7ea | 67 | if (module != null) { |
03f0b0b1 | 68 | module.dispose(); |
edbdb7ea | 69 | } |
392bf486 AM |
70 | if (fixture != null) { |
71 | fixture.dispose(); | |
72 | } | |
73 | module = null; | |
74 | fixture = null; | |
bd64ee73 AM |
75 | } |
76 | ||
6a769f6a BH |
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 | |
f479550c | 87 | public boolean setTrace(ITmfTrace trace) throws TmfAnalysisException { |
6a769f6a | 88 | if (!(trace instanceof CtfTmfTrace)) { |
f479550c | 89 | return false; |
6a769f6a | 90 | } |
f479550c | 91 | return super.setTrace(trace); |
6a769f6a BH |
92 | } |
93 | ||
94 | @Override | |
95 | protected ITmfStateProvider createStateProvider() { | |
e363eae1 | 96 | return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance()); |
6a769f6a BH |
97 | } |
98 | ||
99 | @Override | |
100 | protected StateSystemBackendType getBackendType() { | |
a3b864c0 | 101 | return StateSystemBackendType.INMEM; |
6a769f6a | 102 | } |
f9a76cac AM |
103 | } |
104 | } |