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
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 15import static org.junit.Assert.assertTrue;
947504fa 16import static org.junit.Assert.fail;
1b9d3765
AM
17
18import java.io.File;
1b9d3765 19
c1831960
AM
20import org.eclipse.jdt.annotation.NonNull;
21import org.eclipse.jdt.annotation.NonNullByDefault;
22import org.eclipse.jdt.annotation.Nullable;
d3ba47d4 23import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
edbdb7ea 24import org.eclipse.linuxtools.statesystem.core.ITmfStateSystem;
bcec0116 25import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
6a769f6a
BH
26import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
27import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
28import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
29import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
30import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
91e7f946 31import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
58ba027e 32import org.junit.After;
1b9d3765
AM
33import org.junit.Test;
34
35/**
36 * State system tests using a partial history.
37 *
38 * @author Alexandre Montplaisir
39 */
40public class PartialStateSystemTest extends StateSystemTest {
41
c1831960 42 private static final @NonNull String TEST_FILE_NAME = "test-partial";
6a769f6a 43
58ba027e
AM
44 private File stateFile;
45 private TestLttngKernelAnalysisModule module;
bd64ee73 46
edbdb7ea
AM
47 @Override
48 protected ITmfStateSystem initialize() {
6a769f6a
BH
49 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
50 if (stateFile.exists()) {
51 stateFile.delete();
52 }
1b9d3765 53
bd64ee73 54 module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
6a769f6a
BH
55 try {
56 module.setTrace(testTrace.getTrace());
57 } catch (TmfAnalysisException e) {
947504fa 58 fail();
1b9d3765 59 }
6a769f6a 60 module.schedule();
7d6122fc 61 assertTrue(module.waitForCompletion());
edbdb7ea 62 return module.getStateSystem();
1b9d3765
AM
63 }
64
947504fa
AM
65 /**
66 * Class clean-up
67 */
58ba027e 68 @After
edbdb7ea
AM
69 public void cleanup() {
70 if (module != null) {
71 module.close();
72 }
73 if (stateFile != null) {
74 stateFile.delete();
75 }
947504fa
AM
76 }
77
1b9d3765
AM
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 }
6a769f6a 139
c1831960 140 @NonNullByDefault
6a769f6a
BH
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
c1831960 156 public void setTrace(@Nullable ITmfTrace trace) throws TmfAnalysisException {
6a769f6a
BH
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() {
1887c91b 165 return new LttngKernelStateProvider(getTrace());
6a769f6a
BH
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 }
1b9d3765 179}
This page took 0.04788 seconds and 5 git commands to generate.