1 /*******************************************************************************
2 * Copyright (c) 2016 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
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.ust
.ui
.tests
.analysis
.callstack
;
12 import static org
.junit
.Assert
.assertEquals
;
14 import java
.util
.Collection
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.internal
.lttng2
.ust
.ui
.analysis
.callstack
.LttngUstCallStackAnalysisRequirement
;
19 import org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
.LttngUstTrace
;
20 import org
.eclipse
.tracecompass
.lttng2
.ust
.core
.trace
.layout
.ILttngUstEventLayout
;
21 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEventType
;
22 import org
.junit
.Test
;
24 import com
.google
.common
.collect
.ImmutableSet
;
27 * Test the {@link LttngUstCallStackAnalysisRequirement} class
29 * @author Bernd Hufmann
31 public class LTTngUstCallStackAnalysisRequirementTest
{
33 private static final @NonNull String FUNC_EXIT_FAST
= "lttng_ust_cyg_profile_fast:func_exit";
34 private static final @NonNull String FUNC_EXIT
= "lttng_ust_cyg_profile:func_exit";
35 private static final @NonNull String FUNC_ENTRY_FAST
= "lttng_ust_cyg_profile_fast:func_entry";
36 private static final @NonNull String FUNC_ENTRY
= "lttng_ust_cyg_profile:func_entry";
37 private static final @NonNull String OTHER_EVENT
= "OTHER";
39 private static final @NonNull String CONTEXT_VTID
= "context._vtid";
40 private static final @NonNull String CONTEXT_PROCNAME
= "context._procname";
41 private static final @NonNull String CONTEXT_OTHER
= "context._other";
43 private static final @NonNull Collection
<String
> validFields
= ImmutableSet
.of(CONTEXT_VTID
, CONTEXT_PROCNAME
);
44 private static final @NonNull Collection
<String
> badFields
= ImmutableSet
.of(CONTEXT_OTHER
, CONTEXT_PROCNAME
);
47 EVT_EXIT_FAST (FUNC_EXIT_FAST
, validFields
),
48 EVT_EXIT (FUNC_EXIT
, validFields
),
49 EVT_ENTRY_FAST (FUNC_ENTRY_FAST
, validFields
),
50 EVT_ENTRY (FUNC_ENTRY
, validFields
),
51 EVT_OTHER (OTHER_EVENT
, validFields
),
52 EVT_ENTRY_BAD_FIELDS (FUNC_ENTRY
, badFields
),
53 EVT_ENTRY_FAST_BAD_FIELDS (FUNC_ENTRY_FAST
, badFields
),
54 EVT_ENTRY_FAST_EMPTY_FIELDS (FUNC_ENTRY_FAST
, ImmutableSet
.of());
56 private final @NonNull CtfTmfEventType fType
;
58 EventType(@NonNull String name
, @NonNull Collection
<String
> fields
) {
59 fType
= new CtfTmfEventType(name
, null) {
61 public String
getName() {
65 public @NonNull Collection
<String
> getFieldNames() {
71 @NonNull CtfTmfEventType
getEventType() {
77 TRACE_WITH_VALID_EVENTS(EventType
.EVT_ENTRY
, EventType
.EVT_EXIT
, true),
78 TRACE_WITH_VALID_EVENTS_FAST(EventType
.EVT_ENTRY_FAST
, EventType
.EVT_EXIT_FAST
, true),
79 TRACE_WITH_VALID_EVENTS_MISSING_FIELDS(EventType
.EVT_ENTRY_BAD_FIELDS
,
80 EventType
.EVT_EXIT
, false),
81 TRACE_WITH_VALID_EVENTS_MISSING_FIELDS_FAST(EventType
.EVT_ENTRY_FAST_BAD_FIELDS
,
82 EventType
.EVT_EXIT_FAST
, false),
83 TRACE_WITH_VALID_EVENTS_WRONG_FIELDS(EventType
.EVT_ENTRY_FAST_EMPTY_FIELDS
,
84 EventType
.EVT_EXIT_FAST
, false),
85 TRACE_WITH_MISSING_EVENTS(EventType
.EVT_OTHER
,
86 EventType
.EVT_EXIT_FAST
, false),
87 TRACE_MISMATCH_EVENTS(EventType
.EVT_ENTRY_FAST
, EventType
.EVT_EXIT
, false);
89 private final @NonNull LttngUstTrace fTrace
;
90 private final boolean fIsValid
;
92 TestData(EventType first
, EventType second
, boolean isValid
) {
93 fTrace
= new LttngUstTrace() {
95 public Set
<CtfTmfEventType
> getContainedEventTypes() {
96 return ImmutableSet
.of(first
.getEventType(), second
.getEventType());
102 @NonNull LttngUstTrace
getTrace() {
113 * Test Call Stack Analysis requirements
116 public void testCallStackRequirements() {
117 LttngUstCallStackAnalysisRequirement req
= new LttngUstCallStackAnalysisRequirement(ILttngUstEventLayout
.DEFAULT_LAYOUT
);
118 for (TestData item
: TestData
.values()) {
119 assertEquals(item
.name(), item
.isValid(), req
.test(item
.getTrace()));