Add UST and kernel streaming tests
[lttng-tools.git] / tests / tools / streaming / run-kernel
CommitLineData
f4e40ab6
DG
1#!/bin/bash
2#
3# Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18CURDIR=$(dirname $0)/
19TESTDIR=$CURDIR/../..
20EVENT_NAME="sched_switch"
21PID_RELAYD=0
22SESSION_NAME=""
23
24source $TESTDIR/utils.sh
25
26echo -e "\n---------------------------"
27echo -e " Streaming - Kernel tracing "
28echo -e "----------------------------"
29
30if [ "$(id -u)" != "0" ]; then
31 echo "This test must be running as root. Aborting"
32 # Exit status 0 so the tests can continue
33 exit 0
34fi
35
36# LTTng kernel modules check
37out=`ls /lib/modules/$(uname -r)/extra | grep lttng`
38if [ -z "$out" ]; then
39 echo "LTTng modules not detected. Aborting kernel tests!"
40 echo ""
41 # Exit status 0 so the tests can continue
42 exit 0
43fi
44
45function lttng_create_session
46{
47 echo -n "Creating session $SESSION_NAME... "
48 # Create session with default path
49 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
50 if [ $? -eq 1 ]; then
51 echo -e '\e[1;31mFAILED\e[0m'
52 return 1
53 else
54 echo -e "\e[1;32mOK\e[0m"
55 fi
56}
57
58function lttng_enable_consumer_localhost
59{
60 echo -n "Enabling network consumer... "
61 # Create session with default path
62 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -k net://localhost >/dev/null 2>&1
63 if [ $? -eq 1 ]; then
64 echo -e '\e[1;31mFAILED\e[0m'
65 return 1
66 else
67 echo -e "\e[1;32mOK\e[0m"
68 fi
69}
70
71function test_kernel_before_start ()
72{
73 echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
74 lttng_create_session
75 lttng_enable_consumer_localhost
76 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
77 start_tracing $SESSION_NAME
78 # Give a second
79 sleep 1
80 stop_tracing $SESSION_NAME
81 destroy_lttng_session $SESSION_NAME
82}
83
84function test_kernel_after_start ()
85{
86 echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
87 lttng_create_session
88 lttng_enable_consumer_localhost
89 start_tracing $SESSION_NAME
90 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
91 # Give a second
92 sleep 1
93 stop_tracing $SESSION_NAME
94 destroy_lttng_session $SESSION_NAME
95}
96
97start_sessiond
98lttng_start_relayd
99
100tests=( test_kernel_before_start test_kernel_after_start )
101
102for fct_test in ${tests[@]};
103do
104 SESSION_NAME=$(randstring 16 0)
105 ${fct_test}
106
107 # Validate test
108 validate_trace $EVENT_NAME ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
109 if [ $? -eq 0 ]; then
110 # Only delete if successful
111 rm -rf ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
112 rm -rf ~/lttng-traces/$SESSION_NAME*
113 else
114 break
115 fi
116done
117
118echo ""
119stop_sessiond
120lttng_stop_relayd
121
122
123exit $out
This page took 0.027939 seconds and 5 git commands to generate.