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