Tests: Convert the tools health tests output to TAP
[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
CB
30
31print_test_banner "$TEST_DESC"
32
a863986c 33if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
33c820d6 34 BAIL_OUT "libhealthexit.so not available for this test."
9e32c5c0
CB
35fi
36
37function test_thread_exit
38{
39 test_thread_exit_name="$1"
40 test_thread_exit_code="$2"
41
33c820d6 42 diag "Test health failure with ${test_thread_exit_name}"
9e32c5c0
CB
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
9e32c5c0
CB
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
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}
33c820d6 81plan_tests $NUM_TESTS
9e32c5c0
CB
82
83THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
84 "LTTNG_THREAD_MANAGE_APPS"
33c820d6 85 "LTTNG_THREAD_REG_APPS")
9e32c5c0
CB
86
87# Exit code value to indicate specific thread failure
33c820d6 88EXIT_CODE=(1 2 4)
9e32c5c0
CB
89
90THREAD_COUNT=${#THREAD[@]}
91i=0
92while [ "$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++"
100done
101
33c820d6
CB
102# The manage kernel thread is only spawned if we are root
103if [ "$(id -u)" == "0" ]; then
104 isroot=1
105else
106 isroot=0
107fi
108
109skip $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.
9e32c5c0 116#"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.027745 seconds and 4 git commands to generate.