diff mbox series

[01/10] t/test-lib: fix quoting of TEST_RESULTS_SAN_FILE

Message ID 601670912eeb80cc599c0e7af4ea87c370ae831d.1728906490.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series Platform compatibility fixes | expand

Commit Message

Patrick Steinhardt Oct. 14, 2024, 12:21 p.m. UTC
When assembling our LSAN_OPTIONS that configure the leak sanitizer we
end up prepending the string with various different colon-separated
options via calls to `prepend_var`. One of the settings we add is the
path where the sanitizer should store logs, which can be an arbitrary
filesystem path.

Naturally, filesystem paths may contain whitespace characters. And while
it does seem as if we were quoting the value, we use escaped quotes and
consequently split up the value if it does contain spaces. This leads to
the following error in t0000 when having a value with whitespaces:

    .../t/test-lib.sh: eval: line 64: unexpected EOF while looking for matching `"'
    ++ return 1
    error: last command exited with $?=1
    not ok 5 - subtest: 3 passing tests

The error itself is a bit puzzling at first. The basic problem is that
the code sees the leading escaped quote during eval, but because we
truncate everything after the space character it doesn't see the
trailing escaped quote and thus fails to parse the string.

Properly quote the value to fix the issue while using single-quotes to
quote the inner value passed to eval. The issue can be reproduced by
t0000 with such a path that contains spaces.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/test-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Taylor Blau Oct. 14, 2024, 10 p.m. UTC | #1
On Mon, Oct 14, 2024 at 02:21:12PM +0200, Patrick Steinhardt wrote:
> Properly quote the value to fix the issue while using single-quotes to
> quote the inner value passed to eval. The issue can be reproduced by
> t0000 with such a path that contains spaces.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  t/test-lib.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index b1a8ee5c002..241198ba95f 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -1572,7 +1572,7 @@ then
>
>  	prepend_var LSAN_OPTIONS : dedup_token_length=9999
>  	prepend_var LSAN_OPTIONS : log_exe_name=1
> -	prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
> +	prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'"

Makes sense.

Thanks,
Taylor
diff mbox series

Patch

diff --git a/t/test-lib.sh b/t/test-lib.sh
index b1a8ee5c002..241198ba95f 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1572,7 +1572,7 @@  then
 
 	prepend_var LSAN_OPTIONS : dedup_token_length=9999
 	prepend_var LSAN_OPTIONS : log_exe_name=1
-	prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
+	prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'"
 	export LSAN_OPTIONS
 
 elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||