1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
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
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng2
.ust
.core
.tests
.trace
.callstack
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertNotNull
;
17 import static org
.junit
.Assert
.assertTrue
;
18 import static org
.junit
.Assume
.assumeTrue
;
22 import org
.eclipse
.core
.resources
.IResource
;
23 import org
.eclipse
.core
.runtime
.IStatus
;
24 import org
.eclipse
.linuxtools
.lttng2
.ust
.core
.trace
.LttngUstTrace
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.ITmfStateSystem
;
28 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.CtfTmfTestTrace
;
29 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
30 import org
.junit
.AfterClass
;
31 import org
.junit
.BeforeClass
;
32 import org
.junit
.Test
;
35 * Test suite for the UST callstack state provider, using the trace of a program
36 * instrumented with lttng-ust-cyg-profile-fast.so tracepoints. These do not
37 * contain the function addresses in the func_exit events.
39 * @author Alexandre Montplaisir
41 public class LttngUstCallStackProviderFastTest
{
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
47 private static final CtfTmfTestTrace testTrace
= CtfTmfTestTrace
.CYG_PROFILE_FAST
;
49 private static final String PROCNAME
= "glxgears-29822";
51 private static LttngUstTrace fixture
= null;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * Perform pre-class initialization.
60 * @throws TmfTraceException
61 * If the test trace is not found
64 public static void setUp() throws TmfTraceException
{
65 assumeTrue(testTrace
.exists());
67 /* We init the trace ourselves (we need the specific LttngUstTrace type) */
68 fixture
= new LttngUstTrace();
69 IStatus valid
= fixture
.validate(null, testTrace
.getPath());
70 assertTrue(valid
.isOK());
71 fixture
.initTrace((IResource
) null, testTrace
.getPath(), CtfTmfEvent
.class);
72 TestUtils
.openTrace(fixture
);
76 * Perform post-class clean-up.
79 public static void tearDown() {
80 if (fixture
!= null) {
82 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(fixture
));
83 TestUtils
.deleteDirectory(suppDir
);
87 // ------------------------------------------------------------------------
89 // ------------------------------------------------------------------------
92 * Test that the callstack state system is there and contains data.
95 public void testConstruction() {
96 ITmfStateSystem ss
= fixture
.getStateSystems().get(TestUtils
.SSID
);
98 assertTrue(ss
.getNbAttributes() > 0);
102 * Test the callstack at the beginning of the state system.
105 public void testCallStackBegin() {
106 long start
= fixture
.getStateSystems().get(TestUtils
.SSID
).getStartTime();
107 String
[] cs
= TestUtils
.getCallStack(fixture
, PROCNAME
, start
);
108 assertEquals(1, cs
.length
);
110 assertEquals("40472b", cs
[0]);
114 * Test the callstack somewhere in the trace.
117 public void testCallStack1() {
118 String
[] cs
= TestUtils
.getCallStack(fixture
, PROCNAME
, 1379361250310000000L);
119 assertEquals(2, cs
.length
);
121 assertEquals("40472b", cs
[0]);
122 assertEquals("403d60", cs
[1]);
126 * Test the callstack somewhere in the trace.
129 public void testCallStack2() {
130 String
[] cs
= TestUtils
.getCallStack(fixture
, PROCNAME
, 1379361250498400000L);
131 assertEquals(3, cs
.length
);
133 assertEquals("40472b", cs
[0]);
134 assertEquals("403b14", cs
[1]);
135 assertEquals("401b23", cs
[2]);
139 * Test the callstack somewhere in the trace.
142 public void testCallStack3() {
143 String
[] cs
= TestUtils
.getCallStack(fixture
, PROCNAME
, 1379361250499759000L);
144 assertEquals(4, cs
.length
);
146 assertEquals("40472b", cs
[0]);
147 assertEquals("4045c8", cs
[1]);
148 assertEquals("403760", cs
[2]);
149 assertEquals("401aac", cs
[3]);
153 * Test the callstack at the end of the trace/state system.
156 public void testCallStackEnd() {
157 long end
= fixture
.getStateSystems().get(TestUtils
.SSID
).getCurrentEndTime();
158 String
[] cs
= TestUtils
.getCallStack(fixture
, PROCNAME
, end
);
159 assertEquals(3, cs
.length
);
161 assertEquals("40472b", cs
[0]);
162 assertEquals("4045c8", cs
[1]);
163 assertEquals("403760", cs
[2]);