Gen-ust-events: use options instead of arguments
[lttng-tools.git] / tests / regression / tools / health / test_thread_ok
1 #!/bin/bash
2 #
3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 # Copyright (C) - 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 #
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License, version 2 only, as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
14 #
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 51
17 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 TEST_DESC="Health check - Thread OK"
20
21 CURDIR=$(dirname $0)/
22 TESTDIR=$CURDIR/../../..
23 SESSION_NAME="health_thread_ok"
24 UST_EVENT_NAME="tp:tptest"
25 KERNEL_EVENT_NAME="sched_switch"
26 CHANNEL_NAME="testchan"
27 HEALTH_CHECK_BIN="health_check"
28 NUM_TESTS=17
29 SLEEP_TIME=30
30
31 source $TESTDIR/utils/utils.sh
32
33 function report_errors
34 {
35 # Report health errors
36 out=$(cat ${STDOUT_PATH} | wc -l)
37 if [ $out -ne 0 ]; then
38 fail "Validation failure"
39 diag "Health returned:"
40 diag "stdout:"
41 file=${STDOUT_PATH}
42 while read line ; do
43 diag "$line"
44 done < ${file}
45
46 diag "stderr:"
47 file=${STDERR_PATH}
48 while read line ; do
49 diag "$line"
50 done < ${file}
51 else
52 pass "Validation OK"
53 fi
54 }
55
56 function test_thread_ok
57 {
58 diag "Test health OK"
59
60 # Set the socket timeout to 5 so the health check delta is set to 25.
61 export LTTNG_NETWORK_SOCKET_TIMEOUT=5
62 export LTTNG_RELAYD_HEALTH="${HEALTH_PATH}/test-health"
63
64 diag "Only session daemon"
65 start_lttng_sessiond
66
67 # Check health status
68 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
69 report_errors
70
71 diag "With UST consumer daemons"
72 create_lttng_session_no_output $SESSION_NAME
73 enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
74 start_lttng_tracing_ok $SESSION_NAME
75 destroy_lttng_session_ok $SESSION_NAME
76
77 # Check health status
78 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
79 report_errors
80
81 skip $isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
82 {
83 diag "With kernel consumer daemon"
84 create_lttng_session_no_output $SESSION_NAME
85 lttng_enable_kernel_event $SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
86 start_lttng_tracing_ok $SESSION_NAME
87 destroy_lttng_session_ok $SESSION_NAME
88
89 # Check health status
90 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
91 report_errors
92 }
93
94 diag "With relay daemon"
95
96 start_lttng_relayd "-o $TRACE_PATH"
97 # Check health status
98 $CURDIR/$HEALTH_CHECK_BIN \
99 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
100 > ${STDOUT_PATH} 2> ${STDERR_PATH}
101 report_errors
102
103 # Wait
104 diag "Check after running for ${SLEEP_TIME} seconds"
105 sleep ${SLEEP_TIME}
106
107 # Check health status
108 $CURDIR/$HEALTH_CHECK_BIN \
109 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
110 > ${STDOUT_PATH} 2> ${STDERR_PATH}
111 report_errors
112
113 stop_lttng_relayd
114 stop_lttng_sessiond
115
116 unset LTTNG_NETWORK_SOCKET_TIMEOUT
117 unset LTTNG_RELAYD_HEALTH
118 }
119
120 plan_tests $NUM_TESTS
121
122 print_test_banner "$TEST_DESC"
123
124 STDOUT_PATH=$(mktemp)
125 STDERR_PATH=$(mktemp)
126 TRACE_PATH=$(mktemp -d)
127 HEALTH_PATH=$(mktemp -d)
128
129 # The manage kernel thread is only spawned if we are root
130 if [ "$(id -u)" == "0" ]; then
131 isroot=1
132 else
133 isroot=0
134 fi
135
136 test_thread_ok
137
138 rm -rf ${HEALTH_PATH}
139 rm -rf ${TRACE_PATH}
140 rm -f ${STDOUT_PATH}
141 rm -f ${STDERR_PATH}
This page took 0.034315 seconds and 5 git commands to generate.