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
9 * Alexandre Montplaisir - Initial API and implementation
10 * Bernd Hufmann - Use state system analysis module instead of factory
11 ******************************************************************************/
13 package org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.analysis
.kernel
.statesystem
;
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
.tracecompass
.analysis
.os
.linux
.core
.kernel
.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
.tests
.shared
.CtfTmfTestTraceUtils
;
29 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
30 import org
.junit
.AfterClass
;
31 import org
.junit
.BeforeClass
;
32 import org
.junit
.Ignore
;
33 import org
.junit
.Test
;
36 * State system tests using a partial history.
38 * @author Alexandre Montplaisir
41 public class PartialStateSystemTest
extends StateSystemTest
{
43 private static final @NonNull String TEST_FILE_NAME
= "test-partial";
45 private static CtfTmfTrace trace
;
46 private static File stateFile
;
47 private static TestLttngKernelAnalysisModule module
;
53 public static void initialize() {
54 trace
= CtfTmfTestTraceUtils
.getTrace(testTrace
);
56 stateFile
= new File(TmfTraceManager
.getSupplementaryFileDir(trace
) + TEST_FILE_NAME
);
57 if (stateFile
.exists()) {
61 module
= new TestLttngKernelAnalysisModule(TEST_FILE_NAME
);
63 assertTrue(module
.setTrace(trace
));
64 } catch (TmfAnalysisException e
) {
68 assertTrue(module
.waitForCompletion());
70 fixture
= module
.getStateSystem();
77 public static void cleanup() {
81 if (stateFile
!= null) {
84 if (fixture
!= null) {
96 * Partial histories cannot get the intervals' end times. The fake value that
97 * is returned is equal to the query's timestamp. So override this here
98 * so that {@link #testFullQueryThorough} keeps working.
101 protected long getEndTimes(int idx
) {
102 return interestingTimestamp1
;
105 // ------------------------------------------------------------------------
106 // Skip tests using single-queries (unsupported in partial history)
107 // ------------------------------------------------------------------------
110 @Test(expected
= UnsupportedOperationException
.class)
111 public void testSingleQuery1() {
112 super.testSingleQuery1();
116 @Test(expected
= UnsupportedOperationException
.class)
117 public void testRangeQuery1() {
118 super.testRangeQuery1();
122 @Test(expected
= UnsupportedOperationException
.class)
123 public void testRangeQuery2() {
124 super.testRangeQuery2();
128 @Test(expected
= UnsupportedOperationException
.class)
129 public void testRangeQuery3() {
130 super.testRangeQuery3();
134 @Test(expected
= UnsupportedOperationException
.class)
135 public void testSingleQueryInvalidTime1() throws TimeRangeException
{
136 super.testSingleQueryInvalidTime1();
140 @Test(expected
= UnsupportedOperationException
.class)
141 public void testSingleQueryInvalidTime2() throws TimeRangeException
{
142 super.testSingleQueryInvalidTime2();
146 @Test(expected
= UnsupportedOperationException
.class)
147 public void testRangeQueryInvalidTime1() throws TimeRangeException
{
148 super.testRangeQueryInvalidTime1();
152 @Test(expected
= UnsupportedOperationException
.class)
153 public void testRangeQueryInvalidTime2() throws TimeRangeException
{
154 super.testRangeQueryInvalidTime2();
158 private static class TestLttngKernelAnalysisModule
extends KernelAnalysisModule
{
160 private final String htFileName
;
163 * Constructor adding the views to the analysis
165 * The History File Name
167 public TestLttngKernelAnalysisModule(String htFileName
) {
169 this.htFileName
= htFileName
;
173 public boolean setTrace(@Nullable ITmfTrace trace
) throws TmfAnalysisException
{
174 if (!(trace
instanceof CtfTmfTrace
)) {
177 return super.setTrace(trace
);
181 protected StateSystemBackendType
getBackendType() {
182 return StateSystemBackendType
.PARTIAL
;
186 protected String
getSsFileName() {