tmf: Null-annotate state system API classes
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / analysis / kernel / statesystem / PartialStateSystemTest.java
CommitLineData
1b9d3765 1/*******************************************************************************
60ae41e1 2 * Copyright (c) 2013, 2014 Ericsson
1b9d3765
AM
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
6a769f6a 10 * Bernd Hufmann - Use state system analysis module instead of factory
1b9d3765
AM
11 ******************************************************************************/
12
42d5b5f2 13package org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
1b9d3765 14
d0c7e4ba 15import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
6a769f6a 16import static org.junit.Assert.assertTrue;
947504fa 17import static org.junit.Assert.fail;
1b9d3765
AM
18
19import java.io.File;
1b9d3765 20
c1831960
AM
21import org.eclipse.jdt.annotation.NonNull;
22import org.eclipse.jdt.annotation.NonNullByDefault;
23import org.eclipse.jdt.annotation.Nullable;
7411cd67 24import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
42d5b5f2 25import org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel.LttngKernelStateProvider;
e894a508 26import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
2bdf0193
AM
27import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
28import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
29import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
30import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
31import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
9722e5d7 32import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
392bf486
AM
33import org.junit.AfterClass;
34import org.junit.BeforeClass;
1b9d3765
AM
35import org.junit.Test;
36
37/**
38 * State system tests using a partial history.
39 *
40 * @author Alexandre Montplaisir
41 */
42public class PartialStateSystemTest extends StateSystemTest {
43
c1831960 44 private static final @NonNull String TEST_FILE_NAME = "test-partial";
6a769f6a 45
392bf486
AM
46 private static File stateFile;
47 private static TestLttngKernelAnalysisModule module;
48
49 /**
50 * Test class setup
51 */
52 @BeforeClass
53 public static void initialize() {
54 if (!testTrace.exists()) {
55 traceIsPresent = false;
56 return;
57 }
58 traceIsPresent = true;
bd64ee73 59
6a769f6a
BH
60 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
61 if (stateFile.exists()) {
62 stateFile.delete();
63 }
1b9d3765 64
bd64ee73 65 module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
6a769f6a
BH
66 try {
67 module.setTrace(testTrace.getTrace());
68 } catch (TmfAnalysisException e) {
947504fa 69 fail();
1b9d3765 70 }
6a769f6a 71 module.schedule();
7d6122fc 72 assertTrue(module.waitForCompletion());
392bf486
AM
73
74 fixture = module.getStateSystem();
1b9d3765
AM
75 }
76
947504fa
AM
77 /**
78 * Class clean-up
79 */
392bf486
AM
80 @AfterClass
81 public static void cleanup() {
edbdb7ea 82 if (module != null) {
03f0b0b1 83 module.dispose();
edbdb7ea
AM
84 }
85 if (stateFile != null) {
86 stateFile.delete();
87 }
392bf486
AM
88 if (fixture != null) {
89 fixture.dispose();
90 }
91 module = null;
92 fixture = null;
947504fa
AM
93 }
94
1b9d3765
AM
95 /**
96 * Partial histories cannot get the intervals' end times. The fake value that
97 * is returned is equal to the query's timestamp. So override this here
98 * so that {@link #testFullQueryThorough} keeps working.
99 */
100 @Override
101 protected long getEndTimes(int idx) {
102 return interestingTimestamp1;
103 }
104
105 // ------------------------------------------------------------------------
106 // Skip tests using single-queries (unsupported in partial history)
107 // ------------------------------------------------------------------------
108
109 @Override
110 @Test(expected = UnsupportedOperationException.class)
111 public void testSingleQuery1() {
112 super.testSingleQuery1();
113 }
114
115 @Override
116 @Test(expected = UnsupportedOperationException.class)
117 public void testRangeQuery1() {
118 super.testRangeQuery1();
119 }
120
121 @Override
122 @Test(expected = UnsupportedOperationException.class)
123 public void testRangeQuery2() {
124 super.testRangeQuery2();
125 }
126
127 @Override
128 @Test(expected = UnsupportedOperationException.class)
129 public void testRangeQuery3() {
130 super.testRangeQuery3();
131 }
132
133 @Override
134 @Test(expected = UnsupportedOperationException.class)
135 public void testSingleQueryInvalidTime1() throws TimeRangeException {
136 super.testSingleQueryInvalidTime1();
137 }
138
139 @Override
140 @Test(expected = UnsupportedOperationException.class)
141 public void testSingleQueryInvalidTime2() throws TimeRangeException {
142 super.testSingleQueryInvalidTime2();
143 }
144
145 @Override
146 @Test(expected = UnsupportedOperationException.class)
147 public void testRangeQueryInvalidTime1() throws TimeRangeException {
148 super.testRangeQueryInvalidTime1();
149 }
150
151 @Override
152 @Test(expected = UnsupportedOperationException.class)
153 public void testRangeQueryInvalidTime2() throws TimeRangeException {
154 super.testRangeQueryInvalidTime2();
155 }
6a769f6a 156
c1831960 157 @NonNullByDefault
6a769f6a
BH
158 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
159
160 private final String htFileName;
161
162 /**
163 * Constructor adding the views to the analysis
164 * @param htFileName
165 * The History File Name
166 */
167 public TestLttngKernelAnalysisModule(String htFileName) {
168 super();
169 this.htFileName = htFileName;
170 }
171
172 @Override
c1831960 173 public void setTrace(@Nullable ITmfTrace trace) throws TmfAnalysisException {
6a769f6a
BH
174 if (!(trace instanceof CtfTmfTrace)) {
175 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
176 }
177 super.setTrace(trace);
178 }
179
180 @Override
181 protected ITmfStateProvider createStateProvider() {
d0c7e4ba 182 return new LttngKernelStateProvider(checkNotNull(getTrace()), LttngEventLayout.getInstance());
6a769f6a
BH
183 }
184
185 @Override
186 protected StateSystemBackendType getBackendType() {
187 return StateSystemBackendType.PARTIAL;
188 }
189
190 @Override
191 protected String getSsFileName() {
192 return htFileName;
193 }
194
195 }
1b9d3765 196}
This page took 0.052274 seconds and 5 git commands to generate.