tmf: Move the analysis requirements to their own package
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.ust.core.tests / src / org / eclipse / tracecompass / lttng2 / ust / core / tests / analysis / debuginfo / UstDebugInfoAnalysisModuleTest.java
1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.debuginfo;
11
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
15 import static org.junit.Assert.fail;
16
17 import java.util.Collection;
18
19 import org.eclipse.jdt.annotation.NonNull;
20 import org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.debuginfo.UstDebugInfoBinaryFile;
21 import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoAnalysisModule;
22 import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
23 import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
24 import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
25 import org.eclipse.tracecompass.tmf.core.analysis.requirements.TmfAnalysisRequirement;
26 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
27 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
28 import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
29 import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Test;
33
34 import com.google.common.collect.ImmutableList;
35 import com.google.common.collect.Iterables;
36
37 /**
38 * Tests for the {@link UstDebugInfoAnalysisModule}
39 *
40 * @author Alexandre Montplaisir
41 */
42 public class UstDebugInfoAnalysisModuleTest {
43
44 // TODO Change to real traces
45 private static final @NonNull CtfTestTrace TEST_TRACE = CtfTestTrace.DEBUG_INFO;
46 private static final @NonNull CtfTestTrace INVALID_TRACE = CtfTestTrace.CYG_PROFILE;
47
48 private LttngUstTrace fTrace;
49 private UstDebugInfoAnalysisModule fModule;
50
51 /**
52 * Test setup
53 */
54 @Before
55 public void setup() {
56 fModule = new UstDebugInfoAnalysisModule();
57 fTrace = new LttngUstTrace();
58 try {
59 fTrace.initTrace(null, CtfTmfTestTraceUtils.getTrace(TEST_TRACE).getPath(), CtfTmfEvent.class);
60 } catch (TmfTraceException e) {
61 /* Should not happen if tracesExist() passed */
62 throw new RuntimeException(e);
63 }
64 }
65
66 /**
67 * Test cleanup
68 */
69 @After
70 public void tearDown() {
71 fTrace.dispose();
72 fModule.dispose();
73 fTrace = null;
74 fModule = null;
75 }
76
77 /**
78 * Test for {@link UstDebugInfoAnalysisModule#getAnalysisRequirements()}
79 */
80 @Test
81 public void testGetAnalysisRequirements() {
82 Iterable<TmfAnalysisRequirement> requirements = fModule.getAnalysisRequirements();
83 assertNotNull(requirements);
84 assertTrue(Iterables.isEmpty(requirements));
85 }
86
87 /**
88 * Test that the analysis can execute on a valid trace.
89 */
90 @Test
91 public void testCanExecute() {
92 assertNotNull(fTrace);
93 assertTrue(fModule.canExecute(fTrace));
94 }
95
96 /**
97 * Test that the analysis correctly refuses to execute on an invalid trace
98 * (LTTng-UST < 2.8 in this case).
99 *
100 * @throws TmfTraceException
101 * Should not happen
102 */
103 @Test
104 public void testCannotExcecute() throws TmfTraceException {
105 LttngUstTrace invalidTrace = new LttngUstTrace();
106 invalidTrace.initTrace(null, CtfTmfTestTraceUtils.getTrace(INVALID_TRACE).getPath(), CtfTmfEvent.class);
107 assertFalse(fModule.canExecute(invalidTrace));
108
109 invalidTrace.dispose();
110 }
111
112 private void executeModule() {
113 assertNotNull(fTrace);
114 try {
115 fModule.setTrace(fTrace);
116 } catch (TmfAnalysisException e) {
117 fail();
118 }
119 fModule.schedule();
120 fModule.waitForCompletion();
121 }
122
123 /**
124 * Test that basic execution of the module works well.
125 */
126 @Test
127 public void testExecution() {
128 executeModule();
129 ITmfStateSystem ss = fModule.getStateSystem();
130 assertNotNull(ss);
131 }
132
133 /**
134 * Test the {@link UstDebugInfoAnalysisModule#getAllBinaries} method.
135 */
136 @Test
137 public void testGetAllBinaries() {
138 executeModule();
139 Collection<UstDebugInfoBinaryFile> actualBinaries = fModule.getAllBinaries();
140 Collection<UstDebugInfoBinaryFile> expectedBinaries = ImmutableList.<UstDebugInfoBinaryFile> builder()
141 .add(new UstDebugInfoBinaryFile("/home/alexandre/src/lttng/examples/test_app_debuginfo/libhello.so", "77e5df951d3c960de71aa816dace97d0769c6357"))
142 .add(new UstDebugInfoBinaryFile("/home/alexandre/src/lttng/examples/test_app_debuginfo/main.out", "a6048c2a073213db0815a08cccd8d7bc17999a12"))
143 .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/ld-2.21.so", "903bb7a6deefd966dceec4566c70444c727ed294"))
144 .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libc-2.21.so", "8acd43cf74a9756cd727b8516b08679ee071a92d"))
145 .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libdl-2.21.so", "f974b99c0c327670ef882ba13912e995a12c6402"))
146 .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/libpthread-2.21.so", "a37a144bcbee86a9e02dff5021a111ede6a1f212"))
147 .add(new UstDebugInfoBinaryFile("/lib/x86_64-linux-gnu/librt-2.21.so", "cb26cb6169cbaa9da2e38a70bcf7d57a8047ccf3"))
148 .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburcu-bp.so.3.0.0", "b89e6022fa66afaea454ac9825bd2d1d8aabcc2f"))
149 .add(new UstDebugInfoBinaryFile("/usr/lib/x86_64-linux-gnu/liburcu-cds.so.3.0.0", "20adc09068db509a8ee159e5a5cab1642c45aaad"))
150 .add(new UstDebugInfoBinaryFile("/usr/local/lib/liblttng-ust-dl.so.0.0.0", "6b2b70024b39672b34268974ec84d65dcd91bd91"))
151 .add(new UstDebugInfoBinaryFile("/usr/local/lib/liblttng-ust-tracepoint.so.0.0.0", "46ef60f7a1b42cbb97dae28ae2231a7e84f0bc05"))
152 .add(new UstDebugInfoBinaryFile("/usr/local/lib/liblttng-ust.so.0.0.0", "48e2b74b240d06d86b5730d666fa0af8337fbe99"))
153 .build();
154
155 assertTrue(actualBinaries.containsAll(expectedBinaries));
156 }
157
158 }
This page took 0.036978 seconds and 6 git commands to generate.