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
="Load session(s)"
21 TESTDIR
=$CURDIR/..
/..
/..
/
22 SESSIOND_BIN
="lttng-sessiond"
23 RELAYD_BIN
="lttng-relayd"
25 export LTTNG_SESSION_CONFIG_XSD_PATH
=$
(readlink
-m ${TESTDIR}..
/src
/common
/config
/)
27 SESSION_NAME
="load-42"
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"
41 function test_basic_load
()
43 diag
"Test basic load"
45 lttng_load
"-i $CURDIR/$SESSION_NAME.lttng"
47 destroy_lttng_session_ok
$SESSION_NAME
50 function test_complex_load
()
52 local sess
="$SESSION_NAME-complex"
53 diag
"Test complex load"
55 # Start relayd with localhost binding. The complex session uses those
57 start_lttng_relayd
"-C tcp://localhost:8172 -D tcp://localhost:9817"
59 lttng_load
"-i $CURDIR/$sess.lttng"
61 # Once loaded, we are suppose to be able to disable certain events/channels
62 # thus having a confirmation that it's valid
63 disable_ust_lttng_event
$sess uevent1 chan1
64 disable_ust_lttng_event
$sess uevent2 chan2
65 disable_ust_lttng_event
$sess uevent3
* chan3
67 disable_ust_lttng_channel
$sess chan1
68 disable_ust_lttng_channel
$sess chan2
69 disable_ust_lttng_channel
$sess chan3
71 # Confirm that an event stored as disabled is restored in its disabled state
72 local mi_output_file
=$
(mktemp
)
76 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
$sess -c chan2
> $mi_output_file
77 mi_result
=$
($CURDIR/..
/mi
/extract_xml
$mi_output_file "//command/output/sessions/session/domains/domain/channels/channel[name='chan2']/events/event[name='uevent_disabled']/enabled/text()")
78 if [[ $mi_result = "false" ]]; then
79 ok
0 "Disabled event is loaded in disabled state"
81 fail
"Disabled event is loaded in disabled state"
83 destroy_lttng_session_ok
$sess
88 function test_all_load
()
90 diag
"Test load all sessions"
92 # Start relayd with localhost binding. The complex session uses those
94 start_lttng_relayd
"-C tcp://localhost:8172 -D tcp://localhost:9817"
96 lttng_load
"-a -i $CURDIR"
98 destroy_lttng_session_ok
$SESSION_NAME
99 destroy_lttng_session_ok
"$SESSION_NAME-complex"
100 destroy_lttng_session_ok
"$SESSION_NAME-trackers"
105 function test_overwrite
()
107 diag
"Test load overwrite"
109 lttng_load
"-i $CURDIR/$SESSION_NAME.lttng"
111 # This one should succeed
112 lttng_load
"-f -i $CURDIR $SESSION_NAME"
114 destroy_lttng_session_ok
$SESSION_NAME
117 function test_trackers
()
119 diag
"Test trackers loading"
121 lttng_load
"-i $CURDIR/$SESSION_NAME-trackers.lttng"
123 diag
"Test pid tracker"
124 local mi_output_file
=$
(mktemp
)
125 if [ $?
-ne 0 ]; then
128 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN --mi XML list
"$SESSION_NAME-trackers" > $mi_output_file
129 mi_result
=$
($CURDIR/..
/mi
/extract_xml
-e $mi_output_file "//command/output/sessions/session/domains/domain/trackers/pid_tracker/targets/pid_target")
130 if [[ $mi_result = "true" ]]; then
131 ok
0 "Pid target is present"
133 fail
"Pid target missing"
136 # Test to remove the target just to make sure
137 lttng_untrack_ok
"-p 666 -u -s $SESSION_NAME-trackers"
139 destroy_lttng_session_ok
"$SESSION_NAME-trackers"
152 for fct_test
in ${TESTS[@]};
154 TRACE_PATH
=$
(mktemp
-d)
157 if [ $?
-ne 0 ]; then
160 # Only delete if successful