8aaa4cabc736e41395c3eb495eabe8a3be8269ad
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.core.tests / src / org / eclipse / tracecompass / lttng2 / kernel / core / tests / analysis / kernel / statesystem / PartialStateSystemTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 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.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;
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.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
24 import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
25 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
26 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
27 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
28 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
29 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
30 import org.junit.AfterClass;
31 import org.junit.BeforeClass;
32 import org.junit.Ignore;
33 import org.junit.Test;
34
35 /**
36 * State system tests using a partial history.
37 *
38 * @author Alexandre Montplaisir
39 */
40 @Ignore
41 public class PartialStateSystemTest extends StateSystemTest {
42
43 private static final @NonNull String TEST_FILE_NAME = "test-partial";
44
45 private static CtfTmfTrace trace;
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 trace = CtfTmfTestTraceUtils.getTrace(testTrace);
55
56 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(trace) + TEST_FILE_NAME);
57 if (stateFile.exists()) {
58 stateFile.delete();
59 }
60
61 module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
62 try {
63 assertTrue(module.setTrace(trace));
64 } catch (TmfAnalysisException e) {
65 fail();
66 }
67 module.schedule();
68 assertTrue(module.waitForCompletion());
69
70 fixture = module.getStateSystem();
71 }
72
73 /**
74 * Class clean-up
75 */
76 @AfterClass
77 public static void cleanup() {
78 if (module != null) {
79 module.dispose();
80 }
81 if (stateFile != null) {
82 stateFile.delete();
83 }
84 if (fixture != null) {
85 fixture.dispose();
86 }
87 if (trace != null) {
88 trace.dispose();
89 }
90 module = null;
91 fixture = null;
92 trace = null;
93 }
94
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 }
156
157 @NonNullByDefault
158 private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
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
173 public boolean setTrace(@Nullable ITmfTrace trace) throws TmfAnalysisException {
174 if (!(trace instanceof CtfTmfTrace)) {
175 return false;
176 }
177 return super.setTrace(trace);
178 }
179
180 @Override
181 protected StateSystemBackendType getBackendType() {
182 return StateSystemBackendType.PARTIAL;
183 }
184
185 @Override
186 protected String getSsFileName() {
187 return htFileName;
188 }
189
190 }
191 }
This page took 0.080886 seconds and 4 git commands to generate.