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 | ||
d291a715 MAL |
19 | import java.util.concurrent.TimeUnit; |
20 | ||
e894a508 | 21 | import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem; |
2bdf0193 AM |
22 | import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; |
23 | import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal; | |
24 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; | |
25 | import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace; | |
26 | import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub; | |
8a6ff07f GB |
27 | import org.junit.After; |
28 | import org.junit.Before; | |
29 | import org.junit.Rule; | |
30 | import org.junit.Test; | |
31 | import org.junit.rules.TestRule; | |
32 | import org.junit.rules.Timeout; | |
33 | ||
34 | /** | |
35 | * Test the {@link TmfStateSystemAnalysisModule} class | |
36 | * | |
37 | * @author Geneviève Bastien | |
38 | */ | |
39 | public class StateSystemAnalysisModuleTest { | |
40 | ||
41 | /** Time-out tests after 20 seconds */ | |
42 | @Rule | |
d291a715 | 43 | public TestRule globalTimeout= new Timeout(20, TimeUnit.SECONDS); |
8a6ff07f GB |
44 | |
45 | /** ID of the test state system analysis module */ | |
46 | public static final String MODULE_SS = "org.eclipse.linuxtools.tmf.core.tests.analysis.sstest"; | |
47 | ||
09ec275e | 48 | private TmfStateSystemAnalysisModule module; |
8a6ff07f GB |
49 | |
50 | /** | |
51 | * Setup test trace | |
52 | */ | |
53 | @Before | |
54 | public void setupTraces() { | |
09ec275e AM |
55 | TmfTraceStub trace = (TmfTraceStub) TmfTestTrace.A_TEST_10K.getTrace(); |
56 | TmfSignalManager.deregister(trace); | |
57 | trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null)); | |
58 | ||
59 | module = (TmfStateSystemAnalysisModule) trace.getAnalysisModule(MODULE_SS); | |
8a6ff07f GB |
60 | } |
61 | ||
62 | /** | |
63 | * Some tests use traces, let's clean them here | |
64 | */ | |
65 | @After | |
66 | public void cleanupTraces() { | |
67 | TmfTestTrace.A_TEST_10K.dispose(); | |
68 | } | |
69 | ||
70 | /** | |
71 | * Test the state system module execution and result | |
72 | */ | |
73 | @Test | |
74 | public void testSsModule() { | |
09ec275e | 75 | ITmfStateSystem ss = module.getStateSystem(); |
8a6ff07f GB |
76 | assertNull(ss); |
77 | module.schedule(); | |
7d6122fc | 78 | if (module.waitForCompletion()) { |
8a6ff07f GB |
79 | ss = module.getStateSystem(); |
80 | assertNotNull(ss); | |
81 | } else { | |
82 | fail("Module did not complete properly"); | |
83 | } | |
84 | } | |
85 | ||
09ec275e AM |
86 | /** |
87 | * Make sure that the state system is initialized after calling | |
88 | * {@link TmfStateSystemAnalysisModule#waitForInitialization()}. | |
89 | */ | |
90 | @Test | |
91 | public void testInitialization() { | |
92 | assertNull(module.getStateSystem()); | |
93 | module.schedule(); | |
94 | ||
95 | module.waitForInitialization(); | |
96 | assertNotNull(module.getStateSystem()); | |
97 | } | |
98 | ||
8a6ff07f | 99 | } |