common: fix compilation when strnlen, strnup and memrchr are not available
[lttng-tools.git] / tests / regression / ust / test_event_perf
CommitLineData
bb8ec90d
JD
1#!/bin/bash
2#
9d16b343
MJ
3# Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
4# Copyright (C) 2014 Julien Desfossez <jdesfossez@efficios.com>
bb8ec90d 5#
9d16b343 6# SPDX-License-Identifier: GPL-2.0-only
bb8ec90d
JD
7
8TEST_DESC="UST tracer - Perf counters"
9
10CURDIR=$(dirname $0)/
11TESTDIR=$CURDIR/../..
bb8ec90d
JD
12SESSION_NAME="perf_counters"
13EVENT_NAME="tp:tptest"
7cd988f0 14NUM_TESTS=24
bb8ec90d
JD
15NR_ITER=1
16NR_USEC_WAIT=1
17TESTAPP_PATH="$TESTDIR/utils/testapp"
18TESTAPP_NAME="gen-ust-events"
19TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
20
21source $TESTDIR/utils/utils.sh
22
23function 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
db3db2cb
MJ
33function 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
7cd988f0
JD
56# Only test parsing of the enabling by raw ID
57function test_parsing_raw()
bb8ec90d 58{
33e55711 59 TRACE_PATH=$(mktemp --tmpdir -d "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
7cd988f0
JD
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
bb8ec90d 68
db3db2cb 69 add_context_ust_skip_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test" 1
7cd988f0
JD
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
bb8ec90d
JD
83}
84
85function test_event_basic()
86{
33e55711 87 TRACE_PATH=$(mktemp --tmpdir -d "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
bb8ec90d
JD
88 SESSION_NAME="ust_event_basic"
89 CHAN_NAME="mychan"
90
db3db2cb
MJ
91 local ret
92
bf6ae429 93 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
bb8ec90d 94
827caf52 95 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
bb8ec90d
JD
96
97 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
98
db3db2cb
MJ
99 add_context_ust_skip_ok $SESSION_NAME $CHAN_NAME "perf:thread:page-fault" 4
100 ret=$?
bb8ec90d 101
db3db2cb
MJ
102 if [ "$ret" != "4" ]; then
103 start_lttng_tracing_ok
bb8ec90d 104
6c4a91d6 105 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev/null 2>&1
bb8ec90d 106
db3db2cb
MJ
107 stop_lttng_tracing_ok
108
109 validate_trace "perf_thread_page_fault" "$TRACE_PATH"
110 fi
bb8ec90d 111
67b4c664 112 destroy_lttng_session_ok $SESSION_NAME
bb8ec90d 113
db3db2cb 114 rm -rf "$TRACE_PATH"
bb8ec90d
JD
115}
116
117# MUST set TESTDIR before calling those functions
118plan_tests $NUM_TESTS
119
120print_test_banner "$TEST_DESC"
121
c125de8f
FD
122bail_out_if_no_babeltrace
123
bc2d01d2
MD
124if [ "$(id -u)" == "0" ]; then
125 isroot=1
126else
127 isroot=0
128fi
129
7cd988f0 130start_lttng_sessiond
bb8ec90d 131
7cd988f0 132test_parsing_raw
bb8ec90d 133
7cd988f0
JD
134skip $isroot "Root access is needed. Skipping UST perf tests." 8 ||
135{
136 test_event_basic
bc2d01d2 137}
7cd988f0
JD
138
139stop_lttng_sessiond
This page took 0.0455179999999999 seconds and 4 git commands to generate.