862634db5c4c3f215227b71379ab4f53a0eadf97
[lttng-tools.git] / tests / regression / tools / rotation / test_save_load_mi
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
18 TEST_DESC="Rotation - Save/Load/List/MI"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 SESSION_NAME="stream"
23
24 TRACE_PATH=$(mktemp -d)
25
26 NUM_TESTS=22
27
28 source $TESTDIR/utils/utils.sh
29 source $CURDIR/rotate_utils.sh
30
31 #Overwrite the lttng_bin to get mi output
32 LTTNG_BIN="lttng --mi xml"
33
34 XSD_PATH=$TESTDIR/../src/common/mi-lttng-3.0.xsd
35
36 XML_VALIDATE="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH"
37 XML_EXTRACT="$TESTDIR/regression/tools/mi/extract_xml"
38
39 XPATH_CMD_OUTPUT="//lttng:command/lttng:output"
40 XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
41 XPATH_ROTATE_SETUP="$XPATH_CMD_OUTPUT/lttng:rotation_schedule"
42
43 function test_save_load_mi ()
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
53
54 OUTPUT_DEST=${tmp_xml_output}
55 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
56 $XML_VALIDATE ${tmp_xml_output}
57 ok $? "Valid lttng enable-rotation timer XML"
58
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
64 lttng_enable_rotation_size_ok $SESSION_NAME 500k
65 $XML_VALIDATE ${tmp_xml_output}
66 ok $? "Valid lttng enable-rotation size XML"
67
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
73 list_lttng_with_opts $SESSION_NAME
74 $XML_VALIDATE ${tmp_xml_output}
75 ok $? "Valid lttng list XML"
76
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"
80
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
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"
90
91 OUTPUT_DEST=${tmp_xml_output}
92 # Check the output of lttng list with the 2 rotation parameters after the load
93 list_lttng_with_opts $SESSION_NAME
94 $XML_VALIDATE ${tmp_xml_output}
95 ok $? "Valid lttng list XML after load"
96
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"
100
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
105 OUTPUT_DEST=/dev/null
106 destroy_lttng_session_ok $SESSION_NAME
107
108 rm -rf ${TRACE_PATH}
109 rm $tmp_xml_output
110 rm -rf $tmp_save_output
111 }
112
113 plan_tests $NUM_TESTS
114
115 print_test_banner "$TEST_DESC"
116
117 start_lttng_sessiond
118
119 tests=( test_save_load_mi )
120
121 for fct_test in ${tests[@]};
122 do
123 SESSION_NAME=$(randstring 16 0)
124 ${fct_test}
125 done
126
127 stop_lttng_sessiond
This page took 0.045121 seconds and 3 git commands to generate.