Tests: Swap usages of pidof for pgrep --full
[lttng-tools.git] / tests / stress / test_multi_sessions_per_uid_10app
CommitLineData
605ac758
DG
1#!/bin/bash
2#
3# Copyright (C) - 2013 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8# details.
9#
10# You should have received a copy of the GNU Lesser General Public License
11# along with this library; if not, write to the Free Software Foundation, Inc.,
12# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
14
15CURDIR=$(dirname $0)/
16TESTDIR=$CURDIR/..
17LAUNCH_APP="launch_ust_app"
18SESSION_NAME="stress"
19EVENT_NAME="tp:tptest"
20LOG_FILE="sessiond.log"
21CHANNEL_NAME="channel0"
22NUM_TESTS=16
23NR_APP=10
24NR_SESSION=5
25NR_LOOP=1000
26COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
7e635e71 27APPS_PID=
605ac758
DG
28
29TEST_DESC="Stress test - $NR_SESSION sessions per UID with $NR_APP apps"
30
31source $TESTDIR/utils/utils.sh
32
33# MUST set TESTDIR before calling those functions
34
35function enable_channel_per_uid()
36{
37 local sess_name=$1
38 local channel_name=$2
39
40 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name >/dev/null 2>&1
41 ok $? "Enable channel $channel_name per UID for session $sess_name"
42}
43
44function check_sessiond()
45{
db7b260c 46 if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
605ac758
DG
47 local str_date=$(date +%H%M%S-%d%m%Y)
48
49 diag "!!!The session daemon died unexpectedly!!!"
50 mv $LOG_FILE $LOG_FILE-$str_date
51 if [ -e $COREDUMP_FILE ]; then
52 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
53 fi
54 exit 1
55 fi
56}
57
58function start_sessiond()
59{
60 local SESSIOND_BIN="lttng-sessiond"
61
62 validate_kernel_version
63 if [ $? -ne 0 ]; then
64 fail "Start session daemon"
65 BAIL_OUT "*** Kernel too old for session daemon tests ***"
66 fi
67
db7b260c 68 if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
605ac758
DG
69 # We have to start it like this so the ulimit -c is used by this
70 # process. Also, we collect any error message printed out.
0fc2834c 71 $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
605ac758 72 status=$?
605ac758
DG
73 ok $status "Start session daemon"
74 fi
75}
76
77test_stress()
78{
79 for b in $(seq 1 $NR_LOOP); do
80 for a in $(seq 1 $NR_SESSION); do
bf6ae429 81 create_lttng_session_ok $SESSION_NAME-$a $TRACE_PATH
605ac758
DG
82 check_sessiond
83 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
84 check_sessiond
c4926bb5 85 enable_ust_lttng_event_ok $SESSION_NAME-$a $EVENT_NAME
605ac758 86 check_sessiond
e563bbdb 87 start_lttng_tracing_ok $SESSION_NAME-$a
605ac758
DG
88 check_sessiond
89 done
90
91 for a in $(seq 1 $NR_SESSION); do
96340a01 92 stop_lttng_tracing_ok $SESSION_NAME-$a
605ac758 93 check_sessiond
67b4c664 94 destroy_lttng_session_ok $SESSION_NAME-$a
605ac758
DG
95 check_sessiond
96 done
97 done
98
99 return 0
100}
101
102function cleanup()
103{
104 diag "Cleaning up!"
7e635e71
MD
105 for p in ${APPS_PID}; do
106 kill -s SIGKILL ${p}
107 wait ${p} 2>/dev/null
108 done
109 APPS_PID=
605ac758
DG
110 stop_lttng_sessiond
111}
112
113function sighandler()
114{
115 cleanup
116 rm $LOG_FILE
117 exit 1
118}
119
120trap sighandler SIGINT
7e635e71 121trap sighandler SIGTERM
605ac758
DG
122
123# Make sure we collect a coredump if possible.
124ulimit -c unlimited
125
126# MUST set TESTDIR before calling those functions
127plan_tests $NUM_TESTS
128
129print_test_banner "$TEST_DESC"
130
131start_sessiond
132
133diag "Starting applications"
134
135# Start NR_APP applications script that will spawn apps non stop.
136./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
7e635e71 137APPS_PID="${APPS_PID} ${!}"
605ac758
DG
138
139TRACE_PATH=$(mktemp -d)
140
141test_stress
142out=$?
143if [ $out -ne 0 ]; then
144 cleanup
145 exit $out
146fi
147
148cleanup
149rm -rf $TRACE_PATH
150rm $LOG_FILE
151exit 0
This page took 0.034191 seconds and 4 git commands to generate.