Tests: Fix first line of output to follow TAP guidelines
[lttng-tools.git] / tests / regression / tools / health / test_tp_fail
CommitLineData
6b5133f2
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 - Testpoint failure"
19
20CURDIR=$(dirname $0)/
9ac429ef 21TESTDIR=$CURDIR/../../..
6b5133f2
CB
22LTTNG_BIN="lttng"
23SESSION_NAME="health_tp_fail"
24EVENT_NAME="bogus"
25HEALTH_CHECK_BIN="health_check"
26SESSIOND_PRELOAD=".libs/libhealthtpfail.so"
33c820d6 27NUM_TESTS=9
6b5133f2 28
9ac429ef 29source $TESTDIR/utils/utils.sh
6b5133f2 30
6b5133f2 31if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
33c820d6 32 BAIL_OUT "libhealthtpfail.so not available for this test."
6b5133f2
CB
33fi
34
35function test_tp_fail
36{
37 test_tp_fail_name="$1"
38 test_tp_fail_code="$2"
39
33c820d6 40 diag "Test health failure with ${test_tp_fail_name}"
6b5133f2
CB
41
42 # Activate testpoints
43 export LTTNG_TESTPOINT_ENABLE=1
44
45 # Activate specific testpoint failure
46 export ${test_tp_fail_name}_TP_FAIL=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_tp_fail_name}_TP_FAIL
55
6b5133f2
CB
56 # Check health status, exit code should indicate failure
57 $CURDIR/$HEALTH_CHECK_BIN &> /dev/null
58
59 health_check_exit_code=$?
60
61 if [ $health_check_exit_code -eq $test_tp_fail_code ]; then
33c820d6 62 pass "Validate thread ${test_tp_fail_name} failure"
6b5133f2
CB
63 stop_lttng_sessiond
64 else
33c820d6
CB
65 fail "Validate thread ${test_tp_fail_name} failure"
66 diag "Health returned: $health_check_exit_code"
6b5133f2
CB
67 stop_lttng_sessiond
68 return 1
69 fi
70}
71
33c820d6
CB
72plan_tests $NUM_TESTS
73
e3bef725
CB
74print_test_banner "$TEST_DESC"
75
6b5133f2 76THREAD=("LTTNG_THREAD_MANAGE_CLIENTS"
33c820d6 77 "LTTNG_THREAD_MANAGE_APPS")
6b5133f2
CB
78
79# Exit code value to indicate specific thread failure
33c820d6 80EXIT_CODE=(1 2)
6b5133f2
CB
81
82THREAD_COUNT=${#THREAD[@]}
83i=0
84while [ "$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++"
92done
93
33c820d6
CB
94# The manage kernel thread is only spawned if we are root
95if [ "$(id -u)" == "0" ]; then
96 isroot=1
97else
98 isroot=0
99fi
100
101skip $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.
6b5133f2 108#"LTTNG_THREAD_MANAGE_CONSUMER"
This page took 0.026732 seconds and 4 git commands to generate.