Commit | Line | Data |
---|---|---|
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 | ||
9bc60be7 | 13 | package org.eclipse.tracecompass.lttng2.kernel.core.tests.stateprovider; |
1b9d3765 | 14 | |
6a769f6a | 15 | import static org.junit.Assert.assertTrue; |
947504fa | 16 | import static org.junit.Assert.fail; |
1b9d3765 AM |
17 | |
18 | import java.io.File; | |
1b9d3765 | 19 | |
c1831960 AM |
20 | import org.eclipse.jdt.annotation.NonNull; |
21 | import org.eclipse.jdt.annotation.NonNullByDefault; | |
22 | import org.eclipse.jdt.annotation.Nullable; | |
9bc60be7 | 23 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider; |
e894a508 AM |
24 | import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; |
25 | import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; | |
2bdf0193 AM |
26 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; |
27 | import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; | |
28 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
29 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | |
30 | import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; | |
31 | import org.eclipse.tracecompass.tmf.ctf.core.CtfTmfTrace; | |
58ba027e | 32 | import org.junit.After; |
1b9d3765 AM |
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 | ||
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) { | |
03f0b0b1 | 71 | module.dispose(); |
edbdb7ea AM |
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 | } |