From: Francis Deslauriers Date: Mon, 17 May 2021 19:01:33 +0000 (-0400) Subject: Cleanup: tests: use find's `-name` option instead of grep X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fc2dd19e2c7dbeaa86654b47c0a2c221b7018ecf;p=lttng-tools.git Cleanup: tests: use find's `-name` option instead of grep This prevents grep of finding matches in the leading directories listed by find. It caused problem when I used the "metadata" string in one of the directory names: /tmp/tmp.test_regen_metadata_ust_trace_path.6FbwPF/ Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: I7165a3b4e4a16c793fe51c40484978be3a99dbfc --- diff --git a/tests/regression/tools/metadata/test_kernel b/tests/regression/tools/metadata/test_kernel index 82faf43b9..630fe2d4a 100755 --- a/tests/regression/tools/metadata/test_kernel +++ b/tests/regression/tools/metadata/test_kernel @@ -45,7 +45,7 @@ function test_kernel () # bt1 accepts only a directory while bt2 accepts either the metadata # file directly or a directory with an immediate metadata file. # Settle for the common denominator. - metadata_path=$(find "${expected_path}/${session_name}"* | grep metadata) + metadata_path=$(find "${expected_path}/${session_name}"* -name "metadata") metadata_path=$(dirname "$metadata_path") $BABELTRACE_BIN --output-format=ctf-metadata "${metadata_path}" > "$metadata" diff --git a/tests/regression/tools/metadata/test_ust b/tests/regression/tools/metadata/test_ust index cea0d5ced..ba34b7f4c 100755 --- a/tests/regression/tools/metadata/test_ust +++ b/tests/regression/tools/metadata/test_ust @@ -56,7 +56,7 @@ function test_per_uid () # bt1 accepts only a directory while bt2 accepts either the metadata # file directly or a directory with an immediate metadata file. # Settle for the common denominator. - metadata_path=$(find "${expected_path}/${session_name}"* | grep metadata) + metadata_path=$(find "${expected_path}/${session_name}"* -name "metadata") metadata_path=$(dirname "$metadata_path") $BABELTRACE_BIN --output-format=ctf-metadata "${metadata_path}" > "$metadata" @@ -150,7 +150,7 @@ function test_per_pid () # bt1 accepts only a directory while bt2 accepts either the metadata # file directly or a directory with an immediate metadata file. # Settle for the common denominator. - metadata_path=$(find "${expected_path}/${session_name}"* | grep metadata) + metadata_path=$(find "${expected_path}/${session_name}"* -name "metadata") metadata_path=$(dirname "$metadata_path") $BABELTRACE_BIN --output-format=ctf-metadata "${metadata_path}" 1> "$metadata" diff --git a/tests/regression/tools/regen-metadata/test_kernel b/tests/regression/tools/regen-metadata/test_kernel index 8c31d488e..3056e3904 100755 --- a/tests/regression/tools/regen-metadata/test_kernel +++ b/tests/regression/tools/regen-metadata/test_kernel @@ -32,7 +32,7 @@ function test_kernel_streaming () validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* # Find the metadata file - metadata_path=$(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* | grep metadata) + metadata_path=$(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* -name "metadata") # Empty the metadata file echo -n > "$metadata_path" @@ -61,7 +61,7 @@ function test_kernel_local () validate_trace $EVENT_NAME "$TRACE_PATH" # Find the metadata file - metadata_path=$(find "$TRACE_PATH"* | grep metadata) + metadata_path=$(find "$TRACE_PATH"* -name "metadata") # Empty the metadata file echo -n > "$metadata_path" diff --git a/tests/regression/tools/regen-metadata/test_ust b/tests/regression/tools/regen-metadata/test_ust index 2a7613074..d23b4f203 100755 --- a/tests/regression/tools/regen-metadata/test_ust +++ b/tests/regression/tools/regen-metadata/test_ust @@ -63,7 +63,7 @@ function test_ust_streaming () validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* # Find the metadata file - metadata_path=$(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* | grep metadata) + metadata_path=$(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* -name "metadata") # Empty the metadata file echo -n > "$metadata_path" @@ -107,7 +107,7 @@ function test_ust_local () validate_trace $EVENT_NAME "$TRACE_PATH" # Find the metadata file - metadata_path=$(find "$TRACE_PATH"* | grep metadata) + metadata_path=$(find "$TRACE_PATH"* -name "metadata") # Empty the metadata file echo -n > "$metadata_path" diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 9ff25a0a5..530a10623 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1783,7 +1783,7 @@ function validate_metadata_event () local nr_event_id=$2 local trace_path=$3 - local metadata_file=$(find $trace_path | grep metadata) + local metadata_file=$(find $trace_path -name "metadata") local metadata_path=$(dirname $metadata_file) which $BABELTRACE_BIN >/dev/null