Commit | Line | Data |
---|---|---|
8679c86b CB |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com> | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify it | |
6 | # under the terms of the GNU General Public License, version 2 only, as | |
7 | # published by the Free Software Foundation. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | # more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License along with | |
15 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | ||
18 | TEST_DESC="UST tracer - Basic events" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../.. | |
22 | LTTNG_BIN="lttng" | |
23 | BIN_NAME="gen-ust-events" | |
24 | SESSION_NAME="valid_filter" | |
25 | EVENT_NAME="tp:tptest" | |
26 | NUM_TESTS=25 | |
27 | ||
28 | source $TESTDIR/utils/utils.sh | |
29 | ||
30 | print_test_banner "$TEST_DESC" | |
31 | ||
32 | function enable_ust_lttng_event_per_chan() | |
33 | { | |
34 | sess_name="$1" | |
35 | event_name="$2" | |
36 | chan_name="$3" | |
37 | ||
38 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1 | |
39 | ok $? "Enable event $event_name for session $sess_name in channel $chan_name" | |
40 | } | |
41 | ||
42 | function disable_ust_lttng_event_per_chan() | |
43 | { | |
44 | sess_name="$1" | |
45 | event_name="$2" | |
46 | chan_name="$3" | |
47 | ||
48 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1 | |
49 | ok $? "Disable event $event_name for session $sess_name in channel $chan_name" | |
50 | } | |
51 | ||
52 | function add_ust_lttng_context() | |
53 | { | |
54 | sess_name="$1" | |
55 | chan_name="$2" | |
56 | type="$3" | |
57 | ||
58 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1 | |
59 | ok $? "Add context $type for session $sess_name in channel $chan_name" | |
60 | } | |
61 | ||
62 | function test_event_basic() | |
63 | { | |
64 | TRACE_PATH=$(mktemp -d) | |
65 | SESSION_NAME="ust_event_basic" | |
66 | SESSION_NAME2="ust_event_basic2" | |
67 | CHAN_NAME="mychan" | |
68 | CHAN_NAME2="mychan2" | |
69 | EVENT_NAME="tp1" | |
70 | EVENT_NAME2="ev2" | |
71 | EVENT_NAME3="ev3" | |
72 | ||
73 | create_lttng_session $SESSION_NAME $TRACE_PATH | |
74 | create_lttng_session $SESSION_NAME2 $TRACE_PATH | |
75 | ||
76 | enable_ust_lttng_channel $SESSION_NAME $CHAN_NAME | |
77 | enable_ust_lttng_channel $SESSION_NAME2 $CHAN_NAME2 | |
78 | ||
79 | enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME | |
80 | enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME2 $CHAN_NAME | |
81 | enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2 | |
82 | ||
83 | add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vpid" | |
84 | add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vtid" | |
85 | add_ust_lttng_context $SESSION_NAME $CHAN_NAME "pthread_id" | |
86 | add_ust_lttng_context $SESSION_NAME $CHAN_NAME "procname" | |
87 | add_ust_lttng_context $SESSION_NAME2 $CHAN_NAME2 "procname" | |
88 | ||
89 | disable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME | |
90 | disable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2 | |
91 | ||
92 | enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME | |
93 | enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2 | |
94 | ||
95 | start_lttng_tracing | |
96 | stop_lttng_tracing | |
97 | ||
98 | start_lttng_tracing | |
99 | stop_lttng_tracing | |
100 | ||
101 | TODO="Validate trace output is coherent" | |
102 | ok 0 "Validate trace" | |
103 | unset TODO | |
104 | ||
105 | destroy_lttng_session $SESSION_NAME2 | |
106 | destroy_lttng_session $SESSION_NAME | |
107 | ||
108 | rm -rf $TRACE_PATH | |
109 | } | |
110 | ||
111 | # MUST set TESTDIR before calling those functions | |
112 | plan_tests $NUM_TESTS | |
113 | ||
114 | start_lttng_sessiond | |
115 | ||
116 | test_event_basic | |
117 | ||
118 | stop_lttng_sessiond |