Refactor: test: wrapper for stop_lttng_tracing
[lttng-tools.git] / tests / regression / ust / test_event_perf
CommitLineData
bb8ec90d
JD
1#!/bin/bash
2#
3# Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com>
4# Copyright (C) - 2014 Julien Desfossez <jdesfossez@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
19TEST_DESC="UST tracer - Perf counters"
20
21CURDIR=$(dirname $0)/
22TESTDIR=$CURDIR/../..
23LTTNG_BIN="lttng"
24SESSION_NAME="perf_counters"
25EVENT_NAME="tp:tptest"
26NUM_TESTS=10
27NR_ITER=1
28NR_USEC_WAIT=1
29TESTAPP_PATH="$TESTDIR/utils/testapp"
30TESTAPP_NAME="gen-ust-events"
31TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
32
33source $TESTDIR/utils/utils.sh
34
35function enable_ust_lttng_event_per_chan()
36{
37 sess_name="$1"
38 event_name="$2"
39 chan_name="$3"
40
41 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
42 ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
43}
44
45function add_ust_lttng_context()
46{
47 sess_name="$1"
48 chan_name="$2"
49 type="$3"
50
51 $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1
52 ok $? "Add context $type for session $sess_name in channel $chan_name"
53}
54
55function test_event_basic()
56{
57 TRACE_PATH=$(mktemp -d)
58 SESSION_NAME="ust_event_basic"
59 CHAN_NAME="mychan"
60
bf6ae429 61 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
bb8ec90d 62
827caf52 63 enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
bb8ec90d
JD
64
65 enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
66
67 add_ust_lttng_context $SESSION_NAME $CHAN_NAME "perf:thread:page-fault"
68
e563bbdb 69 start_lttng_tracing_ok
bb8ec90d
JD
70
71 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
72
96340a01 73 stop_lttng_tracing_ok
bb8ec90d
JD
74
75 destroy_lttng_session $SESSION_NAME
76
77 validate_trace "perf_thread_page_fault" $TRACE_PATH
78 rm -rf $TRACE_PATH
79}
80
c1e454f7
JD
81uname -m|grep x86 >/dev/null
82if test $? != 0; then
83 plan_tests 1
84 ok 0 "This test only runs on x86"
85 exit 0
86fi
87
bb8ec90d
JD
88# MUST set TESTDIR before calling those functions
89plan_tests $NUM_TESTS
90
91print_test_banner "$TEST_DESC"
92
93start_lttng_sessiond
94
95test_event_basic
96
97stop_lttng_sessiond
This page took 0.030379 seconds and 5 git commands to generate.