From c125de8f5c0dc9ba3ada63e9317e468ffb9e335a Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 8 Oct 2021 09:41:04 -0400 Subject: [PATCH] Tests: use babeltrace2 for all tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Change value of `BABELTRACE_BIN` to `babeltrace2`, - Replace all direct calls to babeltrace with calls to `BABELTRACE_BIN` variable, - Add `bail_out_if_no_babeltrace` bash function to fail the test if Babeltrace 2 is needed but not found. Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: Ieeffe4977660f47561732223e94a1b8f5a00ef0e --- README.adoc | 3 +- tests/destructive/metadata-regeneration | 8 ++- tests/regression/kernel/test_callstack | 19 +++---- tests/regression/kernel/test_clock_override | 2 + tests/regression/tools/base-path/test_ust | 1 + tests/regression/tools/channel/test_channel | 2 + tests/regression/tools/clear/test_kernel | 2 + tests/regression/tools/clear/test_ust | 2 + tests/regression/tools/crash/test_crash | 2 + .../regression/tools/exclusion/test_exclusion | 8 +-- .../tools/filtering/test_invalid_filter | 2 + .../tools/filtering/test_valid_filter | 4 +- tests/regression/tools/live/test_lttng_ust | 2 + tests/regression/tools/metadata/test_kernel | 1 + tests/regression/tools/metadata/test_ust | 2 + .../regression/tools/regen-metadata/test_ust | 1 + .../regression/tools/regen-statedump/test_ust | 1 + .../regression/tools/relayd-grouping/test_ust | 1 + tests/regression/tools/rotation/test_kernel | 1 + tests/regression/tools/rotation/test_ust | 1 + tests/regression/tools/snapshots/test_kernel | 3 ++ .../tools/snapshots/test_ust_streaming | 2 + tests/regression/tools/snapshots/ust_test | 2 + .../streaming/test_high_throughput_limits | 6 ++- tests/regression/tools/streaming/test_ust | 1 + .../tracefile-limits/test_tracefile_count | 4 +- .../tracefile-limits/test_tracefile_size | 2 + .../tools/tracker/test_event_tracker | 2 + .../tools/trigger/start-stop/test_start_stop | 1 + .../tools/wildcard/test_event_wildcard | 2 + .../baddr-statedump/test_baddr-statedump.py | 4 +- .../ust/before-after/test_before_after | 1 + tests/regression/ust/blocking/test_blocking | 4 +- .../ust/buffers-pid/test_buffers_pid | 6 ++- tests/regression/ust/daemon/test_daemon.py | 4 +- .../ust/exit-fast/test_exit-fast.py | 4 +- tests/regression/ust/fork/test_fork.py | 4 +- .../ust/getcpu-override/test_getcpu_override | 2 + .../ust/high-throughput/test_high_throughput | 6 ++- tests/regression/ust/java-jul/test_java_jul | 2 + .../regression/ust/java-log4j/test_java_log4j | 2 + .../ust/libc-wrapper/test_libc-wrapper.py | 4 +- tests/regression/ust/linking/test_linking.py | 4 +- .../ust/low-throughput/test_low_throughput | 4 +- tests/regression/ust/multi-lib/test_multi_lib | 2 + .../ust/namespaces/test_ns_contexts | 2 + .../ust/namespaces/test_ns_contexts_change | 2 + tests/regression/ust/overlap/test_overlap | 2 + .../test_periodical_metadata_flush | 3 +- tests/regression/ust/test_event_perf | 2 + tests/regression/ust/test_event_tracef | 2 + .../test_type_declarations.py | 4 +- tests/regression/ust/ust-dl/test_ust-dl.py | 4 +- tests/utils/test_utils.py | 1 + tests/utils/utils.sh | 52 +++++++------------ 55 files changed, 138 insertions(+), 79 deletions(-) diff --git a/README.adoc b/README.adoc index e9ff9a812..b9669d941 100644 --- a/README.adoc +++ b/README.adoc @@ -73,7 +73,8 @@ Debian/Ubuntu package: `libxml2{nbh}dev` The following dependencies are optional: * **https://babeltrace.org/[Babeltrace{nbsp}2]**: default viewer - of the https://lttng.org/man/1/lttng-view/[`lttng view`] command. + of the https://lttng.org/man/1/lttng-view/[`lttng view`] command, + `make{nbsp}check` and tests. + Debian/Ubuntu package: `babeltrace2` diff --git a/tests/destructive/metadata-regeneration b/tests/destructive/metadata-regeneration index b81e7af32..449dc05be 100755 --- a/tests/destructive/metadata-regeneration +++ b/tests/destructive/metadata-regeneration @@ -38,16 +38,14 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + + function validate_trace_date { local test_date=$1 local trace_path=$2 - which $BABELTRACE_BIN >/dev/null - if [ $? -ne 0 ]; then - skip 0 "Babeltrace binary not found. Skipping trace validation" - fi - res=$($BABELTRACE_BIN --clock-date $trace_path 2>/dev/null | head -1 | grep $test_date) if [ $? -eq 0 ]; then pass "Validate trace at date $test_date" diff --git a/tests/regression/kernel/test_callstack b/tests/regression/kernel/test_callstack index b5759d442..ad506b553 100755 --- a/tests/regression/kernel/test_callstack +++ b/tests/regression/kernel/test_callstack @@ -134,6 +134,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ "$(id -u)" == "0" ]; then isroot=1 else @@ -142,18 +144,13 @@ fi skip $isroot "Root access is needed. Skipping all tests." "$NUM_TESTS" || { - which "$BABELTRACE_BIN" > /dev/null - test $? -ne 0 - skip $? "Babeltrace binary not found. Skipping callstack tests" "$NUM_TESTS" || - { - start_lttng_sessiond + start_lttng_sessiond - if test $RUN_USERSPACE_TEST == 1; then - test_user_callstack - fi + if test $RUN_USERSPACE_TEST == 1; then + test_user_callstack + fi - test_kernel_callstack + test_kernel_callstack - stop_lttng_sessiond - } + stop_lttng_sessiond } diff --git a/tests/regression/kernel/test_clock_override b/tests/regression/kernel/test_clock_override index cef30dc30..9dcde73d8 100755 --- a/tests/regression/kernel/test_clock_override +++ b/tests/regression/kernel/test_clock_override @@ -164,6 +164,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + TESTS=( "test_clock_override_metadata" "test_clock_override_timestamp" diff --git a/tests/regression/tools/base-path/test_ust b/tests/regression/tools/base-path/test_ust index fd1a67af8..38a087753 100755 --- a/tests/regression/tools/base-path/test_ust +++ b/tests/regression/tools/base-path/test_ust @@ -155,6 +155,7 @@ function ust_app_stream_base_path_via_load () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/tools/channel/test_channel b/tests/regression/tools/channel/test_channel index eaae3d9c1..7244ac3c7 100755 --- a/tests/regression/tools/channel/test_channel +++ b/tests/regression/tools/channel/test_channel @@ -64,6 +64,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond if [ ! -x "$TESTAPP_BIN" ]; then diff --git a/tests/regression/tools/clear/test_kernel b/tests/regression/tools/clear/test_kernel index c12a153c5..0229f5f92 100755 --- a/tests/regression/tools/clear/test_kernel +++ b/tests/regression/tools/clear/test_kernel @@ -535,6 +535,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/clear/test_ust b/tests/regression/tools/clear/test_ust index 8edc72292..27cd71fe9 100755 --- a/tests/regression/tools/clear/test_ust +++ b/tests/regression/tools/clear/test_ust @@ -803,6 +803,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + streaming_tests=(test_ust_streaming test_ust_streaming_rotate_clear test_ust_streaming_clear_rotate diff --git a/tests/regression/tools/crash/test_crash b/tests/regression/tools/crash/test_crash index 8201c56bc..7570ba9b9 100755 --- a/tests/regression/tools/crash/test_crash +++ b/tests/regression/tools/crash/test_crash @@ -35,6 +35,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + function start_test_app() { local tmp_file=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}.XXXXXX") diff --git a/tests/regression/tools/exclusion/test_exclusion b/tests/regression/tools/exclusion/test_exclusion index 00e364025..0c9bdc829 100755 --- a/tests/regression/tools/exclusion/test_exclusion +++ b/tests/regression/tools/exclusion/test_exclusion @@ -53,7 +53,7 @@ function dry_run run_apps stop_lttng_tracing_ok $SESSION_NAME - nb_events=$(babeltrace $trace_path | wc -l) + nb_events=$("$BABELTRACE_BIN" $trace_path | wc -l) if [ "$nb_events" -ne "0" ]; then ok 0 "Events were found during the dry run without exclusion" else @@ -86,7 +86,7 @@ function test_exclusion # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=`babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index 2> /dev/null` + stats=`"$BABELTRACE_BIN" $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index 2> /dev/null` if [ ! -z "$stats" ]; then fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" else @@ -139,7 +139,7 @@ function test_exclusion_tracing_started # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=$(babeltrace $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index 2> /dev/null) + stats=$("$BABELTRACE_BIN" $trace_path | $STATS_BIN --tracepoint "$event_name_expected_to_be_missing" | grep -v index 2> /dev/null) if [ ! -z "$stats" ]; then fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" else @@ -174,6 +174,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond diag "Enable event without exclusion" diff --git a/tests/regression/tools/filtering/test_invalid_filter b/tests/regression/tools/filtering/test_invalid_filter index 7d9e524d9..013061239 100755 --- a/tests/regression/tools/filtering/test_invalid_filter +++ b/tests/regression/tools/filtering/test_invalid_filter @@ -94,6 +94,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + OLDIFS="$IFS" IFS=$'\n' INVALID_FILTERS=( diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter index e76ffa25f..7e764ca5d 100755 --- a/tests/regression/tools/filtering/test_valid_filter +++ b/tests/regression/tools/filtering/test_valid_filter @@ -112,7 +112,7 @@ function test_valid_filter # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name` + stats=`"$BABELTRACE_BIN" $trace_path | $STATS_BIN --tracepoint $event_name` rm -rf $trace_path @@ -401,6 +401,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + issue_356_filter="intfield > 0 && intfield > 1 && " issue_356_filter+="intfield > 2 && intfield > 3 && " issue_356_filter+="intfield > 4 && intfield > 5 && " diff --git a/tests/regression/tools/live/test_lttng_ust b/tests/regression/tools/live/test_lttng_ust index aceb08e41..3aa1083b0 100755 --- a/tests/regression/tools/live/test_lttng_ust +++ b/tests/regression/tools/live/test_lttng_ust @@ -32,6 +32,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + function test_custom_url() { # Create session with custom URL diff --git a/tests/regression/tools/metadata/test_kernel b/tests/regression/tools/metadata/test_kernel index 57cace6ea..08743008b 100755 --- a/tests/regression/tools/metadata/test_kernel +++ b/tests/regression/tools/metadata/test_kernel @@ -90,6 +90,7 @@ function test_kernel () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace if [ "$(id -u)" == "0" ]; then isroot=1 diff --git a/tests/regression/tools/metadata/test_ust b/tests/regression/tools/metadata/test_ust index 810a226cf..6b17b02cf 100755 --- a/tests/regression/tools/metadata/test_ust +++ b/tests/regression/tools/metadata/test_ust @@ -222,6 +222,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + # Use LTTNG_HOME since we want the complete "default" lttng directory hierarchy # with "-/...". LTTNG_HOME="$TRACE_PATH" diff --git a/tests/regression/tools/regen-metadata/test_ust b/tests/regression/tools/regen-metadata/test_ust index cc3aed9cf..60735c364 100755 --- a/tests/regression/tools/regen-metadata/test_ust +++ b/tests/regression/tools/regen-metadata/test_ust @@ -195,6 +195,7 @@ function test_ust_live () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/tools/regen-statedump/test_ust b/tests/regression/tools/regen-statedump/test_ust index 8572e2545..29e1d1b9d 100755 --- a/tests/regression/tools/regen-statedump/test_ust +++ b/tests/regression/tools/regen-statedump/test_ust @@ -64,6 +64,7 @@ function test_ust_local () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_sessiond diff --git a/tests/regression/tools/relayd-grouping/test_ust b/tests/regression/tools/relayd-grouping/test_ust index 579881492..eecf95207 100755 --- a/tests/regression/tools/relayd-grouping/test_ust +++ b/tests/regression/tools/relayd-grouping/test_ust @@ -642,6 +642,7 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace tests=( test_ust_uid_live diff --git a/tests/regression/tools/rotation/test_kernel b/tests/regression/tools/rotation/test_kernel index f5f1f5553..d4a66c508 100755 --- a/tests/regression/tools/rotation/test_kernel +++ b/tests/regression/tools/rotation/test_kernel @@ -81,6 +81,7 @@ function test_kernel_streaming_timer () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace if [ "$(id -u)" == "0" ]; then isroot=1 diff --git a/tests/regression/tools/rotation/test_ust b/tests/regression/tools/rotation/test_ust index 4d295d6e9..278684d67 100755 --- a/tests/regression/tools/rotation/test_ust +++ b/tests/regression/tools/rotation/test_ust @@ -187,6 +187,7 @@ function test_incompatible_sessions () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/tools/snapshots/test_kernel b/tests/regression/tools/snapshots/test_kernel index 8cac901e7..c99802d54 100755 --- a/tests/regression/tools/snapshots/test_kernel +++ b/tests/regression/tools/snapshots/test_kernel @@ -215,6 +215,9 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/snapshots/test_ust_streaming b/tests/regression/tools/snapshots/test_ust_streaming index ed109abd4..24e52c416 100755 --- a/tests/regression/tools/snapshots/test_ust_streaming +++ b/tests/regression/tools/snapshots/test_ust_streaming @@ -232,6 +232,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/snapshots/ust_test b/tests/regression/tools/snapshots/ust_test index 54365c3ea..e2e84b5c3 100755 --- a/tests/regression/tools/snapshots/ust_test +++ b/tests/regression/tools/snapshots/ust_test @@ -479,6 +479,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond tests=( test_ust_list_output test_ust_local_snapshot diff --git a/tests/regression/tools/streaming/test_high_throughput_limits b/tests/regression/tools/streaming/test_high_throughput_limits index 2b9e3ad39..cd97dc776 100755 --- a/tests/regression/tools/streaming/test_high_throughput_limits +++ b/tests/regression/tools/streaming/test_high_throughput_limits @@ -129,8 +129,8 @@ function validate_event_count TEMP_FILE=$(mktemp --tmpdir tmp.streaming_high_throughput_limit_file1.XXXXXX) TEMP_FILE_2=$(mktemp --tmpdir tmp.streaming_high_throughput_limit_file2.XXXXXX) - traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) - babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 + traced=$("$BABELTRACE_BIN" $TRACE_PATH 2>/dev/null | wc -l) + "$BABELTRACE_BIN" $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE @@ -170,6 +170,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/streaming/test_ust b/tests/regression/tools/streaming/test_ust index 2e15bd4c6..b88e945f8 100755 --- a/tests/regression/tools/streaming/test_ust +++ b/tests/regression/tools/streaming/test_ust @@ -79,6 +79,7 @@ function test_ust_after_start () plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/tools/tracefile-limits/test_tracefile_count b/tests/regression/tools/tracefile-limits/test_tracefile_count index 244910dd6..5ca10ac23 100755 --- a/tests/regression/tools/tracefile-limits/test_tracefile_count +++ b/tests/regression/tools/tracefile-limits/test_tracefile_count @@ -134,7 +134,7 @@ function test_tracefile_count_limit () [ "$(get_stream_file_count "$trace_path" "$stream_pattern")" -eq "$count_limit" ] ok $? "Stream meets the trace file limit of $count_limit" - stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name` + stats=`"$BABELTRACE_BIN" $trace_path | $STATS_BIN --tracepoint $event_name` validate_min_max "$stats" "intfield" "[0-9]+" "$expected_max" ok $? "Trace validation - intfield" @@ -154,6 +154,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond for limit in "${LIMITS[@]}"; diff --git a/tests/regression/tools/tracefile-limits/test_tracefile_size b/tests/regression/tools/tracefile-limits/test_tracefile_size index bbfc27c9e..5d9f21b60 100755 --- a/tests/regression/tools/tracefile-limits/test_tracefile_size +++ b/tests/regression/tools/tracefile-limits/test_tracefile_size @@ -164,6 +164,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond # Test with multiples of PAGE_SIZE diff --git a/tests/regression/tools/tracker/test_event_tracker b/tests/regression/tools/tracker/test_event_tracker index cc0f698d2..deecb8f80 100755 --- a/tests/regression/tools/tracker/test_event_tracker +++ b/tests/regression/tools/tracker/test_event_tracker @@ -395,6 +395,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond diag "Test UST tracker" diff --git a/tests/regression/tools/trigger/start-stop/test_start_stop b/tests/regression/tools/trigger/start-stop/test_start_stop index c3a4e7fbd..823fb27a8 100755 --- a/tests/regression/tools/trigger/start-stop/test_start_stop +++ b/tests/regression/tools/trigger/start-stop/test_start_stop @@ -148,6 +148,7 @@ function test_stop_session_action() plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_sessiond_notap diff --git a/tests/regression/tools/wildcard/test_event_wildcard b/tests/regression/tools/wildcard/test_event_wildcard index f69baffc4..c22646175 100755 --- a/tests/regression/tools/wildcard/test_event_wildcard +++ b/tests/regression/tools/wildcard/test_event_wildcard @@ -85,6 +85,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond diag "Test UST wildcard" diff --git a/tests/regression/ust/baddr-statedump/test_baddr-statedump.py b/tests/regression/ust/baddr-statedump/test_baddr-statedump.py index 026f08444..c145972bb 100644 --- a/tests/regression/ust/baddr-statedump/test_baddr-statedump.py +++ b/tests/regression/ust/baddr-statedump/test_baddr-statedump.py @@ -44,9 +44,9 @@ stop_session(session_info) # Check for statedump events in the resulting trace try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.", session_info) + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN), session_info) start_event_found = False bin_info_event_found = False diff --git a/tests/regression/ust/before-after/test_before_after b/tests/regression/ust/before-after/test_before_after index de07d31a4..0c3ebec54 100755 --- a/tests/regression/ust/before-after/test_before_after +++ b/tests/regression/ust/before-after/test_before_after @@ -80,6 +80,7 @@ function test_after_apps() plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace start_lttng_sessiond diff --git a/tests/regression/ust/blocking/test_blocking b/tests/regression/ust/blocking/test_blocking index 617d9a278..ca8643532 100755 --- a/tests/regression/ust/blocking/test_blocking +++ b/tests/regression/ust/blocking/test_blocking @@ -123,7 +123,7 @@ function test_ust_blocking_no_discard() destroy_lttng_session_ok $SESSION_NAME stop_lttng_sessiond - nr_events=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) + nr_events=$("$BABELTRACE_BIN" $TRACE_PATH 2>/dev/null | wc -l) test $nr_events -eq $NUM_EVENT ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT" @@ -133,6 +133,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + TESTS=( "test_ust_implicit_no_blocking" "test_ust_implicit_no_blocking_with_channel_blocking" diff --git a/tests/regression/ust/buffers-pid/test_buffers_pid b/tests/regression/ust/buffers-pid/test_buffers_pid index 48c09538e..982ee2d58 100755 --- a/tests/regression/ust/buffers-pid/test_buffers_pid +++ b/tests/regression/ust/buffers-pid/test_buffers_pid @@ -98,7 +98,7 @@ test_before_multiple_apps() { rm -f ${file_sync_before_last}_${i} done - out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + out=$("$BABELTRACE_BIN" $TRACE_PATH | grep $EVENT_NAME | wc -l) if [ $out -eq 0 ]; then fail "Trace validation" diag "No event(s) found. We are supposed to have at least one." @@ -165,7 +165,7 @@ test_before_app() { rm -f ${file_sync_after_first} rm -f ${file_sync_before_last} - out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + out=$("$BABELTRACE_BIN" $TRACE_PATH | grep $EVENT_NAME | wc -l) if [ $out -eq 0 ]; then fail "Trace validation" diag "No event(s) found. We are supposed to have at least one." @@ -222,6 +222,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + TESTS=( "test_before_app" "test_after_app" diff --git a/tests/regression/ust/daemon/test_daemon.py b/tests/regression/ust/daemon/test_daemon.py index 0351f1d21..46df102b9 100644 --- a/tests/regression/ust/daemon/test_daemon.py +++ b/tests/regression/ust/daemon/test_daemon.py @@ -57,9 +57,9 @@ if daemon_process_return_code != 0: stop_session(session_info) try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.") + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN)) before_daemon_event_found = False before_daemon_event_pid = -1 diff --git a/tests/regression/ust/exit-fast/test_exit-fast.py b/tests/regression/ust/exit-fast/test_exit-fast.py index f61d540b3..aaacd4529 100644 --- a/tests/regression/ust/exit-fast/test_exit-fast.py +++ b/tests/regression/ust/exit-fast/test_exit-fast.py @@ -49,9 +49,9 @@ stop_session(session_info) # Check both events (normal exit and suicide messages) are present in the resulting trace try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.") + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN)) event_lines = [] for event_line in babeltrace_process.stdout: diff --git a/tests/regression/ust/fork/test_fork.py b/tests/regression/ust/fork/test_fork.py index 4cb721f38..3c9a2ea91 100644 --- a/tests/regression/ust/fork/test_fork.py +++ b/tests/regression/ust/fork/test_fork.py @@ -52,9 +52,9 @@ stop_session(session_info) # Check both events (normal exit and suicide messages) are present in the resulting trace try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.", session_info) + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN)) event_lines = [] for event_line in babeltrace_process.stdout: diff --git a/tests/regression/ust/getcpu-override/test_getcpu_override b/tests/regression/ust/getcpu-override/test_getcpu_override index 7553b685b..124219a36 100755 --- a/tests/regression/ust/getcpu-override/test_getcpu_override +++ b/tests/regression/ust/getcpu-override/test_getcpu_override @@ -147,6 +147,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ ! -x "$CURDIR/.libs/lttng-ust-getcpu-override-test.so" ]; then skip 0 "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0 fi diff --git a/tests/regression/ust/high-throughput/test_high_throughput b/tests/regression/ust/high-throughput/test_high_throughput index 1640e3994..873646fa9 100755 --- a/tests/regression/ust/high-throughput/test_high_throughput +++ b/tests/regression/ust/high-throughput/test_high_throughput @@ -28,6 +28,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond create_lttng_session_ok $SESSION_NAME $TRACE_PATH @@ -53,8 +55,8 @@ stop_lttng_sessiond TEMP_FILE=$(mktemp --tmpdir tmp.test_high_throughput_tmp_file1.XXXXXX) TEMP_FILE_2=$(mktemp --tmpdir tmp.test_high_throughput_tmp_file2.XXXXXX) -traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) -babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 +traced=$("$BABELTRACE_BIN" $TRACE_PATH 2>/dev/null | wc -l) +"$BABELTRACE_BIN" $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE diff --git a/tests/regression/ust/java-jul/test_java_jul b/tests/regression/ust/java-jul/test_java_jul index f2244cb72..90c1758e1 100755 --- a/tests/regression/ust/java-jul/test_java_jul +++ b/tests/regression/ust/java-jul/test_java_jul @@ -662,6 +662,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ ! -f "$TESTAPP_PATH.class" ]; then withapp=0 else diff --git a/tests/regression/ust/java-log4j/test_java_log4j b/tests/regression/ust/java-log4j/test_java_log4j index fc16e02d0..ed4302879 100755 --- a/tests/regression/ust/java-log4j/test_java_log4j +++ b/tests/regression/ust/java-log4j/test_java_log4j @@ -661,6 +661,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ ! -f "$TESTAPP_PATH.class" ]; then withapp=0 else diff --git a/tests/regression/ust/libc-wrapper/test_libc-wrapper.py b/tests/regression/ust/libc-wrapper/test_libc-wrapper.py index f56fa50de..f07152a28 100644 --- a/tests/regression/ust/libc-wrapper/test_libc-wrapper.py +++ b/tests/regression/ust/libc-wrapper/test_libc-wrapper.py @@ -41,9 +41,9 @@ stop_session(session_info) # Check for malloc events in the resulting trace try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.", session_info) + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN), session_info) malloc_event_found = False free_event_found = False diff --git a/tests/regression/ust/linking/test_linking.py b/tests/regression/ust/linking/test_linking.py index 21941f0d2..264747ea6 100644 --- a/tests/regression/ust/linking/test_linking.py +++ b/tests/regression/ust/linking/test_linking.py @@ -133,9 +133,9 @@ for executable in test_executables: continue try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.") + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN)) # We should find 8 events in the resulting trace event_entries = [] diff --git a/tests/regression/ust/low-throughput/test_low_throughput b/tests/regression/ust/low-throughput/test_low_throughput index 66ed8950f..e03d9f01e 100755 --- a/tests/regression/ust/low-throughput/test_low_throughput +++ b/tests/regression/ust/low-throughput/test_low_throughput @@ -27,6 +27,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond create_lttng_session_ok $SESSION_NAME $TRACE_PATH @@ -47,7 +49,7 @@ stop_lttng_sessiond last_val=0 out=0 -babeltrace $TRACE_PATH | while read event; +"$BABELTRACE_BIN" $TRACE_PATH | while read event; do val=$(echo $event | cut -f10 -d" ") val=${val%?} diff --git a/tests/regression/ust/multi-lib/test_multi_lib b/tests/regression/ust/multi-lib/test_multi_lib index 23821ed0f..94caee5db 100755 --- a/tests/regression/ust/multi-lib/test_multi_lib +++ b/tests/regression/ust/multi-lib/test_multi_lib @@ -217,6 +217,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + TESTS=( "test_dlopen_same_provider_name_same_event" "test_dlopen_same_provider_name_different_event" diff --git a/tests/regression/ust/namespaces/test_ns_contexts b/tests/regression/ust/namespaces/test_ns_contexts index be038eb28..e65cc2475 100755 --- a/tests/regression/ust/namespaces/test_ns_contexts +++ b/tests/regression/ust/namespaces/test_ns_contexts @@ -76,6 +76,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + system_has_ns=0 if [ -d "/proc/$$/ns" ]; then system_has_ns=1 diff --git a/tests/regression/ust/namespaces/test_ns_contexts_change b/tests/regression/ust/namespaces/test_ns_contexts_change index 8a4b62ce3..78fc37b5d 100755 --- a/tests/regression/ust/namespaces/test_ns_contexts_change +++ b/tests/regression/ust/namespaces/test_ns_contexts_change @@ -101,6 +101,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + isroot=0 if [ "$(id -u)" == "0" ]; then isroot=1 diff --git a/tests/regression/ust/overlap/test_overlap b/tests/regression/ust/overlap/test_overlap index d10284e06..a942d066a 100755 --- a/tests/regression/ust/overlap/test_overlap +++ b/tests/regression/ust/overlap/test_overlap @@ -602,6 +602,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ -x "$CURDIR/demo/demo" ]; then foundbin=1 else diff --git a/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush b/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush index f9f4f1c95..d81d475d4 100755 --- a/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush +++ b/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush @@ -68,7 +68,7 @@ function validate_trace() { local out - out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + out=$("$BABELTRACE_BIN" $TRACE_PATH | grep $EVENT_NAME | wc -l) if [ $out -eq 0 ]; then fail "Trace validation" diag "No event(s) found. We are supposed to have at least one." @@ -298,6 +298,7 @@ test_before_app_uid() { plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace TESTS=( "test_before_app_uid" diff --git a/tests/regression/ust/test_event_perf b/tests/regression/ust/test_event_perf index 33aab2981..01c137a19 100755 --- a/tests/regression/ust/test_event_perf +++ b/tests/regression/ust/test_event_perf @@ -119,6 +119,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/ust/test_event_tracef b/tests/regression/ust/test_event_tracef index ca14c73f5..2d7a64154 100755 --- a/tests/regression/ust/test_event_tracef +++ b/tests/regression/ust/test_event_tracef @@ -45,6 +45,8 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" +bail_out_if_no_babeltrace + start_lttng_sessiond TRACE_PATH=$(mktemp --tmpdir -d tmp.test_event_tracef_trace_path.XXXXXX) diff --git a/tests/regression/ust/type-declarations/test_type_declarations.py b/tests/regression/ust/type-declarations/test_type_declarations.py index 62eda73a3..bdb649b9a 100644 --- a/tests/regression/ust/type-declarations/test_type_declarations.py +++ b/tests/regression/ust/type-declarations/test_type_declarations.py @@ -43,9 +43,9 @@ stop_session(session_info) # Check event fields using type declarations are present try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.") + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN)) event_lines = [] for event_line in babeltrace_process.stdout: diff --git a/tests/regression/ust/ust-dl/test_ust-dl.py b/tests/regression/ust/ust-dl/test_ust-dl.py index 96509c7cf..04903af26 100644 --- a/tests/regression/ust/ust-dl/test_ust-dl.py +++ b/tests/regression/ust/ust-dl/test_ust-dl.py @@ -52,9 +52,9 @@ stop_session(session_info) # Check for dl events in the resulting trace try: - babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + babeltrace_process = subprocess.Popen([BABELTRACE_BIN, session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except FileNotFoundError: - bail("Could not open babeltrace. Please make sure it is installed.", session_info) + bail("Could not open {}. Please make sure it is installed.".format(BABELTRACE_BIN), session_info) dlopen_event_found = 0 dlmopen_event_found = 0 diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index afe066d76..ba9c2946e 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -22,6 +22,7 @@ sys.path.append(lttng_bindings_path) sys.path.append(lttng_bindings_libs_path) from lttng import * +BABELTRACE_BIN="babeltrace2" class SessionInfo: def __init__(self, handle, session_name, tmp_directory, channel_name): diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 42d99444f..c6d627cef 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -12,7 +12,7 @@ CONSUMERD_MATCH=".*lttng-consumerd.*" RELAYD_BIN="lttng-relayd" RELAYD_MATCH=".*lttng-relayd.*" LTTNG_BIN="lttng" -BABELTRACE_BIN="babeltrace" +BABELTRACE_BIN="babeltrace2" OUTPUT_DEST=/dev/null ERROR_OUTPUT_DEST=/dev/null MI_XSD_MAJOR_VERSION=4 @@ -1841,6 +1841,14 @@ function wait_live_viewer_connect () pass "Waiting for live viewers on url: $url" } +function bail_out_if_no_babeltrace() +{ + which "$BABELTRACE_BIN" >/dev/null + if [ $? -ne 0 ]; then + LTTNG_BAIL_OUT "\"$BABELTRACE_BIN\" binary not found. Skipping tests" + fi +} + function validate_metadata_event () { local event_name=$1 @@ -1850,8 +1858,7 @@ function validate_metadata_event () local metadata_file=$(find $trace_path -name "metadata") local metadata_path=$(dirname $metadata_file) - which $BABELTRACE_BIN >/dev/null - skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" + bail_out_if_no_babeltrace local count=$($BABELTRACE_BIN --output-format=ctf-metadata $metadata_path | grep $event_name | wc -l) @@ -1870,8 +1877,7 @@ function trace_matches () local nr_iter=$2 local trace_path=$3 - which $BABELTRACE_BIN >/dev/null - skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" + bail_out_if_no_babeltrace local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) @@ -1889,8 +1895,9 @@ function trace_match_only() local nr_iter=$2 local trace_path=$3 - which $BABELTRACE_BIN >/dev/null - skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" + bail_out_if_no_babeltrace + #which "$BABELTRACE_BIN" >/dev/null + #skip $? -ne 0 "\"$BABELTRACE_BIN\" binary not found. Skipping trace comparison" local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l) local total=$($BABELTRACE_BIN $trace_path | wc -l) @@ -1908,10 +1915,7 @@ function validate_trace local event_name=$1 local trace_path=$2 - which $BABELTRACE_BIN >/dev/null - if [ $? -ne 0 ]; then - skip 0 "Babeltrace binary not found. Skipping trace validation" - fi + bail_out_if_no_babeltrace OLDIFS=$IFS IFS="," @@ -1935,10 +1939,7 @@ function validate_trace_count local trace_path=$2 local expected_count=$3 - which $BABELTRACE_BIN >/dev/null - if [ $? -ne 0 ]; then - skip 0 "Babeltrace binary not found. Skipping trace validation" - fi + bail_out_if_no_babeltrace cnt=0 OLDIFS=$IFS @@ -1965,10 +1966,7 @@ function validate_trace_count_range_incl_min_excl_max local expected_min=$3 local expected_max=$4 - which $BABELTRACE_BIN >/dev/null - if [ $? -ne 0 ]; then - skip 0 "Babeltrace binary not found. Skipping trace validation" - fi + bail_out_if_no_babeltrace cnt=0 OLDIFS=$IFS @@ -1992,11 +1990,6 @@ function trace_first_line { local trace_path=$1 - which $BABELTRACE_BIN >/dev/null - if [ $? -ne 0 ]; then - skip 0 "Babeltrace binary not found. Skipping trace validation" - fi - $BABELTRACE_BIN $trace_path 2>/dev/null | head -n 1 } @@ -2005,8 +1998,7 @@ function validate_trace_exp() local event_exp=$1 local trace_path=$2 - which $BABELTRACE_BIN >/dev/null - skip $? -ne 0 "Babeltrace binary not found. Skipping trace validation" + bail_out_if_no_babeltrace traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep --extended-regexp ${event_exp} | wc -l) if [ "$traced" -ne 0 ]; then @@ -2024,8 +2016,7 @@ function validate_trace_only_exp() local event_exp=$1 local trace_path=$2 - which $BABELTRACE_BIN >/dev/null - skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches" + bail_out_if_no_babeltrace local count=$($BABELTRACE_BIN $trace_path | grep --extended-regexp ${event_exp} | wc -l) local total=$($BABELTRACE_BIN $trace_path | wc -l) @@ -2044,10 +2035,7 @@ function validate_trace_empty() { local trace_path=$1 - which $BABELTRACE_BIN >/dev/null - if [ $? -ne 0 ]; then - skip 0 "Babeltrace binary not found. Skipping trace validation" - fi + bail_out_if_no_babeltrace events=$($BABELTRACE_BIN $trace_path 2>/dev/null) ret=$? -- 2.34.1