3 # Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
8 CURDIR
=$
(dirname "$0")/
10 LAUNCH_APP
="launch_ust_app"
12 EVENT_NAME
="tp:tptest"
13 LOG_FILE
="sessiond.log"
14 CHANNEL_NAME
="channel0"
19 COREDUMP_FILE
=$
(cat /proc
/sys
/kernel
/core_pattern
)
22 TEST_DESC
="Stress test - $NR_SESSION sessions per UID with $NR_APP apps"
24 # shellcheck source-path=SCRIPTDIR/../
25 source "$TESTDIR/utils/utils.sh"
27 # MUST set TESTDIR before calling those functions
29 function enable_channel_per_uid
()
34 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel
--buffers-uid -u "$channel_name" -s "$sess_name" >/dev
/null
2>&1
35 ok $?
"Enable channel $channel_name per UID for session $sess_name"
38 function check_sessiond
()
41 if [ -z "$(lttng_pgrep lttng-sessiond)" ]; then
42 str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
44 diag
"!!!The session daemon died unexpectedly!!!"
45 mv $LOG_FILE "$LOG_FILE-$str_date"
46 if [ -e "$COREDUMP_FILE" ]; then
47 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
53 function start_sessiond
()
55 if ! validate_kernel_version
; then
56 fail
"Start session daemon"
57 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
60 if [ -z "$(lttng_pgrep $SESSIOND_BIN)" ]; then
61 # We have to start it like this so the ulimit -c is used by this
62 # process. Also, we collect any error message printed out.
63 "$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN" --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE 2>&1
65 ok
$status "Start session daemon"
71 # shellcheck disable=SC2034
72 for b
in $
(seq 1 $NR_LOOP); do
73 for a
in $
(seq 1 $NR_SESSION); do
74 create_lttng_session_ok
$SESSION_NAME-"$a" "$TRACE_PATH"
76 enable_channel_per_uid
$SESSION_NAME-"$a" $CHANNEL_NAME
78 enable_ust_lttng_event_ok
$SESSION_NAME-"$a" $EVENT_NAME
80 start_lttng_tracing_ok
$SESSION_NAME-"$a"
84 for a
in $
(seq 1 $NR_SESSION); do
85 stop_lttng_tracing_ok
$SESSION_NAME-"$a"
87 destroy_lttng_session_ok
$SESSION_NAME-"$a"
98 kill -s SIGKILL
"${APP_PIDS[@]}"
99 wait "${APP_PIDS[@]}" 2>/dev
/null
101 # shellcheck disable=SC2119
105 function sighandler
()
112 trap sighandler SIGINT SIGTERM
114 # Make sure we collect a coredump if possible.
117 # MUST set TESTDIR before calling those functions
118 plan_tests
$NUM_TESTS
120 print_test_banner
"$TEST_DESC"
124 diag
"Starting applications"
126 # Start NR_APP applications script that will spawn apps non stop.
127 "./$TESTDIR/stress/$LAUNCH_APP" $NR_APP &
130 TRACE_PATH
=$
(mktemp
-d -t tmp.test_multi_sess_per_uid_10app.XXXXXX
)
134 if [ $out -ne 0 ]; then
140 rm -rf "${TRACE_PATH:?}/"