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