5b68e62bef68f6c75d9b84c0322b5d326e7d7e97
[lttng-tools.git] / tests / tools / health / health_tp_fail
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 - Testpoint failure"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../..
22 LTTNG_BIN="lttng"
23 SESSION_NAME="health_tp_fail"
24 EVENT_NAME="bogus"
25 HEALTH_CHECK_BIN="health_check"
26 SESSIOND_PRELOAD=".libs/libhealthtpfail.so"
27
28 source $TESTDIR/utils.sh
29
30 print_test_banner "$TEST_DESC"
31
32 if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
33 echo -e "libhealthtpfail.so not available for this test. Skipping."
34 exit 0
35 fi
36
37 function test_tp_fail
38 {
39 test_tp_fail_name="$1"
40 test_tp_fail_code="$2"
41
42 echo ""
43 echo -e "=== Testing health failure with ${test_tp_fail_name}"
44
45 # Activate testpoints
46 export LTTNG_TESTPOINT_ENABLE=1
47
48 # Activate specific testpoint failure
49 export ${test_tp_fail_name}_TP_FAIL=1
50
51 # Spawn sessiond with preload healthexit lib
52 export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
53 start_lttng_sessiond
54
55 # Cleanup some env. var.
56 unset LD_PRELOAD
57 unset ${test_tp_fail_name}_TP_FAIL
58
59 echo -n "Validating thread ${test_tp_fail_name} failure... "
60
61 # Check health status, exit code should indicate failure
62 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
63
64 health_check_exit_code=$?
65
66 if [ $health_check_exit_code -eq $test_tp_fail_code ]; then
67 print_ok
68 stop_lttng_sessiond
69 else
70 print_fail
71 echo -e "Health returned: $health_check_exit_code\n"
72
73 stop_lttng_sessiond
74 return 1
75 fi
76 }
77
78 THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
79 "LTTNG_THREAD_MANAGE_APPS"
80 "LTTNG_THREAD_MANAGE_KERNEL")
81
82 # Exit code value to indicate specific thread failure
83 EXIT_CODE=(1 2 8)
84
85 THREAD_COUNT=${#THREAD[@]}
86 i=0
87 while [ "$i" -lt "$THREAD_COUNT" ]; do
88 test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}"
89
90 if [ $? -eq 1 ]; then
91 exit 1
92 fi
93
94 let "i++"
95 done
96
97 # Special case manage consumer, need to spawn consumer via commands.
98 #"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.031137 seconds and 3 git commands to generate.