Commit | Line | Data |
---|---|---|
1b368955 JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Julien Desfossez <julien.desfossez@efficios.com> | |
4 | # David Goulet <dgoulet@efficios.com> | |
5 | # | |
6 | # This library is free software; you can redistribute it and/or modify it under | |
7 | # the terms of the GNU Lesser General Public License as published by the Free | |
8 | # Software Foundation; version 2.1 of the License. | |
9 | # | |
10 | # This library is distributed in the hope that it will be useful, but WITHOUT | |
11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
12 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
13 | # details. | |
14 | # | |
15 | # You should have received a copy of the GNU Lesser General Public License | |
16 | # along with this library; if not, write to the Free Software Foundation, Inc., | |
17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | ||
19 | TEST_DESC="Live - User space tracing" | |
20 | ||
21 | CURDIR=$(dirname $0)/ | |
22 | TESTDIR=$CURDIR/../../../ | |
23 | SESSIOND_BIN="lttng-sessiond" | |
24 | RELAYD_BIN="lttng-relayd" | |
25 | LTTNG_BIN="lttng" | |
26 | BABELTRACE_BIN="babeltrace" | |
27 | NR_ITER=1 | |
28 | NR_USEC_WAIT=1 | |
29 | DELAY_USEC=2000000 | |
30 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
31 | TESTAPP_NAME="gen-ust-events" | |
32 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
33 | ||
34 | SESSION_NAME="live" | |
35 | EVENT_NAME="tp:tptest" | |
36 | ||
37 | TRACE_PATH=$(mktemp -d) | |
38 | ||
39 | DIR=$(readlink -f $TESTDIR) | |
40 | ||
41 | NUM_TESTS=10 | |
42 | ||
43 | source $TESTDIR/utils/utils.sh | |
44 | ||
45 | # MUST set TESTDIR before calling those functions | |
46 | plan_tests $NUM_TESTS | |
47 | ||
48 | print_test_banner "$TEST_DESC" | |
49 | ||
50 | function setup_live_tracing() | |
51 | { | |
52 | # Create session with default path | |
53 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live $DELAY_USEC \ | |
54 | -U net://localhost >/dev/null 2>&1 | |
55 | ok $? "Create session in live mode with delay $DELAY_USEC" | |
56 | ||
57 | enable_ust_lttng_event $SESSION_NAME $EVENT_NAME | |
58 | start_lttng_tracing $SESSION_NAME | |
59 | } | |
60 | ||
61 | function clean_live_tracing() | |
62 | { | |
63 | stop_lttng_tracing $SESSION_NAME | |
64 | destroy_lttng_session $SESSION_NAME | |
65 | } | |
66 | ||
67 | start_lttng_sessiond | |
68 | start_lttng_relayd "-o $TRACE_PATH" | |
69 | ||
70 | setup_live_tracing | |
71 | ||
72 | # Run app in background | |
73 | $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 & | |
74 | # Wait for app to complete | |
75 | while [ -n "$(pidof $TESTAPP_NAME)" ]; do | |
76 | sleep 0.5 | |
77 | done | |
78 | ||
79 | clean_live_tracing | |
80 | ||
81 | trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH | |
82 | rm -rf $TRACE_PATH | |
83 | ||
84 | stop_lttng_relayd | |
85 | stop_lttng_sessiond |