From: Kienan Stewart Date: Thu, 28 Nov 2024 18:41:06 +0000 (-0500) Subject: Clean-up: Tests: Provide default cwd when testing relayd working dir X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=799a0e20371c5fe6db9a0fa9d720f3cfa6f39fdb;p=lttng-tools.git Clean-up: Tests: Provide default cwd when testing relayd working dir In `tap.sh`, `is()` ends up aborting the test script if it is passed an empty (null) value. When, for example, lttng-relayd fails to start, the `cwd` will be empty as `readlink` will fail. E.g. Output when a test fails and limits the runs: ``` ... ok 4 - lttng-relayd already started --- duration_ms: 12.914679 ... not ok 5 - Found lttng-relayd --- duration_ms: 49.119194 ... ./tests/regression/tools/working-directory//../../..//utils/tap/tap.sh: line 288: 1: parameter null or not set ``` Change-Id: I54ac5c23a6d2604d261e8240679a827a12a57a1a Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- diff --git a/tests/regression/tools/working-directory/test_relayd_working_directory b/tests/regression/tools/working-directory/test_relayd_working_directory index 4e5fa4e12..d45aeb7b2 100755 --- a/tests/regression/tools/working-directory/test_relayd_working_directory +++ b/tests/regression/tools/working-directory/test_relayd_working_directory @@ -69,7 +69,7 @@ function test_relayd_daemon() cwd=$(readlink "/proc/${pid}/cwd") - is "$cwd" "$working_dir" "Working directory changed" + is "${cwd:-no working directory found}" "$working_dir" "Working directory changed" stop_lttng_relayd rm -rf "$working_dir" @@ -89,8 +89,7 @@ function test_relayd_daemon_no_working_dir() ok $? "Found lttng-relayd" cwd=$(readlink "/proc/${pid}/cwd") - - is "$cwd" "$expected_working_dir" "Working directory is $expected_working_dir" + is "${cwd:-no working directory found}" "$expected_working_dir" "Working directory is $expected_working_dir" stop_lttng_relayd rm -rf "$working_dir" @@ -110,8 +109,7 @@ function test_relayd_background() ok $? "Found lttng-relayd" cwd=$(readlink "/proc/${pid}/cwd") - - is "$cwd" "$working_dir" "Working directory changed" + is "${cwd:-no working directory found}" "$working_dir" "Working directory changed" stop_lttng_relayd rm -rf "$working_dir" @@ -131,8 +129,7 @@ function test_relayd_background_no_working_dir() ok $? "Found lttng-relayd" cwd=$(readlink "/proc/${pid}/cwd") - - is "$cwd" "$expected_working_dir" "Working directory is $expected_working_dir" + is "${cwd:-no working directory found}" "$expected_working_dir" "Working directory is $expected_working_dir" stop_lttng_relayd rm -rf "$working_dir" @@ -169,7 +166,7 @@ function test_relayd_debug_permission() ok $? "Found lttng-relayd" cwd=$(readlink "/proc/${pid}/cwd") - is "$cwd" "$working_dir" "Working directory changed" + is "${cwd:-no working directory found}" "$working_dir" "Working directory changed" grep -q "$output_pattern" "${RELAYD_ERROR_OUTPUT_DEST}" ok $? "Warning about missing write permission is present" @@ -229,8 +226,7 @@ function test_relayd_env() ok $? "Found lttng-relayd" cwd=$(readlink "/proc/$pid/cwd") - - is "$cwd" "$working_dir" "Working directory changed" + is "${cwd:-no working directory found}" "$working_dir" "Working directory changed" stop_lttng_relayd rm -rf "$working_dir" @@ -253,8 +249,7 @@ function test_relayd_cmdline_overwrite_env() ok $? "Found lttng-relayd" cwd=$(readlink "/proc/$pid/cwd") - - is "$cwd" "$working_dir_cmdline" "Working directory is the one from command line" + is "${cwd:-no working directory found}" "$working_dir_cmdline" "Working directory is the one from command line" stop_lttng_relayd rm -rf "$working_dir_env" "$working_dir_cmdline"