3 # Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Streaming - User space tracing"
10 TESTDIR
=$CURDIR/..
/..
/..
13 TESTAPP_PATH
="$TESTDIR/utils/testapp"
14 TESTAPP_NAME
="gen-ust-events"
15 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
17 EVENT_NAME
="tp:tptest"
19 TRACE_PATH
=$
(mktemp
-d)
23 source $TESTDIR/utils
/utils.sh
25 if [ ! -x "$TESTAPP_BIN" ]; then
26 BAIL_OUT
"No UST events binary detected."
29 # MUST set TESTDIR before calling those functions
31 function test_ust_before_start
()
33 local file_sync_before_last
=$
(mktemp
-u)
35 diag
"Test UST streaming BEFORE tracing starts"
36 create_lttng_session_uri
$SESSION_NAME net
://localhost
37 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
39 # Run 5 times with a 1 second delay
40 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-before-last-event ${file_sync_before_last} > /dev
/null
2>&1 &
42 start_lttng_tracing_ok
$SESSION_NAME
44 touch ${file_sync_before_last}
46 # Wait for the applications started in background
49 stop_lttng_tracing_ok
$SESSION_NAME
50 destroy_lttng_session_ok
$SESSION_NAME
51 rm -f ${file_sync_before_last}
54 function test_ust_after_start
()
56 local file_sync_after_first
=$
(mktemp
-u)
58 diag
"Test UST streaming AFTER tracing starts"
59 create_lttng_session_uri
$SESSION_NAME net
://localhost
60 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
61 start_lttng_tracing_ok
$SESSION_NAME
63 # Run 5 times with a 1 second delay
64 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
65 --sync-after-first-event ${file_sync_after_first} >/dev
/null
2>&1
67 while [ ! -f "${file_sync_after_first}" ]; do
71 stop_lttng_tracing_ok
$SESSION_NAME
72 destroy_lttng_session_ok
$SESSION_NAME
74 # Wait for the applications started in background
76 rm -f ${file_sync_after_first}
81 print_test_banner
"$TEST_DESC"
83 start_lttng_relayd
"-o $TRACE_PATH"
86 tests
=( test_ust_before_start test_ust_after_start
)
88 for fct_test
in ${tests[@]};
90 SESSION_NAME
=$
(randstring
16 0)
94 validate_trace_path_ust_uid_network
"$TRACE_PATH" "$SESSION_NAME"
95 validate_trace
$EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
97 # Only delete if successful