Tests: Convert the tools health tests output to TAP
[lttng-tools.git] / tests / regression / tools / health / test_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 NUM_TESTS=9
28
29 source $TESTDIR/utils/utils.sh
30
31 print_test_banner "$TEST_DESC"
32
33 if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
34 BAIL_OUT "libhealthtpfail.so not available for this test."
35 fi
36
37 function test_tp_fail
38 {
39 test_tp_fail_name="$1"
40 test_tp_fail_code="$2"
41
42 diag "Test health failure with ${test_tp_fail_name}"
43
44 # Activate testpoints
45 export LTTNG_TESTPOINT_ENABLE=1
46
47 # Activate specific testpoint failure
48 export ${test_tp_fail_name}_TP_FAIL=1
49
50 # Spawn sessiond with preload healthexit lib
51 export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
52 start_lttng_sessiond
53
54 # Cleanup some env. var.
55 unset LD_PRELOAD
56 unset ${test_tp_fail_name}_TP_FAIL
57
58 # Check health status, exit code should indicate failure
59 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
60
61 health_check_exit_code=$?
62
63 if [ $health_check_exit_code -eq $test_tp_fail_code ]; then
64 pass "Validate thread ${test_tp_fail_name} failure"
65 stop_lttng_sessiond
66 else
67 fail "Validate thread ${test_tp_fail_name} failure"
68 diag "Health returned: $health_check_exit_code"
69 stop_lttng_sessiond
70 return 1
71 fi
72 }
73
74 plan_tests $NUM_TESTS
75
76 THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
77 "LTTNG_THREAD_MANAGE_APPS")
78
79 # Exit code value to indicate specific thread failure
80 EXIT_CODE=(1 2)
81
82 THREAD_COUNT=${#THREAD[@]}
83 i=0
84 while [ "$i" -lt "$THREAD_COUNT" ]; do
85 test_tp_fail "${THREAD[$i]}" "${EXIT_CODE[$i]}"
86
87 if [ $? -eq 1 ]; then
88 exit 1
89 fi
90
91 let "i++"
92 done
93
94 # The manage kernel thread is only spawned if we are root
95 if [ "$(id -u)" == "0" ]; then
96 isroot=1
97 else
98 isroot=0
99 fi
100
101 skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
102 {
103 test_tp_fail "LTTNG_THREAD_MANAGE_KERNEL" "8"
104 }
105
106
107 # TODO: Special case manage consumer, need to spawn consumer via commands.
108 #"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.034591 seconds and 6 git commands to generate.