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
.linuxtools
.internal
.lttng2
.kernel
.core
.stateprovider
.LttngKernelStateProvider
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TimeRangeException
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfAnalysisException
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateProvider
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
29 import org
.eclipse
.linuxtools
.tmf
.ctf
.core
.CtfTmfTrace
;
30 import org
.junit
.AfterClass
;
31 import org
.junit
.BeforeClass
;
32 import org
.junit
.Test
;
35 * State system tests using a partial history.
37 * @author Alexandre Montplaisir
39 public class PartialStateSystemTest
extends StateSystemTest
{
41 private static File stateFile
;
42 private static final String TEST_FILE_NAME
= "test-partial";
49 public static void initialize() {
50 assumeTrue(testTrace
.exists());
51 stateFile
= new File(TmfTraceManager
.getSupplementaryFileDir(testTrace
.getTrace()) + TEST_FILE_NAME
);
52 if (stateFile
.exists()) {
56 TestLttngKernelAnalysisModule module
= new TestLttngKernelAnalysisModule(TEST_FILE_NAME
);
58 module
.setTrace(testTrace
.getTrace());
59 } catch (TmfAnalysisException e
) {
63 assertTrue(module
.waitForCompletion());
64 ssq
= module
.getStateSystem();
73 public static void tearDownClass() {
78 * Partial histories cannot get the intervals' end times. The fake value that
79 * is returned is equal to the query's timestamp. So override this here
80 * so that {@link #testFullQueryThorough} keeps working.
83 protected long getEndTimes(int idx
) {
84 return interestingTimestamp1
;
87 // ------------------------------------------------------------------------
88 // Skip tests using single-queries (unsupported in partial history)
89 // ------------------------------------------------------------------------
92 @Test(expected
= UnsupportedOperationException
.class)
93 public void testSingleQuery1() {
94 super.testSingleQuery1();
98 @Test(expected
= UnsupportedOperationException
.class)
99 public void testRangeQuery1() {
100 super.testRangeQuery1();
104 @Test(expected
= UnsupportedOperationException
.class)
105 public void testRangeQuery2() {
106 super.testRangeQuery2();
110 @Test(expected
= UnsupportedOperationException
.class)
111 public void testRangeQuery3() {
112 super.testRangeQuery3();
116 @Test(expected
= UnsupportedOperationException
.class)
117 public void testSingleQueryInvalidTime1() throws TimeRangeException
{
118 super.testSingleQueryInvalidTime1();
122 @Test(expected
= UnsupportedOperationException
.class)
123 public void testSingleQueryInvalidTime2() throws TimeRangeException
{
124 super.testSingleQueryInvalidTime2();
128 @Test(expected
= UnsupportedOperationException
.class)
129 public void testRangeQueryInvalidTime1() throws TimeRangeException
{
130 super.testRangeQueryInvalidTime1();
134 @Test(expected
= UnsupportedOperationException
.class)
135 public void testRangeQueryInvalidTime2() throws TimeRangeException
{
136 super.testRangeQueryInvalidTime2();
139 private static class TestLttngKernelAnalysisModule
extends TmfStateSystemAnalysisModule
{
141 private final String htFileName
;
144 * Constructor adding the views to the analysis
146 * The History File Name
148 public TestLttngKernelAnalysisModule(String htFileName
) {
150 this.htFileName
= htFileName
;
154 public void setTrace(ITmfTrace trace
) throws TmfAnalysisException
{
155 if (!(trace
instanceof CtfTmfTrace
)) {
156 throw new IllegalStateException("TestLttngKernelAnalysisModule: trace should be of type CtfTmfTrace"); //$NON-NLS-1$
158 super.setTrace(trace
);
162 protected ITmfStateProvider
createStateProvider() {
163 return new LttngKernelStateProvider((CtfTmfTrace
) getTrace());
167 protected StateSystemBackendType
getBackendType() {
168 return StateSystemBackendType
.PARTIAL
;
172 protected String
getSsFileName() {