Commit | Line | Data |
---|---|---|
9e32c5c0 CB |
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 exit" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../.. | |
22 | LTTNG_BIN="lttng" | |
23 | SESSION_NAME="health_thread_exit" | |
24 | EVENT_NAME="bogus" | |
25 | HEALTH_CHECK_BIN="health_check" | |
26 | SESSIOND_PRELOAD=".libs/libhealthexit.so" | |
27 | ||
28 | source $TESTDIR/utils.sh | |
29 | ||
30 | print_test_banner "$TEST_DESC" | |
31 | ||
a863986c | 32 | if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then |
9e32c5c0 CB |
33 | echo -e "libhealthexit.so not available for this test. Skipping." |
34 | exit 0 | |
35 | fi | |
36 | ||
37 | function test_thread_exit | |
38 | { | |
39 | test_thread_exit_name="$1" | |
40 | test_thread_exit_code="$2" | |
41 | ||
42 | echo "" | |
43 | echo -e "=== Testing health failure with ${test_thread_exit_name}" | |
44 | ||
45 | # Activate testpoints | |
46 | export LTTNG_TESTPOINT_ENABLE=1 | |
47 | ||
48 | # Activate specific thread exit | |
49 | export ${test_thread_exit_name}_EXIT=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_thread_exit_name}_EXIT | |
58 | ||
59 | # Check initial health status | |
60 | $CURDIR/$HEALTH_CHECK_BIN &> /dev/null | |
61 | ||
62 | echo -n "Validating thread ${test_thread_exit_name} failure... " | |
63 | ||
64 | # Wait | |
65 | sleep 25 | |
66 | ||
67 | # Check health status, exit code should indicate failure | |
68 | $CURDIR/$HEALTH_CHECK_BIN &> /dev/null | |
69 | ||
70 | health_check_exit_code=$? | |
71 | ||
72 | if [ $health_check_exit_code -eq $test_thread_exit_code ]; then | |
73 | print_ok | |
74 | stop_lttng_sessiond | |
75 | else | |
76 | print_fail | |
77 | echo -e "Health returned: $health_check_exit_code\n" | |
78 | ||
79 | stop_lttng_sessiond | |
80 | return 1 | |
81 | fi | |
82 | } | |
83 | ||
84 | THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" | |
85 | "LTTNG_THREAD_MANAGE_APPS" | |
86 | "LTTNG_THREAD_REG_APPS" | |
87 | "LTTNG_THREAD_MANAGE_KERNEL") | |
88 | ||
89 | # Exit code value to indicate specific thread failure | |
90 | EXIT_CODE=(1 2 4 8) | |
91 | ||
92 | THREAD_COUNT=${#THREAD[@]} | |
93 | i=0 | |
94 | while [ "$i" -lt "$THREAD_COUNT" ]; do | |
95 | test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}" | |
96 | ||
97 | if [ $? -eq 1 ]; then | |
98 | exit 1 | |
99 | fi | |
100 | ||
101 | let "i++" | |
102 | done | |
103 | ||
104 | # Special case manage consumer, need to spawn consumer via commands. | |
105 | #"LTTNG_THREAD_MANAGE_CONSUMER" |