Fix: Memory allocated by xmlNodeGetContent() must be freed by xmlFree()
[lttng-tools.git] / tests / regression / ust / before-after / test_before_after
... / ...
CommitLineData
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
17TEST_DESC="UST tracer - Start tracing before and after execution"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_ITER=100
22NR_USEC_WAIT=100000
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26SESSION_NAME="per-session"
27EVENT_NAME="tp:tptest"
28NUM_TESTS=16
29
30source $TESTDIR/utils/utils.sh
31
32if [ ! -x "$TESTAPP_BIN" ]; then
33 BAIL_OUT "No UST nevents binary detected."
34fi
35
36# MUST set TESTDIR before calling those functions
37
38function test_before_apps()
39{
40 # BEFORE application is spawned
41 create_lttng_session $SESSION_NAME $TRACE_PATH
42 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
43 start_lttng_tracing $SESSION_NAME
44
45 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
46 wait
47 ok $? "Traced application stopped."
48
49 stop_lttng_tracing $SESSION_NAME
50 destroy_lttng_session $SESSION_NAME
51
52 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
53
54 return $?
55}
56
57function test_after_apps()
58{
59 local out
60 local file_sync_after_first=$(mktemp -u)
61 local file_sync_before_last=$(mktemp -u)
62
63 create_lttng_session $SESSION_NAME $TRACE_PATH
64 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
65
66 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
67 ok $? "Application started in background."
68
69 start_lttng_tracing $SESSION_NAME
70
71 touch ${file_sync_before_last}
72
73 wait
74
75 stop_lttng_tracing $SESSION_NAME
76 destroy_lttng_session $SESSION_NAME
77
78 rm -f ${file_sync_after_first}
79 rm -f ${file_sync_before_last}
80
81 validate_trace $EVENT_NAME $TRACE_PATH
82 out=$?
83
84 return $out
85}
86
87# MUST set TESTDIR before calling those functions
88plan_tests $NUM_TESTS
89
90print_test_banner "$TEST_DESC"
91
92start_lttng_sessiond
93
94diag "Start tracing BEFORE application is started"
95
96TRACE_PATH=$(mktemp -d)
97
98test_before_apps
99out=$?
100if [ $out -ne 0 ]; then
101 stop_lttng_sessiond
102 exit $out
103fi
104
105rm -rf $TRACE_PATH
106
107diag "Start tracing AFTER application is started"
108
109TRACE_PATH=$(mktemp -d)
110
111test_after_apps
112out=$?
113if [ $out -ne 0 ]; then
114 stop_lttng_sessiond
115 exit $out
116fi
117
118stop_lttng_sessiond
119
120rm -rf $TRACE_PATH
This page took 0.02498 seconds and 5 git commands to generate.