3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License, version 2 only, as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 TEST_DESC
="Health check - Thread stall"
21 TESTDIR
=$CURDIR/..
/..
/..
23 SESSION_NAME
="health_thread_stall"
25 HEALTH_CHECK_BIN
="health_check"
26 SESSIOND_PRELOAD
=".libs/libhealthstall.so"
29 source $TESTDIR/utils
/utils.sh
31 if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
32 BAIL_OUT
"libhealthstall.so not available for this test."
35 function test_thread_stall
37 test_thread_stall_name
="$1"
38 test_thread_exit_code
="$2"
40 diag
"Test health failure with ${test_thread_stall_name}"
43 export LTTNG_TESTPOINT_ENABLE
=1
45 # Activate specific thread exit
46 export ${test_thread_stall_name}_STALL
=1
48 # Spawn sessiond with preload healthexit lib
49 export LD_PRELOAD
="$CURDIR/$SESSIOND_PRELOAD"
50 # Set the socket timeout to 5 so the health check delta is set to 25.
51 export LTTNG_NETWORK_SOCKET_TIMEOUT
=5
54 # Cleanup some env. var.
56 unset ${test_thread_stall_name}_STALL
58 # Check initial health status
59 $CURDIR/$HEALTH_CHECK_BIN > /dev
/null
64 # Check health status, should indicate failure
65 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
67 out
=$
(grep "${test_thread_error_string}" ${STDOUT_PATH} |
wc -l)
68 if [ $out -eq 0 ]; then
69 fail
"Validate thread ${test_thread_stall_name} is stalled"
70 diag
"Health returned:"
86 pass
"Validate thread ${test_thread_stall_name} is stalled"
92 # Check health status, should now pass
93 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
95 out
=$
(grep "${test_thread_error_string}" ${STDOUT_PATH} |
wc -l)
96 if [ $out -ne 0 ]; then
97 fail
"Validate thread ${test_thread_stall_name} is not longer stalled"
98 diag
"Health returned:"
114 pass
"Validate thread ${test_thread_stall_name} is not longer stalled"
119 plan_tests
$NUM_TESTS
121 print_test_banner
"$TEST_DESC"
123 THREAD
=("LTTNG_THREAD_MANAGE_CLIENTS"
124 "LTTNG_THREAD_MANAGE_APPS"
125 # This thread is a little bit tricky to stall,
126 # need to send some commands and setup an app.
127 # "LTTNG_THREAD_REG_APPS"
131 "Thread \"Session daemon command\" is not responding in component \"sessiond\"."
132 "Thread \"Session daemon application manager\" is not responding in component \"sessiond\"."
133 "Thread \"Session daemon application registration\" is not responding in component \"sessiond\"."
136 STDOUT_PATH
=$
(mktemp
)
137 STDERR_PATH
=$
(mktemp
)
139 THREAD_COUNT
=${#THREAD[@]}
141 while [ "$i" -lt "$THREAD_COUNT" ]; do
142 test_thread_stall
"${THREAD[$i]}" "${ERROR_STRING[$i]}"
144 if [ $?
-eq 1 ]; then
151 # The manage kernel thread is only spawned if we are root
152 if [ "$(id -u)" == "0" ]; then
158 skip
$isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "4" ||
160 test_thread_stall
"LTTNG_THREAD_MANAGE_KERNEL" "Thread \"Session daemon kernel\" is not responding in component \"sessiond\"."