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 | |
17 | ||
18 | CURDIR=$(dirname $0)/ | |
19 | TESTDIR=$CURDIR/../.. | |
20 | NR_ITER=100 | |
21 | SESSION_NAME="multi-session" | |
22 | EVENT_NAME="ust_gen_nevents:tptest" | |
23 | ||
24 | source $TESTDIR/utils.sh | |
25 | ||
26 | echo -e "\n--------------------------" | |
27 | echo -e "UST tracer - Multi-session" | |
28 | echo -e "--------------------------" | |
29 | ||
30 | if [ ! -x "$CURDIR/gen-nevents" ]; then | |
31 | echo -e "No UST nevents binary detected. Passing." | |
32 | exit 0 | |
33 | fi | |
34 | ||
35 | # MUST set TESTDIR before calling those functions | |
36 | ||
37 | test_multi_session() { | |
38 | local out | |
39 | ||
40 | # BEFORE application is spawned | |
41 | for i in `seq 0 3`; do | |
42 | create_lttng_session "$SESSION_NAME-$i" "$TRACE_PATH/$i" | |
43 | enable_ust_lttng_event "$SESSION_NAME-$i" "$EVENT_NAME$i" | |
44 | start_tracing "$SESSION_NAME-$i" | |
45 | done | |
46 | ||
47 | echo -n "Starting application generating $NR_ITER events... " | |
48 | ./$CURDIR/gen-nevents $NR_ITER & | |
49 | echo -e "\e[1;32mOK\e[0m" | |
50 | ||
51 | # At least hit one event | |
52 | echo -n "Waiting for events to record " | |
53 | while [ -n "$(pidof gen-nevents)" ]; do | |
54 | echo -n "." | |
55 | sleep 0.1 | |
56 | done | |
57 | echo -e "\e[1;32m OK\e[0m" | |
58 | ||
59 | for i in `seq 0 3`; do | |
60 | stop_tracing "$SESSION_NAME-$i" | |
61 | destroy_lttng_session "$SESSION_NAME-$i" | |
62 | out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l) | |
63 | if [ $out -ne $NR_ITER ]; then | |
64 | echo -n "No event found. Suppose to have at least one... " | |
65 | echo -e "\e[1;31mFAILED\e[0m" | |
66 | out=1 | |
67 | else | |
68 | echo -n "Found $out event(s) for $SESSION_NAME-$i. Coherent... " | |
69 | echo -e "\e[1;32mOK\e[0m" | |
70 | out=0 | |
71 | fi | |
72 | done | |
73 | ||
74 | return $out | |
75 | } | |
76 | ||
77 | # MUST set TESTDIR before calling those functions | |
78 | ||
79 | start_sessiond | |
80 | ||
81 | TRACE_PATH=$(mktemp -d) | |
82 | ||
83 | test_multi_session | |
84 | out=$? | |
85 | if [ $out -ne 0 ]; then | |
86 | stop_sessiond | |
87 | exit $out | |
88 | fi | |
89 | ||
90 | stop_sessiond | |
91 | ||
92 | rm -rf "$TRACE_PATH" |