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