Test: save/load: pid_tracker basic test
[lttng-tools.git] / tests / regression / tools / save-load / test_load
CommitLineData
e02b109b
DG
1#!/bin/bash
2#
3# Copyright (C) - 2014 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
18TEST_DESC="Load session(s)"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../../
22SESSIOND_BIN="lttng-sessiond"
23RELAYD_BIN="lttng-relayd"
24LTTNG_BIN="lttng"
742e5f18 25export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
e02b109b
DG
26
27SESSION_NAME="load-42"
28EVENT_NAME="tp:tptest"
29
30DIR=$(readlink -f $TESTDIR)
31
722f854b 32NUM_TESTS=26
e02b109b
DG
33
34source $TESTDIR/utils/utils.sh
35
36# MUST set TESTDIR before calling those functions
37plan_tests $NUM_TESTS
38
39print_test_banner "$TEST_DESC"
40
e02b109b
DG
41function test_basic_load()
42{
43 diag "Test basic load"
44
83b7c3bf 45 lttng_load "-i $CURDIR/$SESSION_NAME.lttng"
e02b109b 46
67b4c664 47 destroy_lttng_session_ok $SESSION_NAME
e02b109b
DG
48}
49
50function test_complex_load()
51{
52 local sess="$SESSION_NAME-complex"
53 diag "Test complex load"
54
55 # Start relayd with localhost binding. The complex session uses those
56 # custom values.
57 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
58
83b7c3bf 59 lttng_load "-i $CURDIR/$sess.lttng"
e02b109b
DG
60
61 # Once loaded, we are suppose to be able to disable certain events/channels
62 # thus having a confirmation that it's valid
722f854b
JR
63 disable_ust_lttng_event $sess uevent1 chan1
64 disable_ust_lttng_event $sess uevent2 chan2
65 disable_ust_lttng_event $sess uevent3* chan3
e02b109b
DG
66
67 disable_ust_lttng_channel $sess chan1
68 disable_ust_lttng_channel $sess chan2
69 disable_ust_lttng_channel $sess chan3
70
ea05d84b
JG
71 # Confirm that an event stored as disabled is restored in its disabled state
72 local mi_output_file=$(mktemp)
73 if [ $? -ne 0 ]; then
74 break;
75 fi
373ff56c 76 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file
ea05d84b
JG
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"
80 else
81 fail "Disabled event is loaded in disabled state"
82 fi
67b4c664 83 destroy_lttng_session_ok $sess
e02b109b
DG
84
85 stop_lttng_relayd_nocheck
86}
87
88function test_all_load()
89{
90 diag "Test load all sessions"
91
92 # Start relayd with localhost binding. The complex session uses those
93 # custom values.
94 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
95
96 lttng_load "-a -i $CURDIR"
97
67b4c664
JR
98 destroy_lttng_session_ok $SESSION_NAME
99 destroy_lttng_session_ok "$SESSION_NAME-complex"
722f854b 100 destroy_lttng_session_ok "$SESSION_NAME-trackers"
e02b109b
DG
101
102 stop_lttng_relayd_nocheck
103}
104
105function test_overwrite()
106{
107 diag "Test load overwrite"
108
83b7c3bf 109 lttng_load "-i $CURDIR/$SESSION_NAME.lttng"
e02b109b
DG
110
111 # This one should succeed
11143783 112 lttng_load "-f -i $CURDIR $SESSION_NAME"
e02b109b 113
67b4c664 114 destroy_lttng_session_ok $SESSION_NAME
e02b109b
DG
115}
116
722f854b
JR
117function test_trackers()
118{
119 diag "Test trackers loading"
120
121 lttng_load "-i $CURDIR/$SESSION_NAME-trackers.lttng"
122
123 diag "Test pid tracker"
124 local mi_output_file=$(mktemp)
125 if [ $? -ne 0 ]; then
126 break;
127 fi
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"
132 else
133 fail "Pid target missing"
134 fi
135
136 # Test to remove the target just to make sure
137 lttng_untrack_ok "-p 666 -u -s $SESSION_NAME-trackers"
138
139 destroy_lttng_session_ok "$SESSION_NAME-trackers"
140}
141
e02b109b
DG
142start_lttng_sessiond
143
144TESTS=(
145 test_basic_load
146 test_complex_load
147 test_all_load
148 test_overwrite
722f854b 149 test_trackers
e02b109b
DG
150)
151
152for fct_test in ${TESTS[@]};
153do
154 TRACE_PATH=$(mktemp -d)
155
156 ${fct_test}
157 if [ $? -ne 0 ]; then
158 break;
159 fi
160 # Only delete if successful
161 rm -rf $TRACE_PATH
162done
163
164stop_lttng_sessiond
This page took 0.036071 seconds and 5 git commands to generate.