1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 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
9 * Alexandre Montplaisir - Initial API and implementation
10 * Bernd Hufmann - Use state system analysis module instead of factory
11 ******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.tests
.stateprovider
;
15 import static org
.junit
.Assert
.assertNotNull
;
16 import static org
.junit
.Assert
.assertTrue
;
17 import static org
.junit
.Assert
.fail
;
18 import static org
.junit
.Assume
.assumeTrue
;
22 import org
.eclipse
.jdt
.annotation
.NonNull
;
23 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
24 import org
.eclipse
.jdt
.annotation
.Nullable
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.LttngKernelStateProvider
;
26 import org
.eclipse
.linuxtools
.statesystem
.core
.exceptions
.TimeRangeException
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfAnalysisException
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateProvider
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
30 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
31 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
32 import org
.eclipse
.linuxtools
.tmf
.ctf
.core
.CtfTmfTrace
;
33 import org
.junit
.After
;
34 import org
.junit
.Before
;
35 import org
.junit
.Test
;
38 * State system tests using a partial history.
40 * @author Alexandre Montplaisir
42 public class PartialStateSystemTest
extends StateSystemTest
{
44 private static final @NonNull String TEST_FILE_NAME
= "test-partial";
46 private File stateFile
;
47 private TestLttngKernelAnalysisModule module
;
54 public void initialize() {
55 assumeTrue(testTrace
.exists());
56 stateFile
= new File(TmfTraceManager
.getSupplementaryFileDir(testTrace
.getTrace()) + TEST_FILE_NAME
);
57 if (stateFile
.exists()) {
61 module
= new TestLttngKernelAnalysisModule(TEST_FILE_NAME
);
63 module
.setTrace(testTrace
.getTrace());
64 } catch (TmfAnalysisException e
) {
68 assertTrue(module
.waitForCompletion());
69 ssq
= module
.getStateSystem();
78 public void tearDownClass() {
84 * Partial histories cannot get the intervals' end times. The fake value that
85 * is returned is equal to the query's timestamp. So override this here
86 * so that {@link #testFullQueryThorough} keeps working.
89 protected long getEndTimes(int idx
) {
90 return interestingTimestamp1
;
93 // ------------------------------------------------------------------------
94 // Skip tests using single-queries (unsupported in partial history)
95 // ------------------------------------------------------------------------
98 @Test(expected
= UnsupportedOperationException
.class)
99 public void testSingleQuery1() {
100 super.testSingleQuery1();
104 @Test(expected
= UnsupportedOperationException
.class)
105 public void testRangeQuery1() {
106 super.testRangeQuery1();
110 @Test(expected
= UnsupportedOperationException
.class)
111 public void testRangeQuery2() {
112 super.testRangeQuery2();
116 @Test(expected
= UnsupportedOperationException
.class)
117 public void testRangeQuery3() {
118 super.testRangeQuery3();
122 @Test(expected
= UnsupportedOperationException
.class)
123 public void testSingleQueryInvalidTime1() throws TimeRangeException
{
124 super.testSingleQueryInvalidTime1();
128 @Test(expected
= UnsupportedOperationException
.class)
129 public void testSingleQueryInvalidTime2() throws TimeRangeException
{
130 super.testSingleQueryInvalidTime2();
134 @Test(expected
= UnsupportedOperationException
.class)
135 public void testRangeQueryInvalidTime1() throws TimeRangeException
{
136 super.testRangeQueryInvalidTime1();
140 @Test(expected
= UnsupportedOperationException
.class)
141 public void testRangeQueryInvalidTime2() throws TimeRangeException
{
142 super.testRangeQueryInvalidTime2();
146 private static class TestLttngKernelAnalysisModule
extends TmfStateSystemAnalysisModule
{
148 private final String htFileName
;
151 * Constructor adding the views to the analysis
153 * The History File Name
155 public TestLttngKernelAnalysisModule(String htFileName
) {
157 this.htFileName
= htFileName
;
161 public void setTrace(@Nullable ITmfTrace trace
) throws TmfAnalysisException
{
162 if (!(trace
instanceof CtfTmfTrace
)) {
163 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
165 super.setTrace(trace
);
169 protected ITmfStateProvider
createStateProvider() {
170 return new LttngKernelStateProvider(getTrace());
174 protected StateSystemBackendType
getBackendType() {
175 return StateSystemBackendType
.PARTIAL
;
179 protected String
getSsFileName() {