1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.ust
.core
.tests
.analysis
.debuginfo
;
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
;
17 import java
.util
.Collection
;
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
;
34 import com
.google
.common
.collect
.ImmutableList
;
35 import com
.google
.common
.collect
.Iterables
;
38 * Tests for the {@link UstDebugInfoAnalysisModule}
40 * @author Alexandre Montplaisir
42 public class UstDebugInfoAnalysisModuleTest
{
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
;
48 private LttngUstTrace fTrace
;
49 private UstDebugInfoAnalysisModule fModule
;
56 fModule
= new UstDebugInfoAnalysisModule();
57 fTrace
= new LttngUstTrace();
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
);
70 public void tearDown() {
78 * Test for {@link UstDebugInfoAnalysisModule#getAnalysisRequirements()}
81 public void testGetAnalysisRequirements() {
82 Iterable
<TmfAnalysisRequirement
> requirements
= fModule
.getAnalysisRequirements();
83 assertNotNull(requirements
);
84 assertTrue(Iterables
.isEmpty(requirements
));
88 * Test that the analysis can execute on a valid trace.
91 public void testCanExecute() {
92 assertNotNull(fTrace
);
93 assertTrue(fModule
.canExecute(fTrace
));
97 * Test that the analysis correctly refuses to execute on an invalid trace
98 * (LTTng-UST < 2.8 in this case).
100 * @throws TmfTraceException
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
));
109 invalidTrace
.dispose();
112 private void executeModule() {
113 assertNotNull(fTrace
);
115 fModule
.setTrace(fTrace
);
116 } catch (TmfAnalysisException e
) {
120 fModule
.waitForCompletion();
124 * Test that basic execution of the module works well.
127 public void testExecution() {
129 ITmfStateSystem ss
= fModule
.getStateSystem();
134 * Test the {@link UstDebugInfoAnalysisModule#getAllBinaries} method.
137 public void testGetAllBinaries() {
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"))
155 assertTrue(actualBinaries
.containsAll(expectedBinaries
));