lttng: Correctly skip tests if test traces are missing
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core.tests / src / org / eclipse / linuxtools / lttng2 / kernel / core / tests / stateprovider / 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.linuxtools.lttng2.kernel.core.tests.stateprovider;
15
16 import static org.junit.Assert.assertNotNull;
17 import static org.junit.Assert.assertTrue;
18 import static org.junit.Assert.fail;
19 import static org.junit.Assume.assumeTrue;
20
21 import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
22 import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
23 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
24 import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
25 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
26 import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
27 import org.junit.After;
28 import org.junit.Before;
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 TestLttngKernelAnalysisModule module;
38
39 /**
40 * Initialization
41 */
42 @Before
43 public void initialize() {
44 assumeTrue(testTrace.exists());
45
46 module = new TestLttngKernelAnalysisModule();
47 try {
48 module.setTrace(testTrace.getTrace());
49 } catch (TmfAnalysisException e) {
50 fail();
51 }
52 module.schedule();
53 assertTrue(module.waitForCompletion());
54 ssq = module.getStateSystem();
55 assertNotNull(ssq);
56 }
57
58 /**
59 * Class cleanup
60 */
61 @After
62 public void cleanupClass() {
63 module.close();
64 }
65
66 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
67
68 /**
69 * Constructor adding the views to the analysis
70 */
71 public TestLttngKernelAnalysisModule() {
72 super();
73 }
74
75 @Override
76 public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
77 if (!(trace instanceof CtfTmfTrace)) {
78 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
79 }
80 super.setTrace(trace);
81 }
82
83 @Override
84 protected ITmfStateProvider createStateProvider() {
85 return new LttngKernelStateProvider(getTrace());
86 }
87
88 @Override
89 protected StateSystemBackendType getBackendType() {
90 return StateSystemBackendType.INMEM;
91 }
92 }
93 }
This page took 0.035414 seconds and 6 git commands to generate.