tmf: Split the state system in a separate plugin
[deliverable/tracecompass.git] / org.eclipse.linuxtools.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
BH
15import static org.junit.Assert.assertNotNull;
16import static org.junit.Assert.assertTrue;
947504fa 17import static org.junit.Assert.fail;
1b9d3765
AM
18import static org.junit.Assume.assumeTrue;
19
20import java.io.File;
1b9d3765 21
d3ba47d4 22import org.eclipse.linuxtools.internal.lttng2.kernel.core.stateprovider.LttngKernelStateProvider;
bcec0116 23import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException;
6a769f6a
BH
24import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
25import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
26import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
27import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
28import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
91e7f946 29import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
947504fa 30import org.junit.AfterClass;
1b9d3765
AM
31import org.junit.BeforeClass;
32import org.junit.Test;
33
34/**
35 * State system tests using a partial history.
36 *
37 * @author Alexandre Montplaisir
38 */
39public class PartialStateSystemTest extends StateSystemTest {
40
947504fa 41 private static File stateFile;
6a769f6a
BH
42 private static final String TEST_FILE_NAME = "test-partial";
43
947504fa 44
1b9d3765
AM
45 /**
46 * Initialization
47 */
48 @BeforeClass
49 public static void initialize() {
9ac63b5b 50 assumeTrue(testTrace.exists());
6a769f6a
BH
51 stateFile = new File(TmfTraceManager.getSupplementaryFileDir(testTrace.getTrace()) + TEST_FILE_NAME);
52 if (stateFile.exists()) {
53 stateFile.delete();
54 }
1b9d3765 55
6a769f6a
BH
56 TestLttngKernelAnalysisModule module = new TestLttngKernelAnalysisModule(TEST_FILE_NAME);
57 try {
58 module.setTrace(testTrace.getTrace());
59 } catch (TmfAnalysisException e) {
947504fa 60 fail();
1b9d3765 61 }
6a769f6a 62 module.schedule();
7d6122fc 63 assertTrue(module.waitForCompletion());
6a769f6a
BH
64 ssq = module.getStateSystem();
65
66 assertNotNull(ssq);
1b9d3765
AM
67 }
68
947504fa
AM
69 /**
70 * Class clean-up
71 */
72 @AfterClass
73 public static void tearDownClass() {
74 stateFile.delete();
75 }
76
1b9d3765
AM
77 /**
78 * Partial histories cannot get the intervals' end times. The fake value that
79 * is returned is equal to the query's timestamp. So override this here
80 * so that {@link #testFullQueryThorough} keeps working.
81 */
82 @Override
83 protected long getEndTimes(int idx) {
84 return interestingTimestamp1;
85 }
86
87 // ------------------------------------------------------------------------
88 // Skip tests using single-queries (unsupported in partial history)
89 // ------------------------------------------------------------------------
90
91 @Override
92 @Test(expected = UnsupportedOperationException.class)
93 public void testSingleQuery1() {
94 super.testSingleQuery1();
95 }
96
97 @Override
98 @Test(expected = UnsupportedOperationException.class)
99 public void testRangeQuery1() {
100 super.testRangeQuery1();
101 }
102
103 @Override
104 @Test(expected = UnsupportedOperationException.class)
105 public void testRangeQuery2() {
106 super.testRangeQuery2();
107 }
108
109 @Override
110 @Test(expected = UnsupportedOperationException.class)
111 public void testRangeQuery3() {
112 super.testRangeQuery3();
113 }
114
115 @Override
116 @Test(expected = UnsupportedOperationException.class)
117 public void testSingleQueryInvalidTime1() throws TimeRangeException {
118 super.testSingleQueryInvalidTime1();
119 }
120
121 @Override
122 @Test(expected = UnsupportedOperationException.class)
123 public void testSingleQueryInvalidTime2() throws TimeRangeException {
124 super.testSingleQueryInvalidTime2();
125 }
126
127 @Override
128 @Test(expected = UnsupportedOperationException.class)
129 public void testRangeQueryInvalidTime1() throws TimeRangeException {
130 super.testRangeQueryInvalidTime1();
131 }
132
133 @Override
134 @Test(expected = UnsupportedOperationException.class)
135 public void testRangeQueryInvalidTime2() throws TimeRangeException {
136 super.testRangeQueryInvalidTime2();
137 }
6a769f6a
BH
138
139 private static class TestLttngKernelAnalysisModule extends TmfStateSystemAnalysisModule {
140
141 private final String htFileName;
142
143 /**
144 * Constructor adding the views to the analysis
145 * @param htFileName
146 * The History File Name
147 */
148 public TestLttngKernelAnalysisModule(String htFileName) {
149 super();
150 this.htFileName = htFileName;
151 }
152
153 @Override
154 public void setTrace(ITmfTrace trace) throws TmfAnalysisException {
155 if (!(trace instanceof CtfTmfTrace)) {
156 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
157 }
158 super.setTrace(trace);
159 }
160
161 @Override
162 protected ITmfStateProvider createStateProvider() {
163 return new LttngKernelStateProvider((CtfTmfTrace) getTrace());
164 }
165
166 @Override
167 protected StateSystemBackendType getBackendType() {
168 return StateSystemBackendType.PARTIAL;
169 }
170
171 @Override
172 protected String getSsFileName() {
173 return htFileName;
174 }
175
176 }
1b9d3765 177}
This page took 0.0547339999999999 seconds and 5 git commands to generate.