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 / PartialStateSystemTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 * All rights reserved. This program and the accompanying materials are
4 * made available under the terms of the Eclipse Public License v1.0 which
5 * accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Alexandre Montplaisir - Initial API and implementation
10 * Bernd Hufmann - Use state system analysis module instead of factory
11 ******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider;
14
15 import static org.junit.Assert.assertNotNull;
16 import static org.junit.Assert.assertTrue;
17 import static org.junit.Assert.fail;
18 import static org.junit.Assume.assumeTrue;
19
20 import java.io.File;
21
22 import org.eclipse.jdt.annotation.NonNull;
23 import org.eclipse.jdt.annotation.NonNullByDefault;
24 import org.eclipse.jdt.annotation.Nullable;
25 import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
26 import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
27 import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
28 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
29 import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
30 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
31 import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
32 import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
33 import org.junit.After;
34 import org.junit.Before;
35 import org.junit.Test;
36
37 /**
38 * State system tests using a partial history.
39 *
40 * @author Alexandre Montplaisir
41 */
42 public class PartialStateSystemTest extends StateSystemTest {
43
44 private static final @NonNull String TEST_FILE_NAME = "test-partial";
45
46 private File stateFile;
47 private TestLttngKernelAnalysisModule module;
48
49
50 /**
51 * Initialization
52 */
53 @Before
54 public void initialize() {
55 assumeTrue(testTrace.exists());
56 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
57 if (stateFile.exists()) {
58 stateFile.delete();
59 }
60
61 module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
62 try {
63 module.setTrace(testTrace.getTrace());
64 } catch (TmfAnalysisException e) {
65 fail();
66 }
67 module.schedule();
68 assertTrue(module.waitForCompletion());
69 ssq = module.getStateSystem();
70
71 assertNotNull(ssq);
72 }
73
74 /**
75 * Class clean-up
76 */
77 @After
78 public void tearDownClass() {
79 module.close();
80 stateFile.delete();
81 }
82
83 /**
84 * Partial histories cannot get the intervals' end times. The fake value that
85 * is returned is equal to the query's timestamp. So override this here
86 * so that {@link #testFullQueryThorough} keeps working.
87 */
88 @Override
89 protected long getEndTimes(int idx) {
90 return interestingTimestamp1;
91 }
92
93 // ------------------------------------------------------------------------
94 // Skip tests using single-queries (unsupported in partial history)
95 // ------------------------------------------------------------------------
96
97 @Override
98 @Test(expected = UnsupportedOperationException.class)
99 public void testSingleQuery1() {
100 super.testSingleQuery1();
101 }
102
103 @Override
104 @Test(expected = UnsupportedOperationException.class)
105 public void testRangeQuery1() {
106 super.testRangeQuery1();
107 }
108
109 @Override
110 @Test(expected = UnsupportedOperationException.class)
111 public void testRangeQuery2() {
112 super.testRangeQuery2();
113 }
114
115 @Override
116 @Test(expected = UnsupportedOperationException.class)
117 public void testRangeQuery3() {
118 super.testRangeQuery3();
119 }
120
121 @Override
122 @Test(expected = UnsupportedOperationException.class)
123 public void testSingleQueryInvalidTime1() throws TimeRangeException {
124 super.testSingleQueryInvalidTime1();
125 }
126
127 @Override
128 @Test(expected = UnsupportedOperationException.class)
129 public void testSingleQueryInvalidTime2() throws TimeRangeException {
130 super.testSingleQueryInvalidTime2();
131 }
132
133 @Override
134 @Test(expected = UnsupportedOperationException.class)
135 public void testRangeQueryInvalidTime1() throws TimeRangeException {
136 super.testRangeQueryInvalidTime1();
137 }
138
139 @Override
140 @Test(expected = UnsupportedOperationException.class)
141 public void testRangeQueryInvalidTime2() throws TimeRangeException {
142 super.testRangeQueryInvalidTime2();
143 }
144
145 @NonNullByDefault
146 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
147
148 private final String htFileName;
149
150 /**
151 * Constructor adding the views to the analysis
152 * @param htFileName
153 * The History File Name
154 */
155 public TestLttngKernelAnalysisModule(String htFileName) {
156 super();
157 this.htFileName = htFileName;
158 }
159
160 @Override
161 public void setTrace(@Nullable ITmfTrace trace) throws TmfAnalysisException {
162 if (!(trace instanceof CtfTmfTrace)) {
163 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
164 }
165 super.setTrace(trace);
166 }
167
168 @Override
169 protected ITmfStateProvider createStateProvider() {
170 return new LttngKernelStateProvider(getTrace());
171 }
172
173 @Override
174 protected StateSystemBackendType getBackendType() {
175 return StateSystemBackendType.PARTIAL;
176 }
177
178 @Override
179 protected String getSsFileName() {
180 return htFileName;
181 }
182
183 }
184 }
This page took 0.0393250000000001 seconds and 6 git commands to generate.