]> git.lttng.org Git - lttng-tools.git/commitdiff
Clean-up: Tests: Provide default cwd when testing relayd working dir
authorKienan Stewart <kstewart@efficios.com>
Thu, 28 Nov 2024 18:41:06 +0000 (13:41 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 Dec 2024 15:55:37 +0000 (15:55 +0000)
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 <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/working-directory/test_relayd_working_directory

index 4e5fa4e122af0e9e8860fe5e4df1f2bb0579ed38..d45aeb7b2710dd4b306fffe8ae3c31f473ccdd4a 100755 (executable)
@@ -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"
This page took 0.029259 seconds and 4 git commands to generate.