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 | |
00eb21af | 28 | if [ ! -x "$CURDIR/gen-nevents" ]; then |
c1f5d7d5 | 29 | BAIL_OUT "No UST nevents binary detected." |
00eb21af DG |
30 | fi |
31 | ||
32 | # MUST set TESTDIR before calling those functions | |
33 | ||
34 | test_multi_session() { | |
35 | local out | |
36 | ||
37 | # BEFORE application is spawned | |
38 | for i in `seq 0 3`; do | |
bf6ae429 | 39 | create_lttng_session_ok "$SESSION_NAME-$i" "$TRACE_PATH/$i" |
c4926bb5 | 40 | enable_ust_lttng_event_ok "$SESSION_NAME-$i" "$EVENT_NAME$i" |
e563bbdb | 41 | start_lttng_tracing_ok "$SESSION_NAME-$i" |
00eb21af DG |
42 | done |
43 | ||
00eb21af | 44 | ./$CURDIR/gen-nevents $NR_ITER & |
c1f5d7d5 | 45 | ok $? "Start application to generate $NR_ITER events" |
00eb21af | 46 | |
c7613334 | 47 | wait |
c1f5d7d5 | 48 | pass "Wait for events to record" |
00eb21af DG |
49 | |
50 | for i in `seq 0 3`; do | |
96340a01 | 51 | stop_lttng_tracing_ok "$SESSION_NAME-$i" |
67b4c664 | 52 | destroy_lttng_session_ok "$SESSION_NAME-$i" |
00eb21af DG |
53 | out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l) |
54 | if [ $out -ne $NR_ITER ]; then | |
c1f5d7d5 CB |
55 | fail "Trace validation of $SESSION_NAME-$i" |
56 | diag "No events found." | |
00eb21af | 57 | out=1 |
c1f5d7d5 | 58 | break |
00eb21af | 59 | else |
c1f5d7d5 CB |
60 | pass "Trace validation of $SESSION_NAME-$i" |
61 | diag "Found $out event(s) for $SESSION_NAME-$i." | |
00eb21af DG |
62 | out=0 |
63 | fi | |
64 | done | |
65 | ||
66 | return $out | |
67 | } | |
68 | ||
69 | # MUST set TESTDIR before calling those functions | |
70 | ||
c1f5d7d5 CB |
71 | plan_tests $NUM_TESTS |
72 | ||
e3bef725 CB |
73 | print_test_banner "$TEST_DESC" |
74 | ||
fb3268e3 | 75 | start_lttng_sessiond |
00eb21af DG |
76 | |
77 | TRACE_PATH=$(mktemp -d) | |
78 | ||
79 | test_multi_session | |
80 | out=$? | |
81 | if [ $out -ne 0 ]; then | |
fb3268e3 | 82 | stop_lttng_sessiond |
00eb21af DG |
83 | exit $out |
84 | fi | |
85 | ||
fb3268e3 | 86 | stop_lttng_sessiond |
00eb21af DG |
87 | |
88 | rm -rf "$TRACE_PATH" |