Fix: error-query: uninitialized action_index value
[lttng-tools.git] / tests / regression / ust / test_event_perf
1 #!/bin/bash
2 #
3 # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
4 # Copyright (C) 2014 Julien Desfossez <jdesfossez@efficios.com>
5 #
6 # SPDX-License-Identifier: GPL-2.0-only
7
8 TEST_DESC="UST tracer - Perf counters"
9
10 CURDIR=$(dirname $0)/
11 TESTDIR=$CURDIR/../..
12 SESSION_NAME="perf_counters"
13 EVENT_NAME="tp:tptest"
14 NUM_TESTS=24
15 NR_ITER=1
16 NR_USEC_WAIT=1
17 TESTAPP_PATH="$TESTDIR/utils/testapp"
18 TESTAPP_NAME="gen-ust-events"
19 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
20
21 source $TESTDIR/utils/utils.sh
22
23 function enable_ust_lttng_event_per_chan()
24 {
25 sess_name="$1"
26 event_name="$2"
27 chan_name="$3"
28
29 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
30 ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
31 }
32
33 function add_context_ust_skip_ok()
34 {
35 local session_name=$1
36 local channel_name=$2
37 local context_name=$3
38 local skip_num=$4
39
40 local ret
41
42 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" add-context -u \
43 -s "$session_name" -c "$channel_name" \
44 -t "$context_name" 1>"$OUTPUT_DEST" 2>"$ERROR_OUTPUT_DEST"
45 ret=$?
46
47 if [ "$ret" == "4" ]; then
48 skip 0 "Current UST lib doesn't implement '$context_name' context" "$skip_num"
49 else
50 ok $ret "Add context command for type: $context_name"
51 fi
52
53 return $ret
54 }
55
56 # Only test parsing of the enabling by raw ID
57 function test_parsing_raw()
58 {
59 TRACE_PATH=$(mktemp -d)
60 SESSION_NAME="ust_event_basic"
61 CHAN_NAME="mychan"
62
63 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
64
65 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
66
67 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
68
69 add_context_ust_skip_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test" 1
70 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:rZZZ:test"
71 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:b0110:test"
72 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
73 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110::"
74 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r:test"
75 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r::"
76 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw::"
77 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw"
78 add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test:wrong"
79
80 destroy_lttng_session_ok $SESSION_NAME
81
82 rm -rf $TRACE_PATH
83 }
84
85 function test_event_basic()
86 {
87 TRACE_PATH=$(mktemp -d)
88 SESSION_NAME="ust_event_basic"
89 CHAN_NAME="mychan"
90
91 local ret
92
93 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
94
95 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
96
97 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
98
99 add_context_ust_skip_ok $SESSION_NAME $CHAN_NAME "perf:thread:page-fault" 4
100 ret=$?
101
102 if [ "$ret" != "4" ]; then
103 start_lttng_tracing_ok
104
105 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1
106
107 stop_lttng_tracing_ok
108
109 validate_trace "perf_thread_page_fault" "$TRACE_PATH"
110 fi
111
112 destroy_lttng_session_ok $SESSION_NAME
113
114 rm -rf "$TRACE_PATH"
115 }
116
117 # MUST set TESTDIR before calling those functions
118 plan_tests $NUM_TESTS
119
120 print_test_banner "$TEST_DESC"
121
122 if [ "$(id -u)" == "0" ]; then
123 isroot=1
124 else
125 isroot=0
126 fi
127
128 start_lttng_sessiond
129
130 test_parsing_raw
131
132 skip $isroot "Root access is needed. Skipping UST perf tests." 8 ||
133 {
134 test_event_basic
135 }
136
137 stop_lttng_sessiond
This page took 0.058006 seconds and 4 git commands to generate.