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
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
16 import static org
.junit
.Assert
.assertTrue
;
17 import static org
.junit
.Assert
.fail
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
23 import org
.eclipse
.jdt
.annotation
.Nullable
;
24 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernelanalysis
.KernelStateProvider
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.kernel
.core
.trace
.layout
.LttngEventLayout
;
26 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.TimeRangeException
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
32 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
33 import org
.junit
.AfterClass
;
34 import org
.junit
.BeforeClass
;
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 static File stateFile
;
47 private static TestLttngKernelAnalysisModule module
;
53 public static void initialize() {
54 if (!testTrace
.exists()) {
55 traceIsPresent
= false;
58 traceIsPresent
= true;
60 stateFile
= new File(TmfTraceManager
.getSupplementaryFileDir(testTrace
.getTrace()) + TEST_FILE_NAME
);
61 if (stateFile
.exists()) {
65 module
= new TestLttngKernelAnalysisModule(TEST_FILE_NAME
);
67 assertTrue(module
.setTrace(testTrace
.getTrace()));
68 } catch (TmfAnalysisException e
) {
72 assertTrue(module
.waitForCompletion());
74 fixture
= module
.getStateSystem();
81 public static void cleanup() {
85 if (stateFile
!= null) {
88 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 TmfStateSystemAnalysisModule
{
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 ITmfStateProvider
createStateProvider() {
182 return new KernelStateProvider(checkNotNull(getTrace()), LttngEventLayout
.getInstance());
186 protected StateSystemBackendType
getBackendType() {
187 return StateSystemBackendType
.PARTIAL
;
191 protected String
getSsFileName() {