1 /*******************************************************************************
2 * Copyright (c) 2017 École Polytechnique de Montréal
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.ust
.core
.tests
.trace
;
12 import static org
.junit
.Assert
.assertNotNull
;
13 import static org
.junit
.Assert
.assertNull
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.event
.aspect
.LinuxTidAspect
;
19 import org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
.LttngUstTrace
;
20 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.request
.TmfEventRequest
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceUtils
;
28 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
29 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
30 import org
.junit
.After
;
31 import org
.junit
.Before
;
32 import org
.junit
.Test
;
35 * Test the {@link LttngUstTrace} class
37 * @author Geneviève Bastien
39 public class LttngUstTraceTest
{
41 private static final @NonNull CtfTestTrace TEST_TRACE
= CtfTestTrace
.CYG_PROFILE
;
43 private ITmfTrace fTrace
;
46 * Perform pre-class initialization.
48 * @throws TmfTraceException
49 * Exceptions in trace initialization
52 public void setUp() throws TmfTraceException
{
53 CtfTmfTrace ctftrace
= CtfTmfTestTraceUtils
.getTrace(TEST_TRACE
);
55 LttngUstTrace trace
= new LttngUstTrace();
56 trace
.initTrace(null, ctftrace
.getPath(), ITmfEvent
.class);
61 /** Empty and delete a directory */
62 private static void deleteDirectory(File dir
) {
63 /* Assuming the dir only contains file or empty directories */
64 for (File file
: dir
.listFiles()) {
71 * Perform post-class clean-up.
74 public void tearDown() {
75 ITmfTrace trace
= fTrace
;
78 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(trace
));
79 deleteDirectory(suppDir
);
83 private static class TestEventRequest
extends TmfEventRequest
{
85 private String errString
= null;
87 public TestEventRequest() {
88 super(ITmfEvent
.class, TmfTimeRange
.ETERNITY
, 0, 2, ExecutionType
.FOREGROUND
);
92 public void handleData(@NonNull ITmfEvent event
) {
93 super.handleData(event
);
94 Integer tid
= TmfTraceUtils
.resolveIntEventAspectOfClassForEvent(event
.getTrace(), LinuxTidAspect
.class, event
);
96 errString
= "No TID for event " + event
;
100 if (tid
.intValue() != 16073) {
101 errString
= "Wrong tid: " + tid
+ " for event";
107 public String
getErrString() {
114 * Test the LinuxTidAspect for this trace
116 * @throws InterruptedException
117 * exception thrown in the request
120 public void testTidAspect() throws InterruptedException
{
121 ITmfTrace trace
= fTrace
;
122 assertNotNull(trace
);
124 TestEventRequest request
= new TestEventRequest();
125 trace
.sendRequest(request
);
126 request
.waitForCompletion();
127 assertNull(request
.getErrString());
This page took 0.049377 seconds and 5 git commands to generate.