From 56f1d5ed68e84ba5dfa328ea2291b8f46c995125 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 20 May 2024 16:55:00 +0300 Subject: [PATCH] Tests: Make the config.h grep patterns Meson compatible Now the test scripts detect both #define HAVE_DECODER_ARM #define HAVE_DECODER_ARM 1 as support for the ARM filter without confusing it with these: #define HAVE_DECODER_ARM64 #define HAVE_DECODER_ARM64 1 Previously only the ones ending with " 1" were accepted for the macros where this kind of confusion was possible. This should help with Meson support because Meson's built-in features produce config.h entries that are either #define FOO 1 #define FOO 0 or: #define FOO #undef FOO The former method has a benefit that one can use "#if FOO" and -Wundef will catch if a #define is missing (for example, it helps catching typos). But XZ Utils has to use the latter since it has been convenient with Autoconf's default behavior.[*] While it's easy to emulate the Autoconf style (#define FOO 1 vs. no #define at all) in Meson, it results in clumsy code. Thus it's better to change the few places in the tests where this difference matters. [*] While most checks in Autoconf default to the second style above, a few things use the first style (like AC_CHECK_DECLS). The mix of both styles is the most confusing as one has to remember which macro needs #ifdef and which #if. Currently HAVE_VISIBILITY is only such config.h entry that is 1 or 0. It comes unmodified from Gnulib's visibility.m4. --- tests/test_compress.sh | 4 ++-- tests/test_files.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_compress.sh b/tests/test_compress.sh index a10343a7..36a9ef94 100755 --- a/tests/test_compress.sh +++ b/tests/test_compress.sh @@ -142,9 +142,9 @@ test_xz -4 test_filter() { if test -f ../config.h ; then - grep "define HAVE_ENCODER_$1 1" ../config.h > /dev/null \ + grep "define HAVE_ENCODER_$1[ 1]*\$" ../config.h > /dev/null \ || return - grep "define HAVE_DECODER_$1 1" ../config.h > /dev/null \ + grep "define HAVE_DECODER_$1[ 1]*\$" ../config.h > /dev/null \ || return fi shift diff --git a/tests/test_files.sh b/tests/test_files.sh index 99c9f2fa..894130c1 100755 --- a/tests/test_files.sh +++ b/tests/test_files.sh @@ -39,7 +39,7 @@ EXIT_STATUS=0 have_feature() { test -f ../config.h || return 0 - grep "define HAVE_$1 1" ../config.h > /dev/null && return 0 + grep "define HAVE_$1[ 1]*\$" ../config.h > /dev/null && return 0 printf '%s: Skipping because HAVE_%s is not enabled\n' "$2" "$1" EXIT_STATUS=77 return 1