Fix the zlib-ng failing tests, for real

I failed to properly account for the case in which the two string are
completely equal.
pull/12624/merge
Tristan Partin 7 months ago committed by Dylan Baker
parent a51d5f36da
commit 4b31974ec5
  1. 17
      test cases/linuxlike/1 pkg-config/prog-checkver.c
  2. 17
      test cases/linuxlike/13 cmake dependency/prog-checkver.c

@ -4,6 +4,12 @@
#include <string.h> #include <string.h>
static bool check_version(const char *zlib_ver, const char *found_zlib) { 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 #ifdef ZLIBNG_VERSION
const char *ptr = strstr(zlib_ver, found_zlib); 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. * that FOUND_ZLIB is the start of ZLIB_VERSION, so compare the rest.
*/ */
ptr += strlen(found_zlib); ptr += strlen(found_zlib);
if (strcmp(ptr, ".zlib-ng") != 0) if (strcmp(ptr, ".zlib-ng") == 0)
return false; return true;
#else
if (strcmp(zlib_ver, found_zlib) != 0)
return false;
#endif #endif
return true; return false;
} }
int main(void) { int main(void) {
@ -31,7 +34,7 @@ int main(void) {
if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) { if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) {
printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION);
#ifdef ZLIBNG_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 #endif
return 2; return 2;
} }

@ -4,6 +4,12 @@
#include <string.h> #include <string.h>
static bool check_version(const char *zlib_ver, const char *found_zlib) { 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 #ifdef ZLIBNG_VERSION
const char *ptr = strstr(zlib_ver, found_zlib); 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. * that FOUND_ZLIB is the start of ZLIB_VERSION, so compare the rest.
*/ */
ptr += strlen(found_zlib); ptr += strlen(found_zlib);
if (strcmp(ptr, ".zlib-ng") != 0) if (strcmp(ptr, ".zlib-ng") == 0)
return false; return true;
#else
if (strcmp(zlib_ver, found_zlib) != 0)
return false;
#endif #endif
return true; return false;
} }
int main(void) { int main(void) {
@ -31,7 +34,7 @@ int main(void) {
if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) { if (!check_version(ZLIB_VERSION, FOUND_ZLIB)) {
printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION); printf("Meson found '%s' but zlib is '%s'\n", FOUND_ZLIB, ZLIB_VERSION);
#ifdef ZLIBNG_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 #endif
return 2; return 2;
} }

Loading…
Cancel
Save