Tests: Replace usage of gen-ust-events testapp in ust before-after test
[lttng-tools.git] / tests / regression / ust / before-after / test_before_after
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 TEST_DESC="UST tracer - Start tracing before and after execution"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../../..
21 NR_ITER=100
22 NR_USEC_WAIT=100000
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"
28 NUM_TESTS=16
29
30 source $TESTDIR/utils/utils.sh
31
32 if [ ! -x "$TESTAPP_BIN" ]; then
33 BAIL_OUT "No UST nevents binary detected."
34 fi
35
36 # MUST set TESTDIR before calling those functions
37
38 test_before_apps() {
39 # BEFORE application is spawned
40 create_lttng_session $SESSION_NAME $TRACE_PATH
41 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
42 start_lttng_tracing $SESSION_NAME
43
44 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
45 ok $? "Start application to trace"
46
47 stop_lttng_tracing $SESSION_NAME
48 destroy_lttng_session $SESSION_NAME
49
50 trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
51
52 return $?
53 }
54
55 test_after_apps() {
56 local out
57
58 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
59 ok $? "Start application to trace"
60
61 # BEFORE application is spawned
62 create_lttng_session $SESSION_NAME $TRACE_PATH
63 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
64 start_lttng_tracing $SESSION_NAME
65
66 # At least hit one event
67 sleep 2
68
69 stop_lttng_tracing $SESSION_NAME
70 destroy_lttng_session $SESSION_NAME
71
72 out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
73 if [ $out -eq 0 ]; then
74 fail "Trace validation"
75 diag "No event(s) found. We are supposed to have at least one."
76 out=1
77 else
78 pass "Trace validation"
79 diag "Found $out event(s). Coherent."
80 out=0
81 fi
82
83 return $out
84 }
85
86 # MUST set TESTDIR before calling those functions
87 plan_tests $NUM_TESTS
88
89 print_test_banner "$TEST_DESC"
90
91 start_lttng_sessiond
92
93 diag "Start application BEFORE tracing was started"
94
95 TRACE_PATH=$(mktemp -d)
96
97 test_before_apps
98 out=$?
99 if [ $out -ne 0 ]; then
100 stop_lttng_sessiond
101 exit $out
102 fi
103
104 rm -rf $TRACE_PATH
105
106 diag "Start application AFTER tracing was started"
107
108 TRACE_PATH=$(mktemp -d)
109
110 test_after_apps
111 out=$?
112 if [ $out -ne 0 ]; then
113 stop_lttng_sessiond
114 exit $out
115 fi
116
117 stop_lttng_sessiond
118
119 rm -rf $TRACE_PATH
This page took 0.034849 seconds and 6 git commands to generate.