3 # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
4 # Copyright (C) 2014 Julien Desfossez <jdesfossez@efficios.com>
6 # SPDX-License-Identifier: GPL-2.0-only
8 TEST_DESC
="UST tracer - Perf counters"
12 SESSION_NAME
="perf_counters"
13 EVENT_NAME
="tp:tptest"
17 TESTAPP_PATH
="$TESTDIR/utils/testapp"
18 TESTAPP_NAME
="gen-ust-events"
19 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
21 source $TESTDIR/utils
/utils.sh
23 function enable_ust_lttng_event_per_chan
()
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"
33 function add_context_ust_skip_ok
()
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"
47 if [ "$ret" == "4" ]; then
48 skip
0 "Current UST lib doesn't implement '$context_name' context" "$skip_num"
50 ok
$ret "Add context command for type: $context_name"
56 # Only test parsing of the enabling by raw ID
57 function test_parsing_raw
()
59 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
60 SESSION_NAME
="ust_event_basic"
63 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
65 enable_ust_lttng_channel_ok
$SESSION_NAME $CHAN_NAME
67 enable_ust_lttng_event_per_chan
$SESSION_NAME $EVENT_NAME $CHAN_NAME
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"
80 destroy_lttng_session_ok
$SESSION_NAME
85 function test_event_basic
()
87 TRACE_PATH
=$
(mktemp
-d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
88 SESSION_NAME
="ust_event_basic"
93 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
95 enable_ust_lttng_channel_ok
$SESSION_NAME $CHAN_NAME
97 enable_ust_lttng_event_per_chan
$SESSION_NAME $EVENT_NAME $CHAN_NAME
99 add_context_ust_skip_ok
$SESSION_NAME $CHAN_NAME "perf:thread:page-fault" 4
102 if [ "$ret" != "4" ]; then
103 start_lttng_tracing_ok
105 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT >/dev
/null
2>&1
107 stop_lttng_tracing_ok
109 validate_trace
"perf_thread_page_fault" "$TRACE_PATH"
112 destroy_lttng_session_ok
$SESSION_NAME
117 # MUST set TESTDIR before calling those functions
118 plan_tests
$NUM_TESTS
120 print_test_banner
"$TEST_DESC"
122 bail_out_if_no_babeltrace
124 if [ "$(id -u)" == "0" ]; then
134 skip
$isroot "Root access is needed. Skipping UST perf tests." 8 ||