Tests: utils: regroup xml utils to utils.sh
[deliverable/lttng-tools.git] / tests / regression / tools / rotation / test_save_load_mi
CommitLineData
e7716c6a
JD
1#!/bin/bash
2#
9d16b343 3# Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
e7716c6a 4#
9d16b343 5# SPDX-License-Identifier: LGPL-2.1-only
e7716c6a
JD
6
7TEST_DESC="Rotation - Save/Load/List/MI"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
11SESSION_NAME="stream"
12
308a8946 13NUM_TESTS=22
e7716c6a
JD
14
15source $TESTDIR/utils/utils.sh
16source $CURDIR/rotate_utils.sh
17
2f686e35 18# Overwrite the lttng_bin to get mi output
e7716c6a
JD
19LTTNG_BIN="lttng --mi xml"
20
e7716c6a
JD
21XPATH_CMD_OUTPUT="//lttng:command/lttng:output"
22XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
66ea93b1
JG
23XPATH_ENABLE_ROTATE_TIMER="$XPATH_CMD_OUTPUT/lttng:rotation_schedule_results/lttng:rotation_schedule_result/lttng:rotation_schedule/lttng:periodic/lttng:time_us"
24XPATH_ENABLE_ROTATE_SIZE="$XPATH_CMD_OUTPUT/lttng:rotation_schedule_results/lttng:rotation_schedule_result/lttng:rotation_schedule/lttng:size_threshold/lttng:bytes"
25
26XPATH_LIST_ROTATE_TIMER="$XPATH_SESSION/lttng:rotation_schedules/lttng:periodic/lttng:time_us"
27XPATH_LIST_ROTATE_SIZE="$XPATH_SESSION/lttng:rotation_schedules/lttng:size_threshold/lttng:bytes"
e7716c6a 28
308a8946 29function test_save_load_mi ()
e7716c6a 30{
7539dcec
FD
31 local tmp_xml_output=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_xml_output.XXXXXX")
32 local tmp_save_output=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_save_output.XXXXXX")
33 local trace_path=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
e7716c6a
JD
34
35 diag "Test save/load/list/MI with rotation"
2f686e35 36 create_lttng_session_ok $SESSION_NAME $trace_path
e7716c6a
JD
37 enable_ust_lttng_event_ok $SESSION_NAME -a
38
39 # Enable a rotation timer and check the MI output of the command
308a8946
JR
40
41 OUTPUT_DEST=${tmp_xml_output}
42 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
045ce78b 43 $MI_VALIDATE ${tmp_xml_output}
e7716c6a 44 ok $? "Valid lttng enable-rotation timer XML"
308a8946 45
66ea93b1 46 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_ENABLE_ROTATE_TIMER})
e7716c6a
JD
47 test $value = 500000
48 ok $? "Found the right rotation timer value in XML"
49
50 # Enable a rotation size and check the MI output of the command
308a8946 51 lttng_enable_rotation_size_ok $SESSION_NAME 500k
045ce78b 52 $MI_VALIDATE ${tmp_xml_output}
e7716c6a 53 ok $? "Valid lttng enable-rotation size XML"
308a8946 54
66ea93b1 55 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_ENABLE_ROTATE_SIZE})
e7716c6a
JD
56 test $value = 512000
57 ok $? "Found the right rotation size value in XML"
58
59 # Check the output of lttng list with the 2 rotation parameters
308a8946 60 list_lttng_with_opts $SESSION_NAME
045ce78b 61 $MI_VALIDATE ${tmp_xml_output}
e7716c6a 62 ok $? "Valid lttng list XML"
308a8946 63
66ea93b1 64 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_TIMER})
e7716c6a
JD
65 test $value = 500000
66 ok $? "Found the right rotation timer value in list XML"
308a8946 67
66ea93b1 68 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_SIZE})
e7716c6a
JD
69 test $value = 512000
70 ok $? "Found the right rotation size value in list XML"
71
72 # save, destroy and reload the same session
308a8946 73 OUTPUT_DEST=/dev/null
c3527cb1 74 lttng_save $SESSION_NAME "-o $tmp_save_output/$SESSION_NAME"
308a8946 75 destroy_lttng_session_ok $SESSION_NAME
c3527cb1 76 lttng_load_ok "-i $tmp_save_output/$SESSION_NAME"
e7716c6a 77
308a8946 78 OUTPUT_DEST=${tmp_xml_output}
e7716c6a 79 # Check the output of lttng list with the 2 rotation parameters after the load
308a8946 80 list_lttng_with_opts $SESSION_NAME
045ce78b 81 $MI_VALIDATE ${tmp_xml_output}
e7716c6a 82 ok $? "Valid lttng list XML after load"
308a8946 83
66ea93b1 84 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_TIMER})
e7716c6a
JD
85 test $value = 500000
86 ok $? "Found the right rotation timer value in list XML after load"
308a8946 87
66ea93b1 88 value=$($XML_EXTRACT ${tmp_xml_output} ${XPATH_LIST_ROTATE_SIZE})
e7716c6a
JD
89 test $value = 512000
90 ok $? "Found the right rotation size value in list XML after load"
91
308a8946
JR
92 OUTPUT_DEST=/dev/null
93 destroy_lttng_session_ok $SESSION_NAME
e7716c6a 94
c3527cb1
FD
95 rm -rf "$trace_path"
96 rm "$tmp_xml_output"
97 rm -rf "$tmp_save_output"
e7716c6a
JD
98}
99
100plan_tests $NUM_TESTS
101
102print_test_banner "$TEST_DESC"
103
104start_lttng_sessiond
105
308a8946 106tests=( test_save_load_mi )
e7716c6a
JD
107
108for fct_test in ${tests[@]};
109do
110 SESSION_NAME=$(randstring 16 0)
111 ${fct_test}
112done
113
114stop_lttng_sessiond
This page took 0.048757 seconds and 5 git commands to generate.