Fix: mark generated python bindings files as nodist
[lttng-tools.git] / tests / ust / before-after / run
CommitLineData
b19155c0
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
c38b5107 17TEST_DESC="UST tracer - Start tracing before and after execution"
b19155c0
DG
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../..
21NR_ITER=100
22SESSION_NAME="per-session"
23EVENT_NAME="ust_gen_nevents:tptest"
24
25source $TESTDIR/utils.sh
26
c38b5107 27print_test_banner "$TEST_DESC"
b19155c0
DG
28
29if [ ! -x "$CURDIR/gen-nevents" ]; then
30 echo -e "No UST nevents binary detected. Passing."
31 exit 0
32fi
33
34# MUST set TESTDIR before calling those functions
35
36test_before_apps() {
37 local out
38
39 # BEFORE application is spawned
40 create_lttng_session $SESSION_NAME $TRACE_PATH
41 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 42 start_lttng_tracing $SESSION_NAME
b19155c0
DG
43 # Start test
44 echo -n "Starting application... "
45 ./$CURDIR/gen-nevents $NR_ITER
c38b5107
CB
46 echo -n "Ended "
47 print_ok
fb3268e3 48 stop_lttng_tracing $SESSION_NAME
b19155c0
DG
49 destroy_lttng_session $SESSION_NAME
50
51 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
52
53 return $?
54}
55
56test_after_apps() {
57 local out
58
59 echo -n "Starting application... "
60 ./$CURDIR/gen-nevents 100 &
c38b5107 61 print_ok
b19155c0
DG
62
63 # BEFORE application is spawned
64 create_lttng_session $SESSION_NAME $TRACE_PATH
65 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
fb3268e3 66 start_lttng_tracing $SESSION_NAME
b19155c0
DG
67
68 # At least hit one event
69 sleep 2
70
fb3268e3 71 stop_lttng_tracing $SESSION_NAME
b19155c0
DG
72 destroy_lttng_session $SESSION_NAME
73
74 out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
75 if [ $out -eq 0 ]; then
76 echo -n "No event found. Suppose to have at least one... "
c38b5107 77 print_fail
b19155c0
DG
78 out=1
79 else
80 echo -n "Found $out event(s). Coherent... "
c38b5107 81 print_ok
b19155c0
DG
82 out=0
83 fi
84
85 return $out
86}
87
88# MUST set TESTDIR before calling those functions
89
fb3268e3 90start_lttng_sessiond
b19155c0
DG
91
92echo ""
93echo "=== Start application BEFORE tracing was started ==="
94
95TRACE_PATH=$(mktemp -d)
96
97test_before_apps
98out=$?
99if [ $out -ne 0 ]; then
fb3268e3 100 stop_lttng_sessiond
b19155c0
DG
101 exit $out
102fi
103
104rm -rf $TRACE_PATH
105
106echo ""
107echo "=== Start application AFTER tracing was started ==="
108
109TRACE_PATH=$(mktemp -d)
110
111test_after_apps
112out=$?
113if [ $out -ne 0 ]; then
fb3268e3 114 stop_lttng_sessiond
b19155c0
DG
115 exit $out
116fi
117
fb3268e3 118stop_lttng_sessiond
b19155c0
DG
119
120rm -rf $TRACE_PATH
This page took 0.02862 seconds and 4 git commands to generate.