tests: invoke full_cleanup from script trap handlers, use modprobe -r
[lttng-tools.git] / tests / stress / test_multi_sessions_per_uid_10app
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
15 CURDIR=$(dirname $0)/
16 TESTDIR=$CURDIR/..
17 LAUNCH_APP="launch_ust_app"
18 SESSION_NAME="stress"
19 EVENT_NAME="tp:tptest"
20 LOG_FILE="sessiond.log"
21 CHANNEL_NAME="channel0"
22 NUM_TESTS=16
23 NR_APP=10
24 NR_SESSION=5
25 NR_LOOP=1000
26 COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
27 APPS_PID=
28
29 TEST_DESC="Stress test - $NR_SESSION sessions per UID with $NR_APP apps"
30
31 source $TESTDIR/utils/utils.sh
32
33 # MUST set TESTDIR before calling those functions
34
35 function 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
44 function check_sessiond()
45 {
46 if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
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
58 function start_sessiond()
59 {
60 validate_kernel_version
61 if [ $? -ne 0 ]; then
62 fail "Start session daemon"
63 BAIL_OUT "*** Kernel too old for session daemon tests ***"
64 fi
65
66 if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
67 # We have to start it like this so the ulimit -c is used by this
68 # process. Also, we collect any error message printed out.
69 $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
70 status=$?
71 ok $status "Start session daemon"
72 fi
73 }
74
75 test_stress()
76 {
77 for b in $(seq 1 $NR_LOOP); do
78 for a in $(seq 1 $NR_SESSION); do
79 create_lttng_session_ok $SESSION_NAME-$a $TRACE_PATH
80 check_sessiond
81 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
82 check_sessiond
83 enable_ust_lttng_event_ok $SESSION_NAME-$a $EVENT_NAME
84 check_sessiond
85 start_lttng_tracing_ok $SESSION_NAME-$a
86 check_sessiond
87 done
88
89 for a in $(seq 1 $NR_SESSION); do
90 stop_lttng_tracing_ok $SESSION_NAME-$a
91 check_sessiond
92 destroy_lttng_session_ok $SESSION_NAME-$a
93 check_sessiond
94 done
95 done
96
97 return 0
98 }
99
100 function cleanup()
101 {
102 diag "Cleaning up!"
103 for p in ${APPS_PID}; do
104 kill -s SIGKILL ${p}
105 wait ${p} 2>/dev/null
106 done
107 APPS_PID=
108 stop_lttng_sessiond
109 }
110
111 function sighandler()
112 {
113 cleanup
114 rm $LOG_FILE
115 full_cleanup
116 }
117
118 trap sighandler SIGINT SIGTERM
119
120 # Make sure we collect a coredump if possible.
121 ulimit -c unlimited
122
123 # MUST set TESTDIR before calling those functions
124 plan_tests $NUM_TESTS
125
126 print_test_banner "$TEST_DESC"
127
128 start_sessiond
129
130 diag "Starting applications"
131
132 # Start NR_APP applications script that will spawn apps non stop.
133 ./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
134 APPS_PID="${APPS_PID} ${!}"
135
136 TRACE_PATH=$(mktemp -d)
137
138 test_stress
139 out=$?
140 if [ $out -ne 0 ]; then
141 cleanup
142 exit $out
143 fi
144
145 cleanup
146 rm -rf $TRACE_PATH
147 rm $LOG_FILE
148 exit 0
This page took 0.048841 seconds and 5 git commands to generate.