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