Tests: Convert the tools health tests output to TAP
[lttng-tools.git] / tests / regression / tools / health / test_thread_exit
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 NUM_TESTS=12
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 "libhealthexit.so not available for this test."
35 fi
36
37 function test_thread_exit
38 {
39 test_thread_exit_name="$1"
40 test_thread_exit_code="$2"
41
42 diag "Test health failure with ${test_thread_exit_name}"
43
44 # Activate testpoints
45 export LTTNG_TESTPOINT_ENABLE=1
46
47 # Activate specific thread exit
48 export ${test_thread_exit_name}_EXIT=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_thread_exit_name}_EXIT
57
58 # Check initial health status
59 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
60
61 # Wait
62 sleep 25
63
64 # Check health status, exit code should indicate failure
65 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
66
67 health_check_exit_code=$?
68
69 if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
70 pass "Validate thread ${test_thread_exit_name} failure"
71 stop_lttng_sessiond
72 else
73 fail "Validate thread ${test_thread_exit_name} failure"
74
75 diag "Health returned: $health_check_exit_code\n"
76
77 stop_lttng_sessiond
78 return 1
79 fi
80 }
81 plan_tests $NUM_TESTS
82
83 THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
84 "LTTNG_THREAD_MANAGE_APPS"
85 "LTTNG_THREAD_REG_APPS")
86
87 # Exit code value to indicate specific thread failure
88 EXIT_CODE=(1 2 4)
89
90 THREAD_COUNT=${#THREAD[@]}
91 i=0
92 while [ "$i" -lt "$THREAD_COUNT" ]; do
93 test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}"
94
95 if [ $? -eq 1 ]; then
96 exit 1
97 fi
98
99 let "i++"
100 done
101
102 # The manage kernel thread is only spawned if we are root
103 if [ "$(id -u)" == "0" ]; then
104 isroot=1
105 else
106 isroot=0
107 fi
108
109 skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
110 {
111 test_thread_exit "LTTNG_THREAD_MANAGE_KERNEL" "8"
112 }
113
114
115 # TODO: Special case manage consumer, need to spawn consumer via commands.
116 #"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.045547 seconds and 4 git commands to generate.