3 # Copyright (C) - 2014 David Goulet <dgoulet@efficios.com>
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.
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
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
18 TEST_DESC
="Save session(s)"
21 TESTDIR
=$CURDIR/..
/..
/..
/
22 SESSIOND_BIN
="lttng-sessiond"
23 RELAYD_BIN
="lttng-relayd"
26 SESSION_NAME
="save-42"
27 CHANNEL_NAME
="chan-save"
28 EVENT_NAME
="tp:tptest"
30 DIR
=$
(readlink
-f $TESTDIR)
34 source $TESTDIR/utils
/utils.sh
36 # MUST set TESTDIR before calling those functions
39 print_test_banner
"$TEST_DESC"
42 function save_lttng_fail
()
47 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN save
$sess_name $opts >/dev
/null
2>&1
49 ok
0 "Session failed to be saved. Expected!"
51 ok
1 "Session has been saved. NOT expected!"
55 function is_session_saved
()
60 [ -f "$path/$name.lttng" ];
61 ok $?
"Session $name.lttng file found!"
64 function test_basic_save
()
66 diag
"Test basic save"
68 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
69 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME
70 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
71 lttng_track_ok
"-p 666 -u -s $SESSION_NAME"
73 lttng_save
$SESSION_NAME "-o $TRACE_PATH"
75 is_session_saved
$TRACE_PATH $SESSION_NAME
77 destroy_lttng_session_ok
$SESSION_NAME
80 function test_basic_save_all
()
82 diag
"Test basic save all"
84 create_lttng_session_ok
$SESSION_NAME-1 $TRACE_PATH
85 create_lttng_session_ok
$SESSION_NAME-2 $TRACE_PATH
86 create_lttng_session_ok
$SESSION_NAME-3 $TRACE_PATH
88 enable_ust_lttng_channel_ok
$SESSION_NAME-1 $CHANNEL_NAME
89 enable_ust_lttng_channel_ok
$SESSION_NAME-2 $CHANNEL_NAME
90 enable_ust_lttng_channel_ok
$SESSION_NAME-3 $CHANNEL_NAME
92 enable_ust_lttng_event_ok
$SESSION_NAME-1 $EVENT_NAME $CHANNEL_NAME
93 enable_ust_lttng_event_ok
$SESSION_NAME-2 $EVENT_NAME $CHANNEL_NAME
94 enable_ust_lttng_event_ok
$SESSION_NAME-3 $EVENT_NAME $CHANNEL_NAME
96 lttng_track_ok
"-p 666 -u -s $SESSION_NAME-1"
97 lttng_track_ok
"-p 666 -u -s $SESSION_NAME-2"
98 lttng_track_ok
"-p 666 -u -s $SESSION_NAME-3"
100 lttng_save
"" "-a -o $TRACE_PATH"
102 is_session_saved
$TRACE_PATH $SESSION_NAME-1
103 is_session_saved
$TRACE_PATH $SESSION_NAME-2
104 is_session_saved
$TRACE_PATH $SESSION_NAME-3
106 destroy_lttng_session_ok
$SESSION_NAME-1
107 destroy_lttng_session_ok
$SESSION_NAME-2
108 destroy_lttng_session_ok
$SESSION_NAME-3
111 function test_overwrite
()
113 diag
"Test overwrite session file"
115 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
116 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME
117 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
119 lttng_save
$SESSION_NAME "-o $TRACE_PATH"
121 is_session_saved
$TRACE_PATH $SESSION_NAME
123 destroy_lttng_session_ok
$SESSION_NAME
125 # Create a new session with same name so we can force the overwrite
126 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
127 enable_ust_lttng_channel_ok
$SESSION_NAME $CHANNEL_NAME
128 enable_ust_lttng_event_ok
$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
131 save_lttng_fail
$SESSION_NAME "-o $TRACE_PATH"
133 # This one MUST succeed
134 lttng_save
$SESSION_NAME "-f -o $TRACE_PATH"
136 is_session_saved
$TRACE_PATH $SESSION_NAME
138 destroy_lttng_session_ok
$SESSION_NAME
149 for fct_test
in ${TESTS[@]};
151 TRACE_PATH
=$
(mktemp
-d)
154 if [ $?
-ne 0 ]; then
157 # Only delete if successful