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
.kernelanalysis
.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
.trace
.CtfTmfTrace
;
29 import org
.junit
.AfterClass
;
30 import org
.junit
.BeforeClass
;
31 import org
.junit
.Ignore
;
32 import org
.junit
.Test
;
35 * State system tests using a partial history.
37 * @author Alexandre Montplaisir
40 public class PartialStateSystemTest
extends StateSystemTest
{
42 private static final @NonNull String TEST_FILE_NAME
= "test-partial";
44 private static File stateFile
;
45 private static TestLttngKernelAnalysisModule module
;
51 public static void initialize() {
52 if (!testTrace
.exists()) {
53 traceIsPresent
= false;
56 traceIsPresent
= true;
58 stateFile
= new File(TmfTraceManager
.getSupplementaryFileDir(testTrace
.getTrace()) + TEST_FILE_NAME
);
59 if (stateFile
.exists()) {
63 module
= new TestLttngKernelAnalysisModule(TEST_FILE_NAME
);
65 assertTrue(module
.setTrace(testTrace
.getTrace()));
66 } catch (TmfAnalysisException e
) {
70 assertTrue(module
.waitForCompletion());
72 fixture
= module
.getStateSystem();
79 public static void cleanup() {
83 if (stateFile
!= null) {
86 if (fixture
!= null) {
94 * Partial histories cannot get the intervals' end times. The fake value that
95 * is returned is equal to the query's timestamp. So override this here
96 * so that {@link #testFullQueryThorough} keeps working.
99 protected long getEndTimes(int idx
) {
100 return interestingTimestamp1
;
103 // ------------------------------------------------------------------------
104 // Skip tests using single-queries (unsupported in partial history)
105 // ------------------------------------------------------------------------
108 @Test(expected
= UnsupportedOperationException
.class)
109 public void testSingleQuery1() {
110 super.testSingleQuery1();
114 @Test(expected
= UnsupportedOperationException
.class)
115 public void testRangeQuery1() {
116 super.testRangeQuery1();
120 @Test(expected
= UnsupportedOperationException
.class)
121 public void testRangeQuery2() {
122 super.testRangeQuery2();
126 @Test(expected
= UnsupportedOperationException
.class)
127 public void testRangeQuery3() {
128 super.testRangeQuery3();
132 @Test(expected
= UnsupportedOperationException
.class)
133 public void testSingleQueryInvalidTime1() throws TimeRangeException
{
134 super.testSingleQueryInvalidTime1();
138 @Test(expected
= UnsupportedOperationException
.class)
139 public void testSingleQueryInvalidTime2() throws TimeRangeException
{
140 super.testSingleQueryInvalidTime2();
144 @Test(expected
= UnsupportedOperationException
.class)
145 public void testRangeQueryInvalidTime1() throws TimeRangeException
{
146 super.testRangeQueryInvalidTime1();
150 @Test(expected
= UnsupportedOperationException
.class)
151 public void testRangeQueryInvalidTime2() throws TimeRangeException
{
152 super.testRangeQueryInvalidTime2();
156 private static class TestLttngKernelAnalysisModule
extends KernelAnalysisModule
{
158 private final String htFileName
;
161 * Constructor adding the views to the analysis
163 * The History File Name
165 public TestLttngKernelAnalysisModule(String htFileName
) {
167 this.htFileName
= htFileName
;
171 public boolean setTrace(@Nullable ITmfTrace trace
) throws TmfAnalysisException
{
172 if (!(trace
instanceof CtfTmfTrace
)) {
175 return super.setTrace(trace
);
179 protected StateSystemBackendType
getBackendType() {
180 return StateSystemBackendType
.PARTIAL
;
184 protected String
getSsFileName() {