3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@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
="Rotation - Save/Load/List/MI"
21 TESTDIR
=$CURDIR/..
/..
/..
26 source $TESTDIR/utils
/utils.sh
27 source $CURDIR/rotate_utils.sh
29 # Overwrite the lttng_bin to get mi output
30 LTTNG_BIN
="lttng --mi xml"
32 XSD_PATH
=$TESTDIR/..
/src
/common
/mi-lttng-3.0.xsd
34 XML_VALIDATE
="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH"
35 XML_EXTRACT
="$TESTDIR/regression/tools/mi/extract_xml"
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"
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"
45 function test_save_load_mi
()
47 tmp_xml_output
=$
(mktemp
-u)
48 tmp_save_output
=$
(mktemp
-d)
49 trace_path
=$
(mktemp
-d)
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
55 # Enable a rotation timer and check the MI output of the command
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"
62 value
=$
($XML_EXTRACT ${tmp_xml_output} ${XPATH_ENABLE_ROTATE_TIMER})
64 ok $?
"Found the right rotation timer value in XML"
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"
71 value
=$
($XML_EXTRACT ${tmp_xml_output} ${XPATH_ENABLE_ROTATE_SIZE})
73 ok $?
"Found the right rotation size value in XML"
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"
80 value
=$
($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_TIMER})
82 ok $?
"Found the right rotation timer value in list XML"
84 value
=$
($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_SIZE})
86 ok $?
"Found the right rotation size value in list XML"
88 # save, destroy and reload the same session
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"
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"
100 value
=$
($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_TIMER})
102 ok $?
"Found the right rotation timer value in list XML after load"
104 value
=$
($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_SIZE})
106 ok $?
"Found the right rotation size value in list XML after load"
108 OUTPUT_DEST
=/dev
/null
109 destroy_lttng_session_ok
$SESSION_NAME
113 rm -rf $tmp_save_output
116 plan_tests
$NUM_TESTS
118 print_test_banner
"$TEST_DESC"
122 tests
=( test_save_load_mi
)
124 for fct_test
in ${tests[@]};
126 SESSION_NAME
=$
(randstring
16 0)