lttng: Enable null-checking in test plugins
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core.tests / src / org / eclipse / linuxtools / lttng2 / kernel / core / tests / stateprovider / 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
13package org.eclipse.linuxtools.lttng2.kernel.core.tests.stateprovider;
14
6a769f6a
BH
15import static org.junit.Assert.assertNotNull;
16import static org.junit.Assert.assertTrue;
947504fa 17import static org.junit.Assert.fail;
1b9d3765
AM
18import static org.junit.Assume.assumeTrue;
19
20import java.io.File;
1b9d3765 21
c1831960
AM
22import org.eclipse.jdt.annotation.NonNull;
23import org.eclipse.jdt.annotation.NonNullByDefault;
24import org.eclipse.jdt.annotation.Nullable;
d3ba47d4 25import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
bcec0116 26import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
6a769f6a
BH
27import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
28import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
29import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
30import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
31import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
91e7f946 32import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
947504fa 33import org.junit.AfterClass;
1b9d3765
AM
34import org.junit.BeforeClass;
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
bd64ee73
AM
46 private static File stateFile;
47 private static TestLttngKernelAnalysisModule module;
48
947504fa 49
1b9d3765
AM
50 /**
51 * Initialization
52 */
53 @BeforeClass
54 public static void initialize() {
9ac63b5b 55 assumeTrue(testTrace.exists());
6a769f6a
BH
56 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
57 if (stateFile.exists()) {
58 stateFile.delete();
59 }
1b9d3765 60
bd64ee73 61 module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
6a769f6a
BH
62 try {
63 module.setTrace(testTrace.getTrace());
64 } catch (TmfAnalysisException e) {
947504fa 65 fail();
1b9d3765 66 }
6a769f6a 67 module.schedule();
7d6122fc 68 assertTrue(module.waitForCompletion());
6a769f6a
BH
69 ssq = module.getStateSystem();
70
71 assertNotNull(ssq);
1b9d3765
AM
72 }
73
947504fa
AM
74 /**
75 * Class clean-up
76 */
77 @AfterClass
78 public static void tearDownClass() {
bd64ee73 79 module.close();
947504fa
AM
80 stateFile.delete();
81 }
82
1b9d3765
AM
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 }
6a769f6a 144
c1831960 145 @NonNullByDefault
6a769f6a
BH
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
c1831960 161 public void setTrace(@Nullable ITmfTrace trace) throws TmfAnalysisException {
6a769f6a
BH
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() {
1887c91b 170 return new LttngKernelStateProvider(getTrace());
6a769f6a
BH
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 }
1b9d3765 184}
This page took 0.044018 seconds and 5 git commands to generate.