Commit | Line | Data |
---|---|---|
8a6ff07f | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2013, 2014 École Polytechnique de Montréal |
8a6ff07f GB |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Geneviève Bastien - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.core.tests.statesystem; |
8a6ff07f GB |
14 | |
15 | import static org.junit.Assert.assertNotNull; | |
16 | import static org.junit.Assert.assertNull; | |
17 | import static org.junit.Assert.fail; | |
18 | ||
e894a508 | 19 | import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; |
2bdf0193 AM |
20 | import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; |
21 | import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; | |
22 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
23 | import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; | |
24 | import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub; | |
8a6ff07f GB |
25 | import org.junit.After; |
26 | import org.junit.Before; | |
27 | import org.junit.Rule; | |
28 | import org.junit.Test; | |
29 | import org.junit.rules.TestRule; | |
30 | import org.junit.rules.Timeout; | |
31 | ||
32 | /** | |
33 | * Test the {@link TmfStateSystemAnalysisModule} class | |
34 | * | |
35 | * @author Geneviève Bastien | |
36 | */ | |
37 | public class StateSystemAnalysisModuleTest { | |
38 | ||
39 | /** Time-out tests after 20 seconds */ | |
40 | @Rule | |
41 | public TestRule globalTimeout= new Timeout(20000); | |
42 | ||
43 | /** ID of the test state system analysis module */ | |
44 | public static final String MODULE_SS = "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest"; | |
45 | ||
09ec275e | 46 | private TmfStateSystemAnalysisModule module; |
8a6ff07f GB |
47 | |
48 | /** | |
49 | * Setup test trace | |
50 | */ | |
51 | @Before | |
52 | public void setupTraces() { | |
09ec275e AM |
53 | TmfTraceStub trace = (TmfTraceStub) TmfTestTrace.A_TEST_10K.getTrace(); |
54 | TmfSignalManager.deregister(trace); | |
55 | trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null)); | |
56 | ||
57 | module = (TmfStateSystemAnalysisModule) trace.getAnalysisModule(MODULE_SS); | |
8a6ff07f GB |
58 | } |
59 | ||
60 | /** | |
61 | * Some tests use traces, let's clean them here | |
62 | */ | |
63 | @After | |
64 | public void cleanupTraces() { | |
65 | TmfTestTrace.A_TEST_10K.dispose(); | |
66 | } | |
67 | ||
68 | /** | |
69 | * Test the state system module execution and result | |
70 | */ | |
71 | @Test | |
72 | public void testSsModule() { | |
09ec275e | 73 | ITmfStateSystem ss = module.getStateSystem(); |
8a6ff07f GB |
74 | assertNull(ss); |
75 | module.schedule(); | |
7d6122fc | 76 | if (module.waitForCompletion()) { |
8a6ff07f GB |
77 | ss = module.getStateSystem(); |
78 | assertNotNull(ss); | |
79 | } else { | |
80 | fail("Module did not complete properly"); | |
81 | } | |
82 | } | |
83 | ||
09ec275e AM |
84 | /** |
85 | * Make sure that the state system is initialized after calling | |
86 | * {@link TmfStateSystemAnalysisModule#waitForInitialization()}. | |
87 | */ | |
88 | @Test | |
89 | public void testInitialization() { | |
90 | assertNull(module.getStateSystem()); | |
91 | module.schedule(); | |
92 | ||
93 | module.waitForInitialization(); | |
94 | assertNotNull(module.getStateSystem()); | |
95 | } | |
96 | ||
8a6ff07f | 97 | } |