3 # Copyright (C) - 2012 David Goulet <dgoulet@efficios.com>
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.
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
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 TEST_DESC
="UST tracer - Start tracing before and after execution"
20 TESTDIR
=$CURDIR/..
/..
/..
23 TESTAPP_PATH
="$TESTDIR/utils/testapp"
24 TESTAPP_NAME
="gen-ust-events"
25 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26 SESSION_NAME
="per-session"
27 EVENT_NAME
="tp:tptest"
30 source $TESTDIR/utils
/utils.sh
32 if [ ! -x "$TESTAPP_BIN" ]; then
33 BAIL_OUT
"No UST nevents binary detected."
36 # MUST set TESTDIR before calling those functions
38 function test_before_apps
()
40 # BEFORE application is spawned
41 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
42 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
43 start_lttng_tracing_ok
$SESSION_NAME
45 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
47 ok $?
"Traced application stopped."
49 stop_lttng_tracing_ok
$SESSION_NAME
50 destroy_lttng_session_ok
$SESSION_NAME
52 trace_match_only
$EVENT_NAME $NR_ITER $TRACE_PATH
57 function test_after_apps
()
60 local file_sync_after_first
=$
(mktemp
-u)
61 local file_sync_before_last
=$
(mktemp
-u)
63 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
64 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME
66 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} &
67 ok $?
"Application started in background."
69 start_lttng_tracing_ok
$SESSION_NAME
71 touch ${file_sync_before_last}
75 stop_lttng_tracing_ok
$SESSION_NAME
76 destroy_lttng_session_ok
$SESSION_NAME
78 rm -f ${file_sync_after_first}
79 rm -f ${file_sync_before_last}
81 validate_trace
$EVENT_NAME $TRACE_PATH
87 # MUST set TESTDIR before calling those functions
90 print_test_banner
"$TEST_DESC"
94 diag
"Start tracing BEFORE application is started"
96 TRACE_PATH
=$
(mktemp
-d)
100 if [ $out -ne 0 ]; then
107 diag
"Start tracing AFTER application is started"
109 TRACE_PATH
=$
(mktemp
-d)
113 if [ $out -ne 0 ]; then