From 808730a32c0f21200c91be329f58c816c54d0324 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Tue, 16 Jul 2024 10:02:34 -0500 Subject: [PATCH] Fix the zlib-ng failing tests, for real I failed to properly account for the case in which the two string are completely equal. (cherry picked from commit 4b31974ec5d73afd8deb5b89b35ad917ebef05ba) --- .../linuxlike/1 pkg-config/prog-checkver.c | 17 ++++++++++------- .../13 cmake dependency/prog-checkver.c | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/test cases/linuxlike/1 pkg-config/prog-checkver.c b/test cases/linuxlike/1 pkg-config/prog-checkver.c index fe705d45da99..14d574642923 100644 --- a/test cases/linuxlike/1 pkg-config/prog-checkver.c +++ b/test cases/linuxlike/1 pkg-config/prog-checkver.c @@ -4,6 +4,12 @@ #include static bool check_version(const char *zlib_ver, const char *found_zlib) { + if (zlib_ver == found_zlib) + return true; + + if (strcmp(zlib_ver, found_zlib) == 0) + return true; + #ifdef ZLIBNG_VERSION const char *ptr = strstr(zlib_ver, found_zlib); @@ -16,14 +22,11 @@ static bool check_version(const char *zlib_ver, const char *found_zlib) { * that FOUND_ZLIB is the start of ZLIB_VERSION, so compare the rest. */ ptr += strlen(found_zlib); - if (strcmp(ptr, ".zlib-ng") != 0) - return false; -#else - if (strcmp(zlib_ver, found_zlib) != 0) - return false; + if (strcmp(ptr, ".zlib-ng") == 0) + return true; #endif - return true; + return false; } int main(void) { @@ -31,7 +34,7 @@ int main(void) { if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) { printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); #ifdef ZLIBNG_VERSION - puts("Note that in the case of zlib-ng, a version suffix of .zlib-ng is expected\n"); + puts("Note that in the case of zlib-ng, a version suffix of .zlib-ng is expected"); #endif return 2; } diff --git a/test cases/linuxlike/13 cmake dependency/prog-checkver.c b/test cases/linuxlike/13 cmake dependency/prog-checkver.c index fe705d45da99..14d574642923 100644 --- a/test cases/linuxlike/13 cmake dependency/prog-checkver.c +++ b/test cases/linuxlike/13 cmake dependency/prog-checkver.c @@ -4,6 +4,12 @@ #include static bool check_version(const char *zlib_ver, const char *found_zlib) { + if (zlib_ver == found_zlib) + return true; + + if (strcmp(zlib_ver, found_zlib) == 0) + return true; + #ifdef ZLIBNG_VERSION const char *ptr = strstr(zlib_ver, found_zlib); @@ -16,14 +22,11 @@ static bool check_version(const char *zlib_ver, const char *found_zlib) { * that FOUND_ZLIB is the start of ZLIB_VERSION, so compare the rest. */ ptr += strlen(found_zlib); - if (strcmp(ptr, ".zlib-ng") != 0) - return false; -#else - if (strcmp(zlib_ver, found_zlib) != 0) - return false; + if (strcmp(ptr, ".zlib-ng") == 0) + return true; #endif - return true; + return false; } int main(void) { @@ -31,7 +34,7 @@ int main(void) { if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) { printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); #ifdef ZLIBNG_VERSION - puts("Note that in the case of zlib-ng, a version suffix of .zlib-ng is expected\n"); + puts("Note that in the case of zlib-ng, a version suffix of .zlib-ng is expected"); #endif return 2; }