0e8b51007f21d66a32a3262e215e8f297f8b4431
[lttng-tools.git] / tests / regression / tools / health / test_thread_stall
1 #!/bin/bash
2 #
3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 #
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.
8 #
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
12 # more details.
13 #
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.
17
18 TEST_DESC="Health check - Thread stall"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 LTTNG_BIN="lttng"
23 SESSION_NAME="health_thread_stall"
24 EVENT_NAME="bogus"
25 HEALTH_CHECK_BIN="health_check"
26 SESSIOND_PRELOAD=".libs/libhealthstall.so"
27 NUM_TESTS=12
28
29 source $TESTDIR/utils/utils.sh
30
31 if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
32 BAIL_OUT "libhealthstall.so not available for this test."
33 fi
34
35 function test_thread_stall
36 {
37 test_thread_stall_name="$1"
38 test_thread_exit_code="$2"
39
40 diag "Test health failure with ${test_thread_stall_name}"
41
42 # Activate testpoints
43 export LTTNG_TESTPOINT_ENABLE=1
44
45 # Activate specific thread exit
46 export ${test_thread_stall_name}_STALL=1
47
48 # Spawn sessiond with preload healthexit lib
49 export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
50 start_lttng_sessiond
51
52 # Cleanup some env. var.
53 unset LD_PRELOAD
54 unset ${test_thread_stall_name}_STALL
55
56 # Check initial health status
57 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
58
59 # Wait
60 sleep 25
61
62 # Check health status, exit code should indicate failure
63 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
64
65 health_check_exit_code=$?
66
67 if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
68 pass "Validate that ${test_thread_stall_name} is stalled"
69 else
70 fail "Validate that ${test_thread_stall_name} is stalled"
71 diag "Health returned: $health_check_exit_code"
72
73 stop_lttng_sessiond
74 return 1
75 fi
76
77 # Wait
78 sleep 40
79
80 # Check health status, exit code should now pass
81 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
82
83 health_check_exit_code=$?
84
85 if [ $health_check_exit_code -eq 0 ]; then
86 pass "Validate that ${test_thread_stall_name} is no longer stalled"
87 stop_lttng_sessiond
88 else
89 fail "Validate that ${test_thread_stall_name} is no longer stalled"
90 diag "Health returned: $health_check_exit_code\n"
91 stop_lttng_sessiond
92 return 1
93 fi
94
95
96 }
97
98 plan_tests $NUM_TESTS
99
100 print_test_banner "$TEST_DESC"
101
102 THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
103 "LTTNG_THREAD_MANAGE_APPS"
104 # This thread is a little bit tricky to stall,
105 # need to send some commands and setup an app.
106 # "LTTNG_THREAD_REG_APPS"
107 )
108
109 # Exit code value to indicate specific thread failure
110 EXIT_CODE=(1
111 2
112 # 4
113 )
114
115 THREAD_COUNT=${#THREAD[@]}
116 i=0
117 while [ "$i" -lt "$THREAD_COUNT" ]; do
118 test_thread_stall "${THREAD[$i]}" "${EXIT_CODE[$i]}"
119
120 if [ $? -eq 1 ]; then
121 exit 1
122 fi
123
124 let "i++"
125 done
126
127 # The manage kernel thread is only spawned if we are root
128 if [ "$(id -u)" == "0" ]; then
129 isroot=1
130 else
131 isroot=0
132 fi
133
134 skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "4" ||
135 {
136 test_thread_stall "LTTNG_THREAD_MANAGE_KERNEL" "8"
137 }
This page took 0.045917 seconds and 3 git commands to generate.