From 7312af6f68ff342b661daa7b7f0f27c1b2b734df Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Wed, 31 Jul 2024 14:54:14 -0400 Subject: [PATCH] Tests: Use _run_babeltrace_cmd where possible MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I5b279201a1806e8975de39fa85e666da3d0c5204 Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- tests/destructive/metadata-regeneration | 2 +- tests/regression/kernel/test_callstack | 4 ++-- tests/regression/kernel/test_clock_override | 6 +++--- tests/regression/tools/clear/test_kernel | 4 ++-- tests/regression/tools/clear/test_ust | 12 +++--------- tests/regression/tools/exclusion/test_exclusion | 6 +++--- tests/regression/tools/metadata/test_kernel | 2 +- tests/regression/tools/metadata/test_ust | 4 ++-- .../tools/tracefile-limits/test_tracefile_count | 2 +- tests/regression/ust/buffers-pid/test_buffers_pid | 4 ++-- .../ust/clock-override/test_clock_override | 6 +++--- .../ust/getcpu-override/test_getcpu_override | 6 +++--- .../ust/low-throughput/test_low_throughput | 2 +- .../regression/ust/multi-session/test_multi_session | 2 +- .../test_periodical_metadata_flush | 2 +- 15 files changed, 29 insertions(+), 35 deletions(-) diff --git a/tests/destructive/metadata-regeneration b/tests/destructive/metadata-regeneration index dcae6bce0..5daa21b16 100755 --- a/tests/destructive/metadata-regeneration +++ b/tests/destructive/metadata-regeneration @@ -46,7 +46,7 @@ function validate_trace_date local test_date=$1 local trace_path=$2 - res=$($BABELTRACE_BIN --clock-date "$trace_path" 2>/dev/null | head -1 | grep $test_date) + res=$(_run_babeltrace_cmd --clock-date "$trace_path" | head -1 | grep $test_date) if [ $? -eq 0 ]; then pass "Validate trace at date $test_date" ret=0 diff --git a/tests/regression/kernel/test_callstack b/tests/regression/kernel/test_callstack index 960bb8a44..6131c251b 100755 --- a/tests/regression/kernel/test_callstack +++ b/tests/regression/kernel/test_callstack @@ -76,7 +76,7 @@ function test_user_callstack() destroy_lttng_session_ok "$SESSION_NAME" - "$BABELTRACE_BIN" "$TRACE_PATH" | grep $EVENT_NAME | ./"$PARSE_CALLSTACK" --user "$TEST_APP_USERSPACE" $USER_CS_EXPECTED + "_run_babeltrace_cmd" "$TRACE_PATH" | grep $EVENT_NAME | ./"$PARSE_CALLSTACK" --user "$TEST_APP_USERSPACE" $USER_CS_EXPECTED ok $? "Validate userspace callstack" rm -rf "$TRACE_PATH" @@ -114,7 +114,7 @@ function test_kernel_callstack() destroy_lttng_session_ok "$SESSION_NAME" - "$BABELTRACE_BIN" "$TRACE_PATH" | grep $EVENT_NAME | ./"$PARSE_CALLSTACK" --kernel $KERNEL_CS_EXPECTED + "_run_babeltrace_cmd" "$TRACE_PATH" | grep $EVENT_NAME | ./"$PARSE_CALLSTACK" --kernel $KERNEL_CS_EXPECTED ok $? "Validate kernel callstack" rm -rf "$TRACE_PATH" diff --git a/tests/regression/kernel/test_clock_override b/tests/regression/kernel/test_clock_override index c3688d359..f9ece05b8 100755 --- a/tests/regression/kernel/test_clock_override +++ b/tests/regression/kernel/test_clock_override @@ -87,7 +87,7 @@ function test_clock_override_metadata() local TRACE_METADATA_FILE_PATH="$(find "$TRACE_PATH" -name metadata -type f)" local TRACE_METADATA_DIR="$(dirname "$TRACE_METADATA_FILE_PATH")" - $BABELTRACE_BIN -o ctf-metadata -w $ctf_metadata_file $TRACE_METADATA_DIR + _run_babeltrace_cmd -o ctf-metadata -w $ctf_metadata_file $TRACE_METADATA_DIR ok $? "Metadata extraction from babeltrace" extract_clock_metadata $ctf_metadata_file $clock_metadata_file @@ -126,7 +126,7 @@ function test_clock_override_timestamp() # Use Babeltrace with "-n all" to give a comma separated list for # easy extraction of timestamps. - unique_timestamps_count=$($BABELTRACE_BIN -n all $TRACE_PATH | \ + unique_timestamps_count=$(_run_babeltrace_cmd -n all $TRACE_PATH | \ cut -d, -f1 | uniq | wc -l) test $unique_timestamps_count -gt 1 ok $? "Unique event timestamps without clock override: $unique_timestamps_count expect >1" @@ -153,7 +153,7 @@ function test_clock_override_timestamp() # Use Babeltrace with "-n all" to give a comma separated list for # easy extraction of timestamps. - unique_timestamps_count=$($BABELTRACE_BIN -n all $TRACE_PATH | \ + unique_timestamps_count=$(_run_babeltrace_cmd -n all $TRACE_PATH | \ cut -d, -f1 | uniq | wc -l) test $unique_timestamps_count -eq 1 ok $? "Unique event timestamps with clock override: $unique_timestamps_count expect 1" diff --git a/tests/regression/tools/clear/test_kernel b/tests/regression/tools/clear/test_kernel index 2e383b8aa..2819c24bc 100755 --- a/tests/regression/tools/clear/test_kernel +++ b/tests/regression/tools/clear/test_kernel @@ -214,7 +214,7 @@ function test_kernel_basic_streaming_live_viewer () wait_live_trace_ready net://localhost # Connect a live viewer - $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path & + _run_babeltrace_cmd -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path & local viewer_pid=$! wait_live_viewer_connect net://localhost @@ -260,7 +260,7 @@ function test_kernel_streaming_live_viewer () wait_live_trace_ready net://localhost # Connect a live viewer - $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path & + _run_babeltrace_cmd -i lttng-live net://localhost/host/$remote_trace_path > $bt_output_path & local viewer_pid=$! wait_live_viewer_connect net://localhost diff --git a/tests/regression/tools/clear/test_ust b/tests/regression/tools/clear/test_ust index 104753b98..c916dd921 100755 --- a/tests/regression/tools/clear/test_ust +++ b/tests/regression/tools/clear/test_ust @@ -247,7 +247,6 @@ function test_ust_basic_streaming_live_viewer () local remote_trace_path="${HOSTNAME}/${SESSION_NAME}" local channel_name="chan" local bt_output_path=$(mktemp -u -t tmp.test_${FUNCNAME[0]}_bt_output_path.XXXXXX) - local bt_error_path=$(mktemp -t "tmp.${FUNCNAME[0]}_bt_error.XXXXXX") local file_sync_before_exit=$(mktemp -u -t tmp.test_${FUNCNAME[0]}_sync_before_exit.XXXXXX) diag "Test ust basic streaming live with viewer" @@ -260,7 +259,7 @@ function test_ust_basic_streaming_live_viewer () wait_live_trace_ready net://localhost # Connect a live viewer - $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path --params=session-not-found-action=end 1> $bt_output_path 2> "${bt_error_path}" & + _run_babeltrace_cmd -i lttng-live net://localhost/host/$remote_trace_path --params=session-not-found-action=end 1> $bt_output_path & local viewer_pid=$! local viewer_iter=0 @@ -292,7 +291,6 @@ function test_ust_basic_streaming_live_viewer () pass "Wait for viewer to exit" rm -f $bt_output_path - clean_path "${bt_error_path}" rm -f $file_sync_before_exit } @@ -306,7 +304,6 @@ function test_ust_streaming_live_viewer () local remote_trace_path="${HOSTNAME}/${SESSION_NAME}" local channel_name="chan" local bt_output_path=$(mktemp -u -t tmp.test_${FUNCNAME[0]}_bt_output_path.XXXXXX) - local bt_error_path=$(mktemp -t "tmp.${FUNCNAME[0]}_bt_error.XXXXXX") diag "Test ust streaming live clear with viewer" diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, buffer_type=$buffer_type" @@ -318,7 +315,7 @@ function test_ust_streaming_live_viewer () wait_live_trace_ready net://localhost # Connect a live viewer - $BABELTRACE_BIN -i lttng-live net://localhost/host/$remote_trace_path --params=session-not-found-action=end 1> $bt_output_path 2> "${bt_error_path}" & + _run_babeltrace_cmd -i lttng-live net://localhost/host/$remote_trace_path --params=session-not-found-action=end 1> $bt_output_path & local viewer_pid=$! wait_live_viewer_connect net://localhost @@ -334,7 +331,6 @@ function test_ust_streaming_live_viewer () pass "Wait for viewer to exit" clean_path $bt_output_path - clean_path "${bt_error_path}" } function test_ust_streaming_live_viewer_new_metadata_after_clear () @@ -348,7 +344,6 @@ function test_ust_streaming_live_viewer_new_metadata_after_clear () local channel_name="chan" local bt_output_path=$(mktemp -t "tmp.${FUNCNAME[0]}_bt_output.XXXXXX") - local bt_error_path=$(mktemp -t "tmp.${FUNCNAME[0]}_bt_error.XXXXXX") local file_sync_before_exit=$(mktemp -u -t "tmp.${FUNCNAME[0]}_sync_before_exit.XXXXXX") diag "Test ust streaming live clear with viewer with new metadata after clear" @@ -368,7 +363,7 @@ function test_ust_streaming_live_viewer_new_metadata_after_clear () wait_live_trace_ready net://localhost # Connect a live viewer - $BABELTRACE_BIN -i lttng-live "net://localhost/host/$remote_trace_path" --params=session-not-found-action=end 1> "$bt_output_path" 2> "$bt_error_path" & + _run_babeltrace_cmd -i lttng-live "net://localhost/host/$remote_trace_path" --params=session-not-found-action=end 1> "$bt_output_path" & local viewer_pid=$! local viewer_iter=0 @@ -428,7 +423,6 @@ function test_ust_streaming_live_viewer_new_metadata_after_clear () pass "Wait for viewer to exit" clean_path "$bt_output_path" - clean_path "$bt_error_path" rm -f "$file_sync_before_exit" } diff --git a/tests/regression/tools/exclusion/test_exclusion b/tests/regression/tools/exclusion/test_exclusion index 6b3a14fd4..8f510f9c2 100755 --- a/tests/regression/tools/exclusion/test_exclusion +++ b/tests/regression/tools/exclusion/test_exclusion @@ -54,7 +54,7 @@ function dry_run run_apps stop_lttng_tracing_ok $SESSION_NAME - nb_events=$("$BABELTRACE_BIN" $trace_path | wc -l) + nb_events=$("_run_babeltrace_cmd" $trace_path | wc -l) if [ "$nb_events" -ne "0" ]; then ok 0 "Events were found during the dry run without exclusion" else @@ -87,7 +87,7 @@ function test_exclusion # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=$("$BABELTRACE_BIN" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name_expected_to_be_missing}\"]" -c sink.lttngtest.field_stats | grep -v index 2> /dev/null) + stats=$("_run_babeltrace_cmd" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name_expected_to_be_missing}\"]" -c sink.lttngtest.field_stats | grep -v index) if [ ! -z "$stats" ]; then fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" else @@ -140,7 +140,7 @@ function test_exclusion_tracing_started # Destroy session destroy_lttng_session_ok $SESSION_NAME - stats=$("$BABELTRACE_BIN" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name_expected_to_be_missing}\"]" -c sink.lttngtest.field_stats | grep -v index 2> /dev/null) + stats=$("_run_babeltrace_cmd" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name_expected_to_be_missing}\"]" -c sink.lttngtest.field_stats | grep -v index) if [ ! -z "$stats" ]; then fail "Excluded event \"$event_name_expected_to_be_missing\" was found in trace!" else diff --git a/tests/regression/tools/metadata/test_kernel b/tests/regression/tools/metadata/test_kernel index d38af841d..1b0225ec5 100755 --- a/tests/regression/tools/metadata/test_kernel +++ b/tests/regression/tools/metadata/test_kernel @@ -47,7 +47,7 @@ function test_kernel () metadata_path=$(find "${expected_path}/${session_name}"* -name "metadata") metadata_path=$(dirname "$metadata_path") - $BABELTRACE_BIN --output-format=ctf-metadata "${metadata_path}" > "$metadata" + _run_babeltrace_cmd --output-format=ctf-metadata "${metadata_path}" > "$metadata" # Extract "env" scope awk '/env {/,/};/' < "$metadata" > "$metadata_env" diff --git a/tests/regression/tools/metadata/test_ust b/tests/regression/tools/metadata/test_ust index 05a2a8bec..fbcb519c6 100755 --- a/tests/regression/tools/metadata/test_ust +++ b/tests/regression/tools/metadata/test_ust @@ -57,7 +57,7 @@ function test_per_uid () metadata_path=$(find "${expected_path}/${session_name}"* -name "metadata") metadata_path=$(dirname "$metadata_path") - $BABELTRACE_BIN --output-format=ctf-metadata "${metadata_path}" > "$metadata" + _run_babeltrace_cmd --output-format=ctf-metadata "${metadata_path}" > "$metadata" # Extract "env" scope awk '/env {/,/};/' < "$metadata" > "$metadata_env" @@ -156,7 +156,7 @@ function test_per_pid () metadata_path=$(find "${expected_path}/${session_name}"* -name "metadata") metadata_path=$(dirname "$metadata_path") - $BABELTRACE_BIN --output-format=ctf-metadata "${metadata_path}" 1> "$metadata" + _run_babeltrace_cmd --output-format=ctf-metadata "${metadata_path}" 1> "$metadata" # Extract "env" scope awk '/env {/,/};/' < "$metadata" > "$metadata_env" diff --git a/tests/regression/tools/tracefile-limits/test_tracefile_count b/tests/regression/tools/tracefile-limits/test_tracefile_count index 9253d3ec2..3d7d6abbc 100755 --- a/tests/regression/tools/tracefile-limits/test_tracefile_count +++ b/tests/regression/tools/tracefile-limits/test_tracefile_count @@ -140,7 +140,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_BIN" --plugin-path "${BT2_PLUGINS_DIR}" convert $trace_path -c filter.lttngtest.event_name -p "names=[\"${event_name}\"]" -c sink.lttngtest.field_stats) + stats=$("_run_babeltrace_cmd" --plugin-path "${BT2_PLUGINS_DIR}" convert $trace_path -c filter.lttngtest.event_name -p "names=[\"${event_name}\"]" -c sink.lttngtest.field_stats) validate_min_max "$stats" "intfield" "[0-9]+" "$expected_max" ok $? "Trace validation - intfield" diff --git a/tests/regression/ust/buffers-pid/test_buffers_pid b/tests/regression/ust/buffers-pid/test_buffers_pid index 9463d1a51..a18cdbf05 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_BIN" $TRACE_PATH | grep $EVENT_NAME | wc -l) + out=$("_run_babeltrace_cmd" $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_BIN" $TRACE_PATH | grep $EVENT_NAME | wc -l) + out=$("_run_babeltrace_cmd" $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." diff --git a/tests/regression/ust/clock-override/test_clock_override b/tests/regression/ust/clock-override/test_clock_override index c7157720e..9cf4ebc5a 100755 --- a/tests/regression/ust/clock-override/test_clock_override +++ b/tests/regression/ust/clock-override/test_clock_override @@ -88,7 +88,7 @@ function test_getcpu_override_metadata() local TRACE_METADATA_FILE_PATH="$(find "$TRACE_PATH" -name metadata -type f)" local TRACE_METADATA_DIR="$(dirname "$TRACE_METADATA_FILE_PATH")" - $BABELTRACE_BIN -o ctf-metadata -w $ctf_metadata_file $TRACE_METADATA_DIR + _run_babeltrace_cmd -o ctf-metadata -w $ctf_metadata_file $TRACE_METADATA_DIR ok $? "Metadata extraction from babeltrace" extract_clock_metadata $ctf_metadata_file $clock_metadata_file @@ -124,7 +124,7 @@ function test_getcpu_override_timestamp() # Use Babeltrace with "-n all" to give a comma separated list for # easy extraction of timestamps. - unique_timestamps_count=$($BABELTRACE_BIN -n all $TRACE_PATH | \ + unique_timestamps_count=$(_run_babeltrace_cmd -n all $TRACE_PATH | \ cut -d, -f1 | uniq | wc -l) test $unique_timestamps_count -gt 1 ok $? "Unique event timestamps without clock override: $unique_timestamps_count expect >1" @@ -146,7 +146,7 @@ function test_getcpu_override_timestamp() # Use Babeltrace with "-n all" to give a comma separated list for # easy extraction of timestamps. - unique_timestamps_count=$($BABELTRACE_BIN -n all $TRACE_PATH | \ + unique_timestamps_count=$(_run_babeltrace_cmd -n all $TRACE_PATH | \ cut -d, -f1 | uniq | wc -l) test $unique_timestamps_count -eq 1 ok $? "Unique event timestamps with clock override: $unique_timestamps_count expect 1" diff --git a/tests/regression/ust/getcpu-override/test_getcpu_override b/tests/regression/ust/getcpu-override/test_getcpu_override index 7723a7679..f6a99a274 100755 --- a/tests/regression/ust/getcpu-override/test_getcpu_override +++ b/tests/regression/ust/getcpu-override/test_getcpu_override @@ -96,7 +96,7 @@ compare() echo "$(( ${SEQUENCE_SEED[$i]} % $num_cpus))" done diag "Dumping trace" - $BABELTRACE_BIN $TRACE_PATH | awk '{print "# " $0}' + _run_babeltrace_cmd $TRACE_PATH | awk '{print "# " $0}' fi fi } @@ -113,7 +113,7 @@ test_getcpu_override_fail() destroy_lttng_session_ok $SESSION_NAME # Move output to an array by using =($()) - local cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p')) + local cpuid_events=($(_run_babeltrace_cmd $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p')) local num_events=${#cpuid_events[*]} test $num_events -eq $NUM_EVENT ok $? "Extraction without getcpu plugin have $num_events/$NUM_EVENT" @@ -133,7 +133,7 @@ test_getcpu_override() stop_lttng_tracing_ok $SESSION_NAME destroy_lttng_session_ok $SESSION_NAME - local cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p')) + local cpuid_events=($(_run_babeltrace_cmd $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p')) local num_events=${#cpuid_events[*]} test $num_events -eq $NUM_EVENT ok $? "Extraction with getcpu plugin have $num_events/$NUM_EVENT" diff --git a/tests/regression/ust/low-throughput/test_low_throughput b/tests/regression/ust/low-throughput/test_low_throughput index 2861324f2..46008c474 100755 --- a/tests/regression/ust/low-throughput/test_low_throughput +++ b/tests/regression/ust/low-throughput/test_low_throughput @@ -49,7 +49,7 @@ stop_lttng_sessiond last_val=0 out=0 -"$BABELTRACE_BIN" $TRACE_PATH | while read event; +"_run_babeltrace_cmd" $TRACE_PATH | while read event; do val=$(echo $event | cut -f10 -d" ") val=${val%?} diff --git a/tests/regression/ust/multi-session/test_multi_session b/tests/regression/ust/multi-session/test_multi_session index c0d1c307e..e407859c4 100755 --- a/tests/regression/ust/multi-session/test_multi_session +++ b/tests/regression/ust/multi-session/test_multi_session @@ -41,7 +41,7 @@ test_multi_session() { for i in $(seq 0 3); do stop_lttng_tracing_ok "$SESSION_NAME-$i" destroy_lttng_session_ok "$SESSION_NAME-$i" - out=$($BABELTRACE_BIN "$TRACE_PATH/$i" | grep -c "$EVENT_NAME$i") + out=$(_run_babeltrace_cmd "$TRACE_PATH/$i" | grep -c "$EVENT_NAME$i") if [ "$out" -ne $NR_ITER ]; then fail "Trace validation of $SESSION_NAME-$i" diag "No events found." 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 f1132c2e4..3ddd654bb 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_BIN" "$TRACE_PATH" | grep -c $EVENT_NAME) + out=$("_run_babeltrace_cmd" "$TRACE_PATH" | grep -c $EVENT_NAME) if [ "$out" -eq 0 ]; then fail "Trace validation" diag "No event(s) found. We are supposed to have at least one." -- 2.34.1