Tests: fix health tests to use custom socket timeout
[lttng-tools.git] / tests / regression / tools / health / test_thread_exit
CommitLineData
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
18TEST_DESC="Health check - Thread exit"
19
20CURDIR=$(dirname $0)/
9ac429ef 21TESTDIR=$CURDIR/../../..
9e32c5c0
CB
22LTTNG_BIN="lttng"
23SESSION_NAME="health_thread_exit"
24EVENT_NAME="bogus"
25HEALTH_CHECK_BIN="health_check"
26SESSIOND_PRELOAD=".libs/libhealthexit.so"
33c820d6 27NUM_TESTS=12
9e32c5c0 28
9ac429ef 29source $TESTDIR/utils/utils.sh
9e32c5c0 30
a863986c 31if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
33c820d6 32 BAIL_OUT "libhealthexit.so not available for this test."
9e32c5c0
CB
33fi
34
35function test_thread_exit
36{
37 test_thread_exit_name="$1"
38 test_thread_exit_code="$2"
39
33c820d6 40 diag "Test health failure with ${test_thread_exit_name}"
9e32c5c0
CB
41
42 # Activate testpoints
43 export LTTNG_TESTPOINT_ENABLE=1
44
45 # Activate specific thread exit
46 export ${test_thread_exit_name}_EXIT=1
47
48 # Spawn sessiond with preload healthexit lib
49 export LD_PRELOAD="$CURDIR/$SESSIOND_PRELOAD"
c2ee6c2e
DG
50 # Set the socket timeout to 5 so the health check delta is set to 25.
51 export LTTNG_NETWORK_SOCKET_TIMEOUT=5
9e32c5c0
CB
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
9e32c5c0 61 # Wait
c2ee6c2e 62 sleep 30
9e32c5c0
CB
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
33c820d6 70 pass "Validate thread ${test_thread_exit_name} failure"
9e32c5c0
CB
71 stop_lttng_sessiond
72 else
33c820d6
CB
73 fail "Validate thread ${test_thread_exit_name} failure"
74
75 diag "Health returned: $health_check_exit_code\n"
9e32c5c0
CB
76
77 stop_lttng_sessiond
78 return 1
79 fi
80}
e3bef725 81
33c820d6 82plan_tests $NUM_TESTS
9e32c5c0 83
e3bef725
CB
84print_test_banner "$TEST_DESC"
85
9e32c5c0
CB
86THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
87 "LTTNG_THREAD_MANAGE_APPS"
33c820d6 88 "LTTNG_THREAD_REG_APPS")
9e32c5c0
CB
89
90# Exit code value to indicate specific thread failure
33c820d6 91EXIT_CODE=(1 2 4)
9e32c5c0
CB
92
93THREAD_COUNT=${#THREAD[@]}
94i=0
95while [ "$i" -lt "$THREAD_COUNT" ]; do
96 test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}"
97
98 if [ $? -eq 1 ]; then
99 exit 1
100 fi
101
102 let "i++"
103done
104
33c820d6
CB
105# The manage kernel thread is only spawned if we are root
106if [ "$(id -u)" == "0" ]; then
107 isroot=1
108else
109 isroot=0
110fi
111
112skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
113{
114 test_thread_exit "LTTNG_THREAD_MANAGE_KERNEL" "8"
115}
116
117
118# TODO: Special case manage consumer, need to spawn consumer via commands.
9e32c5c0 119#"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.029919 seconds and 4 git commands to generate.