Commit | Line | Data |
---|---|---|
00eb21af 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 | 17 | TEST_DESC="UST tracer - Multi-session" |
00eb21af DG |
18 | |
19 | CURDIR=$(dirname $0)/ | |
9ac429ef | 20 | TESTDIR=$CURDIR/../../.. |
00eb21af DG |
21 | NR_ITER=100 |
22 | SESSION_NAME="multi-session" | |
23 | EVENT_NAME="ust_gen_nevents:tptest" | |
c1f5d7d5 | 24 | NUM_TESTS=28 |
00eb21af | 25 | |
9ac429ef | 26 | source $TESTDIR/utils/utils.sh |
00eb21af | 27 | |
c38b5107 | 28 | print_test_banner "$TEST_DESC" |
00eb21af DG |
29 | |
30 | if [ ! -x "$CURDIR/gen-nevents" ]; then | |
c1f5d7d5 | 31 | BAIL_OUT "No UST nevents binary detected." |
00eb21af DG |
32 | fi |
33 | ||
34 | # MUST set TESTDIR before calling those functions | |
35 | ||
36 | test_multi_session() { | |
37 | local out | |
38 | ||
39 | # BEFORE application is spawned | |
40 | for i in `seq 0 3`; do | |
41 | create_lttng_session "$SESSION_NAME-$i" "$TRACE_PATH/$i" | |
42 | enable_ust_lttng_event "$SESSION_NAME-$i" "$EVENT_NAME$i" | |
fb3268e3 | 43 | start_lttng_tracing "$SESSION_NAME-$i" |
00eb21af DG |
44 | done |
45 | ||
00eb21af | 46 | ./$CURDIR/gen-nevents $NR_ITER & |
c1f5d7d5 | 47 | ok $? "Start application to generate $NR_ITER events" |
00eb21af DG |
48 | |
49 | # At least hit one event | |
00eb21af | 50 | while [ -n "$(pidof gen-nevents)" ]; do |
00eb21af DG |
51 | sleep 0.1 |
52 | done | |
c1f5d7d5 CB |
53 | |
54 | pass "Wait for events to record" | |
00eb21af DG |
55 | |
56 | for i in `seq 0 3`; do | |
fb3268e3 | 57 | stop_lttng_tracing "$SESSION_NAME-$i" |
00eb21af DG |
58 | destroy_lttng_session "$SESSION_NAME-$i" |
59 | out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l) | |
60 | if [ $out -ne $NR_ITER ]; then | |
c1f5d7d5 CB |
61 | fail "Trace validation of $SESSION_NAME-$i" |
62 | diag "No events found." | |
00eb21af | 63 | out=1 |
c1f5d7d5 | 64 | break |
00eb21af | 65 | else |
c1f5d7d5 CB |
66 | pass "Trace validation of $SESSION_NAME-$i" |
67 | diag "Found $out event(s) for $SESSION_NAME-$i." | |
00eb21af DG |
68 | out=0 |
69 | fi | |
70 | done | |
71 | ||
72 | return $out | |
73 | } | |
74 | ||
75 | # MUST set TESTDIR before calling those functions | |
76 | ||
c1f5d7d5 CB |
77 | plan_tests $NUM_TESTS |
78 | ||
fb3268e3 | 79 | start_lttng_sessiond |
00eb21af DG |
80 | |
81 | TRACE_PATH=$(mktemp -d) | |
82 | ||
83 | test_multi_session | |
84 | out=$? | |
85 | if [ $out -ne 0 ]; then | |
fb3268e3 | 86 | stop_lttng_sessiond |
00eb21af DG |
87 | exit $out |
88 | fi | |
89 | ||
fb3268e3 | 90 | stop_lttng_sessiond |
00eb21af DG |
91 | |
92 | rm -rf "$TRACE_PATH" |