Fix: remove health test from fast regression
[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"
50 start_lttng_sessiond
51
52 # Cleanup some env. var.
53 unset LD_PRELOAD
54 unset ${test_thread_exit_name}_EXIT
55
56 # Check initial health status
57 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
58
9e32c5c0
CB
59 # Wait
60 sleep 25
61
62 # Check health status, exit code should indicate failure
63 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
64
65 health_check_exit_code=$?
66
67 if [ $health_check_exit_code -eq $test_thread_exit_code ]; then
33c820d6 68 pass "Validate thread ${test_thread_exit_name} failure"
9e32c5c0
CB
69 stop_lttng_sessiond
70 else
33c820d6
CB
71 fail "Validate thread ${test_thread_exit_name} failure"
72
73 diag "Health returned: $health_check_exit_code\n"
9e32c5c0
CB
74
75 stop_lttng_sessiond
76 return 1
77 fi
78}
e3bef725 79
33c820d6 80plan_tests $NUM_TESTS
9e32c5c0 81
e3bef725
CB
82print_test_banner "$TEST_DESC"
83
9e32c5c0
CB
84THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
85 "LTTNG_THREAD_MANAGE_APPS"
33c820d6 86 "LTTNG_THREAD_REG_APPS")
9e32c5c0
CB
87
88# Exit code value to indicate specific thread failure
33c820d6 89EXIT_CODE=(1 2 4)
9e32c5c0
CB
90
91THREAD_COUNT=${#THREAD[@]}
92i=0
93while [ "$i" -lt "$THREAD_COUNT" ]; do
94 test_thread_exit "${THREAD[$i]}" "${EXIT_CODE[$i]}"
95
96 if [ $? -eq 1 ]; then
97 exit 1
98 fi
99
100 let "i++"
101done
102
33c820d6
CB
103# The manage kernel thread is only spawned if we are root
104if [ "$(id -u)" == "0" ]; then
105 isroot=1
106else
107 isroot=0
108fi
109
110skip $isroot "Root access is needed. Skipping LTTNG_THREAD_MANAGE_KERNEL tests." "3" ||
111{
112 test_thread_exit "LTTNG_THREAD_MANAGE_KERNEL" "8"
113}
114
115
116# TODO: Special case manage consumer, need to spawn consumer via commands.
9e32c5c0 117#"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.033438 seconds and 5 git commands to generate.