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
.assertTrue
;
16 import static org
.junit
.Assert
.fail
;
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
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.LttngKernelStateProvider
;
24 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
25 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.TimeRangeException
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
31 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.CtfTmfTrace
;
32 import org
.junit
.After
;
33 import org
.junit
.Test
;
36 * State system tests using a partial history.
38 * @author Alexandre Montplaisir
40 public class PartialStateSystemTest
extends StateSystemTest
{
42 private static final @NonNull String TEST_FILE_NAME
= "test-partial";
44 private File stateFile
;
45 private TestLttngKernelAnalysisModule module
;
48 protected ITmfStateSystem
initialize() {
49 stateFile
= new File(TmfTraceManager
.getSupplementaryFileDir(testTrace
.getTrace()) + TEST_FILE_NAME
);
50 if (stateFile
.exists()) {
54 module
= new TestLttngKernelAnalysisModule(TEST_FILE_NAME
);
56 module
.setTrace(testTrace
.getTrace());
57 } catch (TmfAnalysisException e
) {
61 assertTrue(module
.waitForCompletion());
62 return module
.getStateSystem();
69 public void cleanup() {
73 if (stateFile
!= null) {
79 * Partial histories cannot get the intervals' end times. The fake value that
80 * is returned is equal to the query's timestamp. So override this here
81 * so that {@link #testFullQueryThorough} keeps working.
84 protected long getEndTimes(int idx
) {
85 return interestingTimestamp1
;
88 // ------------------------------------------------------------------------
89 // Skip tests using single-queries (unsupported in partial history)
90 // ------------------------------------------------------------------------
93 @Test(expected
= UnsupportedOperationException
.class)
94 public void testSingleQuery1() {
95 super.testSingleQuery1();
99 @Test(expected
= UnsupportedOperationException
.class)
100 public void testRangeQuery1() {
101 super.testRangeQuery1();
105 @Test(expected
= UnsupportedOperationException
.class)
106 public void testRangeQuery2() {
107 super.testRangeQuery2();
111 @Test(expected
= UnsupportedOperationException
.class)
112 public void testRangeQuery3() {
113 super.testRangeQuery3();
117 @Test(expected
= UnsupportedOperationException
.class)
118 public void testSingleQueryInvalidTime1() throws TimeRangeException
{
119 super.testSingleQueryInvalidTime1();
123 @Test(expected
= UnsupportedOperationException
.class)
124 public void testSingleQueryInvalidTime2() throws TimeRangeException
{
125 super.testSingleQueryInvalidTime2();
129 @Test(expected
= UnsupportedOperationException
.class)
130 public void testRangeQueryInvalidTime1() throws TimeRangeException
{
131 super.testRangeQueryInvalidTime1();
135 @Test(expected
= UnsupportedOperationException
.class)
136 public void testRangeQueryInvalidTime2() throws TimeRangeException
{
137 super.testRangeQueryInvalidTime2();
141 private static class TestLttngKernelAnalysisModule
extends TmfStateSystemAnalysisModule
{
143 private final String htFileName
;
146 * Constructor adding the views to the analysis
148 * The History File Name
150 public TestLttngKernelAnalysisModule(String htFileName
) {
152 this.htFileName
= htFileName
;
156 public void setTrace(@Nullable ITmfTrace trace
) throws TmfAnalysisException
{
157 if (!(trace
instanceof CtfTmfTrace
)) {
158 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
160 super.setTrace(trace
);
164 protected ITmfStateProvider
createStateProvider() {
165 return new LttngKernelStateProvider(getTrace());
169 protected StateSystemBackendType
getBackendType() {
170 return StateSystemBackendType
.PARTIAL
;
174 protected String
getSsFileName() {