7dfbae841e072e5c0233ee093ff83758731cb9cd
[deliverable/tracecompass.git] / 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.trace.CtfTmfTrace;
29 import org.junit.AfterClass;
30 import org.junit.BeforeClass;
31 import org.junit.Ignore;
32 import org.junit.Test;
33
34 /**
35 * State system tests using a partial history.
36 *
37 * @author Alexandre Montplaisir
38 */
39 @Ignore
40 public class PartialStateSystemTest extends StateSystemTest {
41
42 private static final @NonNull String TEST_FILE_NAME = "test-partial";
43
44 private static File stateFile;
45 private static TestLttngKernelAnalysisModule module;
46
47 /**
48 * Test class setup
49 */
50 @BeforeClass
51 public static void initialize() {
52 if (!testTrace.exists()) {
53 traceIsPresent = false;
54 return;
55 }
56 traceIsPresent = true;
57
58 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
59 if (stateFile.exists()) {
60 stateFile.delete();
61 }
62
63 module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
64 try {
65 assertTrue(module.setTrace(testTrace.getTrace()));
66 } catch (TmfAnalysisException e) {
67 fail();
68 }
69 module.schedule();
70 assertTrue(module.waitForCompletion());
71
72 fixture = module.getStateSystem();
73 }
74
75 /**
76 * Class clean-up
77 */
78 @AfterClass
79 public static void cleanup() {
80 if (module != null) {
81 module.dispose();
82 }
83 if (stateFile != null) {
84 stateFile.delete();
85 }
86 if (fixture != null) {
87 fixture.dispose();
88 }
89 module = null;
90 fixture = null;
91 }
92
93 /**
94 * Partial histories cannot get the intervals' end times. The fake value that
95 * is returned is equal to the query's timestamp. So override this here
96 * so that {@link #testFullQueryThorough} keeps working.
97 */
98 @Override
99 protected long getEndTimes(int idx) {
100 return interestingTimestamp1;
101 }
102
103 // ------------------------------------------------------------------------
104 // Skip tests using single-queries (unsupported in partial history)
105 // ------------------------------------------------------------------------
106
107 @Override
108 @Test(expected = UnsupportedOperationException.class)
109 public void testSingleQuery1() {
110 super.testSingleQuery1();
111 }
112
113 @Override
114 @Test(expected = UnsupportedOperationException.class)
115 public void testRangeQuery1() {
116 super.testRangeQuery1();
117 }
118
119 @Override
120 @Test(expected = UnsupportedOperationException.class)
121 public void testRangeQuery2() {
122 super.testRangeQuery2();
123 }
124
125 @Override
126 @Test(expected = UnsupportedOperationException.class)
127 public void testRangeQuery3() {
128 super.testRangeQuery3();
129 }
130
131 @Override
132 @Test(expected = UnsupportedOperationException.class)
133 public void testSingleQueryInvalidTime1() throws TimeRangeException {
134 super.testSingleQueryInvalidTime1();
135 }
136
137 @Override
138 @Test(expected = UnsupportedOperationException.class)
139 public void testSingleQueryInvalidTime2() throws TimeRangeException {
140 super.testSingleQueryInvalidTime2();
141 }
142
143 @Override
144 @Test(expected = UnsupportedOperationException.class)
145 public void testRangeQueryInvalidTime1() throws TimeRangeException {
146 super.testRangeQueryInvalidTime1();
147 }
148
149 @Override
150 @Test(expected = UnsupportedOperationException.class)
151 public void testRangeQueryInvalidTime2() throws TimeRangeException {
152 super.testRangeQueryInvalidTime2();
153 }
154
155 @NonNullByDefault
156 private static class TestLttngKernelAnalysisModule extends KernelAnalysisModule {
157
158 private final String htFileName;
159
160 /**
161 * Constructor adding the views to the analysis
162 * @param htFileName
163 * The History File Name
164 */
165 public TestLttngKernelAnalysisModule(String htFileName) {
166 super();
167 this.htFileName = htFileName;
168 }
169
170 @Override
171 public boolean setTrace(@Nullable ITmfTrace trace) throws TmfAnalysisException {
172 if (!(trace instanceof CtfTmfTrace)) {
173 return false;
174 }
175 return super.setTrace(trace);
176 }
177
178 @Override
179 protected StateSystemBackendType getBackendType() {
180 return StateSystemBackendType.PARTIAL;
181 }
182
183 @Override
184 protected String getSsFileName() {
185 return htFileName;
186 }
187
188 }
189 }
This page took 0.047321 seconds and 4 git commands to generate.