Tests: PID_RELAYD is never used
[lttng-tools.git] / tests / regression / tools / rotation / test_save_load_mi
CommitLineData
e7716c6a
JD
1#!/bin/bash
2#
3# Copyright (C) - 2017 Julien Desfossez <jdesfossez@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="Rotation - Save/Load/List/MI"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../..
22SESSION_NAME="stream"
23
24TRACE_PATH=$(mktemp -d)
25
308a8946 26NUM_TESTS=22
e7716c6a
JD
27
28source $TESTDIR/utils/utils.sh
29source $CURDIR/rotate_utils.sh
30
31#Overwrite the lttng_bin to get mi output
32LTTNG_BIN="lttng --mi xml"
33
e7716c6a
JD
34XSD_PATH=$TESTDIR/../src/common/mi-lttng-3.0.xsd
35
36XML_VALIDATE="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH"
37XML_EXTRACT="$TESTDIR/regression/tools/mi/extract_xml"
38
39XPATH_CMD_OUTPUT="//lttng:command/lttng:output"
40XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
41XPATH_ROTATE_SETUP="$XPATH_CMD_OUTPUT/lttng:rotation_schedule"
42
308a8946 43function test_save_load_mi ()
e7716c6a
JD
44{
45 tmp_xml_output=$(mktemp -u)
46 tmp_save_output=$(mktemp -d)
47
48 diag "Test save/load/list/MI with rotation"
49 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
50 enable_ust_lttng_event_ok $SESSION_NAME -a
51
52 # Enable a rotation timer and check the MI output of the command
308a8946
JR
53
54 OUTPUT_DEST=${tmp_xml_output}
55 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
e7716c6a
JD
56 $XML_VALIDATE ${tmp_xml_output}
57 ok $? "Valid lttng enable-rotation timer XML"
308a8946 58
e7716c6a
JD
59 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_ROTATE_SETUP}/lttng:rotation_schedule_timer_period)
60 test $value = 500000
61 ok $? "Found the right rotation timer value in XML"
62
63 # Enable a rotation size and check the MI output of the command
308a8946 64 lttng_enable_rotation_size_ok $SESSION_NAME 500k
e7716c6a
JD
65 $XML_VALIDATE ${tmp_xml_output}
66 ok $? "Valid lttng enable-rotation size XML"
308a8946 67
e7716c6a
JD
68 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_ROTATE_SETUP}/lttng:rotation_schedule_size)
69 test $value = 512000
70 ok $? "Found the right rotation size value in XML"
71
72 # Check the output of lttng list with the 2 rotation parameters
308a8946 73 list_lttng_with_opts $SESSION_NAME
e7716c6a
JD
74 $XML_VALIDATE ${tmp_xml_output}
75 ok $? "Valid lttng list XML"
308a8946 76
e7716c6a
JD
77 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_SESSION}/lttng:rotation_schedule_timer_period)
78 test $value = 500000
79 ok $? "Found the right rotation timer value in list XML"
308a8946 80
e7716c6a
JD
81 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_SESSION}/lttng:rotation_schedule_size)
82 test $value = 512000
83 ok $? "Found the right rotation size value in list XML"
84
85 # save, destroy and reload the same session
308a8946
JR
86 OUTPUT_DEST=/dev/null
87 lttng_save $SESSION_NAME "-o $tmp_save_output$SESSION_NAME"
88 destroy_lttng_session_ok $SESSION_NAME
89 lttng_load_ok "-i $tmp_save_output$SESSION_NAME"
e7716c6a 90
308a8946 91 OUTPUT_DEST=${tmp_xml_output}
e7716c6a 92 # Check the output of lttng list with the 2 rotation parameters after the load
308a8946 93 list_lttng_with_opts $SESSION_NAME
e7716c6a
JD
94 $XML_VALIDATE ${tmp_xml_output}
95 ok $? "Valid lttng list XML after load"
308a8946 96
e7716c6a
JD
97 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_SESSION}/lttng:rotation_schedule_timer_period)
98 test $value = 500000
99 ok $? "Found the right rotation timer value in list XML after load"
308a8946 100
e7716c6a
JD
101 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_SESSION}/lttng:rotation_schedule_size)
102 test $value = 512000
103 ok $? "Found the right rotation size value in list XML after load"
104
308a8946
JR
105 OUTPUT_DEST=/dev/null
106 destroy_lttng_session_ok $SESSION_NAME
e7716c6a
JD
107
108 rm -rf ${TRACE_PATH}
109 rm $tmp_xml_output
110 rm -rf $tmp_save_output
111}
112
113plan_tests $NUM_TESTS
114
115print_test_banner "$TEST_DESC"
116
117start_lttng_sessiond
118
308a8946 119tests=( test_save_load_mi )
e7716c6a
JD
120
121for fct_test in ${tests[@]};
122do
123 SESSION_NAME=$(randstring 16 0)
124 ${fct_test}
125done
126
127stop_lttng_sessiond
This page took 0.027916 seconds and 4 git commands to generate.