From d11e3c3eeec8ba7db67f3b96c09fca4b7cabc9ad Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Wed, 26 May 2021 16:39:12 -0400 Subject: [PATCH] Move xml utils from mi subfolder to xml-utils folder MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I268dc544bf4f72f61a701ac3efd0b12488cc2f64 --- .gitignore | 4 +-- configure.ac | 1 + tests/regression/tools/mi/Makefile.am | 9 ----- tests/regression/tools/mi/test_mi | 7 ++-- tests/regression/tools/mi/validate_xml.h | 0 .../regression/tools/relayd-grouping/test_ust | 4 +-- .../tools/rotation/test_save_load_mi | 4 +-- tests/regression/tools/save-load/test_load | 33 ++++++++++--------- tests/utils/Makefile.am | 2 +- tests/utils/xml-utils/Makefile.am | 24 ++++++++++++++ .../mi => utils/xml-utils}/extract_xml.c | 0 .../mi => utils/xml-utils}/validate_xml.c | 0 12 files changed, 53 insertions(+), 35 deletions(-) delete mode 100644 tests/regression/tools/mi/validate_xml.h create mode 100644 tests/utils/xml-utils/Makefile.am rename tests/{regression/tools/mi => utils/xml-utils}/extract_xml.c (100%) rename tests/{regression/tools/mi => utils/xml-utils}/validate_xml.c (100%) diff --git a/.gitignore b/.gitignore index aebc12bf8..d9ecbd3d3 100644 --- a/.gitignore +++ b/.gitignore @@ -102,8 +102,6 @@ compile_commands.json /tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns /tests/regression/tools/health/health_check /tests/regression/kernel/select_poll_epoll -/tests/regression/tools/mi/extract_xml -/tests/regression/tools/mi/validate_xml /tests/regression/tools/notification/base_client /tests/regression/tools/notification/notification /tests/regression/tools/rotation/schedule_api @@ -141,6 +139,8 @@ compile_commands.json /tests/utils/testapp/gen-ust-tracef/gen-ust-tracef /tests/utils/testapp/gen-syscall-events/gen-syscall-events /tests/utils/testapp/gen-kernel-test-events/gen-kernel-test-events +/tests/utils/xml-utils/extract_xml +/tests/utils/xml-utils/validate_xml /tests/regression/tools/live/live_test /tests/unit/ini_config/ini_config /tests/perf/find_event diff --git a/configure.ac b/configure.ac index 36fd14b48..932615150 100644 --- a/configure.ac +++ b/configure.ac @@ -1197,6 +1197,7 @@ AC_CONFIG_FILES([ tests/utils/testapp/userspace-probe-elf-binary/Makefile tests/utils/testapp/userspace-probe-elf-cxx-binary/Makefile tests/utils/testapp/userspace-probe-sdt-binary/Makefile + tests/utils/xml-utils/Makefile ]) # Inject variable into python test script. diff --git a/tests/regression/tools/mi/Makefile.am b/tests/regression/tools/mi/Makefile.am index c5bd827b1..bfa42bfc3 100644 --- a/tests/regression/tools/mi/Makefile.am +++ b/tests/regression/tools/mi/Makefile.am @@ -1,14 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -noinst_PROGRAMS = validate_xml extract_xml -validate_xml_SOURCES = validate_xml.c -validate_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) -validate_xml_LDADD = $(libxml2_LIBS) - -extract_xml_SOURCES = extract_xml.c -extract_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) -extract_xml_LDADD = $(libxml2_LIBS) - noinst_SCRIPTS = test_mi EXTRA_DIST = test_mi diff --git a/tests/regression/tools/mi/test_mi b/tests/regression/tools/mi/test_mi index db5dec50e..b3b637865 100755 --- a/tests/regression/tools/mi/test_mi +++ b/tests/regression/tools/mi/test_mi @@ -23,9 +23,10 @@ SESSIOND_LOAD_DIR=$(mktemp --tmpdir -d tmp.test_mi_sessiond_load_dir.XXXXXX) OUTPUT_FILE="default.xml" #Path to custom xml utilities -XML_VALIDATE="$CURDIR/validate_xml $XSD_PATH" -XML_EXTRACT="$CURDIR/extract_xml" -XML_NODE_CHECK="$CURDIR/extract_xml -e" +XML_UTILS_PATH="$TESTDIR/utils/xml-utils" +XML_VALIDATE="$XML_UTILS_PATH/validate_xml $XSD_PATH" +XML_EXTRACT="$XML_UTILS_PATH/extract_xml" +XML_NODE_CHECK="$XML_UTILS_PATH/extract_xml -e" XPATH_CMD_OUTPUT="//lttng:command/lttng:output" XPATH_COMMAND_SUCCESS="/lttng:command/lttng:success/text()" diff --git a/tests/regression/tools/mi/validate_xml.h b/tests/regression/tools/mi/validate_xml.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/regression/tools/relayd-grouping/test_ust b/tests/regression/tools/relayd-grouping/test_ust index 615741364..64fb90e34 100755 --- a/tests/regression/tools/relayd-grouping/test_ust +++ b/tests/regression/tools/relayd-grouping/test_ust @@ -18,8 +18,8 @@ CHANNEL_NAME="my_channel" XSD_PATH=$TESTDIR/../src/common/mi-lttng-4.0.xsd -XML_VALIDATE="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH" -XML_EXTRACT="$TESTDIR/regression/tools/mi/extract_xml" +XML_VALIDATE="$TESTDIR/utils/xml-utils/validate_xml $XSD_PATH" +XML_EXTRACT="$TESTDIR/utils/xml-utils/extract_xml" XPATH_CMD_OUTPUT="//lttng:command/lttng:output" XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session" diff --git a/tests/regression/tools/rotation/test_save_load_mi b/tests/regression/tools/rotation/test_save_load_mi index fc3b24891..cb2050841 100755 --- a/tests/regression/tools/rotation/test_save_load_mi +++ b/tests/regression/tools/rotation/test_save_load_mi @@ -20,8 +20,8 @@ LTTNG_BIN="lttng --mi xml" XSD_PATH=$TESTDIR/../src/common/mi-lttng-4.0.xsd -XML_VALIDATE="$TESTDIR/regression/tools/mi/validate_xml $XSD_PATH" -XML_EXTRACT="$TESTDIR/regression/tools/mi/extract_xml" +XML_VALIDATE="$TESTDIR/utils/xml-utils/validate_xml $XSD_PATH" +XML_EXTRACT="$TESTDIR/utils/xml-utils/extract_xml" XPATH_CMD_OUTPUT="//lttng:command/lttng:output" XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session" diff --git a/tests/regression/tools/save-load/test_load b/tests/regression/tools/save-load/test_load index 3cf0cc501..15901f4f0 100755 --- a/tests/regression/tools/save-load/test_load +++ b/tests/regression/tools/save-load/test_load @@ -19,6 +19,7 @@ DIR=$(readlink -f $TESTDIR) NUM_TESTS=75 source $TESTDIR/utils/utils.sh +XML_EXTRACT="$TESTDIR/utils/xml-utils/extract_xml" # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS @@ -63,21 +64,21 @@ function test_complex_load() break; fi $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain[lttng:type='UST']/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain[lttng:type='UST']/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()") if [[ $mi_result = "false" ]]; then ok 0 "Disabled event is loaded in disabled state" else fail "Disabled event is loaded in disabled state" fi - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()") test $mi_result = "false" ok $? "Disabled event is loaded in disabled state" # Check that uevent_same_name_diff_llevel with log level 6 (TRACE_INFO) is enabled # This ensure that the state of events with similar name but not same # descriptor tuple (exclusion,filter,loglevel) is restored correctly. - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_same_name_diff_llevel' and lttng:loglevel='TRACE_INFO']/lttng:enabled/text()") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_same_name_diff_llevel' and lttng:loglevel='TRACE_INFO']/lttng:enabled/text()") test $mi_result = "true" ok $? "Enabled event with same name but different loglevel is in disabled state" @@ -132,21 +133,21 @@ function test_trackers() break; fi $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME-trackers" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vpid_process_attr_tracker/lttng:process_attr_values/lttng:vpid") + mi_result=$("$XML_EXTRACT" -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vpid_process_attr_tracker/lttng:process_attr_values/lttng:vpid") if [[ $mi_result = "true" ]]; then ok 0 "VPID target is present" else fail "VPID target missing" fi - mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vuid_process_attr_tracker/lttng:process_attr_values/lttng:vuid") + mi_result=$("$XML_EXTRACT" -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vuid_process_attr_tracker/lttng:process_attr_values/lttng:vuid") if [[ $mi_result = "true" ]]; then ok 0 "VUID target is present" else fail "VUID target missing" fi - mi_result=$($CURDIR/../mi/extract_xml -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vgid_process_attr_tracker/lttng:process_attr_values/lttng:vgid") + mi_result=$("$XML_EXTRACT" -e $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vgid_process_attr_tracker/lttng:process_attr_values/lttng:vgid") if [[ $mi_result = "true" ]]; then ok 0 "VGID target is present" else @@ -184,7 +185,7 @@ function test_override_url_normal() # Url of style file:// lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_url_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") test $mi_result = "${local_path_compare_value}" ok $? "Path url file:// override [{$mi_result}, ${local_path_compare_value}]" @@ -193,7 +194,7 @@ function test_override_url_normal() # Url of style / lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_path_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") test $mi_result = "${local_path_compare_value}" ok $? "Path url / override [{$mi_result}, ${local_path_compare_value}]" @@ -202,7 +203,7 @@ function test_override_url_normal() # Url of style net://ip:port:port lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${stream_url_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") test "$mi_result" = "${stream_url_compare}" ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]" @@ -234,7 +235,7 @@ function test_override_url_snapshot() # Url of style file:// lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url") test $mi_result = "${path_compare_value}" ok $? "Path url file:// override [{$mi_result}, ${path_compare_value}]" @@ -243,7 +244,7 @@ function test_override_url_snapshot() # Url of style / lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url") test $mi_result = "${path_compare_value}" ok $? "Path url / override [{$mi_result}, ${path_compare_value}]" @@ -252,12 +253,12 @@ function test_override_url_snapshot() # Url of style net://ip:port:port lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url") test "$mi_result" = "${stream_url_compare_ctrl}" ok $? "Path url ctrl net://host:port:port override [${mi_result}, ${stream_url_compare_ctrl}]" - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url") test "$mi_result" = "${stream_url_compare_data}" ok $? "Path url data net://host:port:port override [${mi_result}, ${stream_url_compare_data}]" @@ -300,7 +301,7 @@ function test_override_url_live() # Url of style net://ip:port:port lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}" $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$local_session_name" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") test "$mi_result" = "${stream_url_compare}" ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]" @@ -328,13 +329,13 @@ function test_override_session_name() fi ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${override_name}" > $mi_output_file - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name") test "${mi_result}" = "${override_name}" ok $? "Override name successful [${SESSION_NAME} to ${override_name}]" # Make sure that the name override did not change something else - mi_result=$($CURDIR/../mi/extract_xml $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") + mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path") test "${mi_result}" = "${output_path}" ok $? "Output path is not affected by name override" diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am index c74d10c06..1c7c95326 100644 --- a/tests/utils/Makefile.am +++ b/tests/utils/Makefile.am @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -SUBDIRS = . tap testapp +SUBDIRS = . tap testapp xml-utils EXTRA_DIST = utils.sh test_utils.py babelstats.pl warn_processes.sh \ parse-callstack.py diff --git a/tests/utils/xml-utils/Makefile.am b/tests/utils/xml-utils/Makefile.am new file mode 100644 index 000000000..9b00f7027 --- /dev/null +++ b/tests/utils/xml-utils/Makefile.am @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only + +noinst_PROGRAMS = validate_xml extract_xml +validate_xml_SOURCES = validate_xml.c +validate_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) +validate_xml_LDADD = $(libxml2_LIBS) + +extract_xml_SOURCES = extract_xml.c +extract_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) +extract_xml_LDADD = $(libxml2_LIBS) + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi diff --git a/tests/regression/tools/mi/extract_xml.c b/tests/utils/xml-utils/extract_xml.c similarity index 100% rename from tests/regression/tools/mi/extract_xml.c rename to tests/utils/xml-utils/extract_xml.c diff --git a/tests/regression/tools/mi/validate_xml.c b/tests/utils/xml-utils/validate_xml.c similarity index 100% rename from tests/regression/tools/mi/validate_xml.c rename to tests/utils/xml-utils/validate_xml.c -- 2.34.1