From 3b3f3df7ff0a2bab9043ce2bd9552415d7e6e806 Mon Sep 17 00:00:00 2001 From: silvioprog Date: Sat, 27 Jan 2024 00:29:31 -0300 Subject: [PATCH] Fix all tests on macOS --- cmake/SgFlags.cmake | 4 ++-- test/test_str.c | 6 +++--- test/test_utils.c | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmake/SgFlags.cmake b/cmake/SgFlags.cmake index f1732017..a4cca25c 100644 --- a/cmake/SgFlags.cmake +++ b/cmake/SgFlags.cmake @@ -19,7 +19,7 @@ # # Cross-platform library which helps to develop web servers or frameworks. # -# Copyright (C) 2016-2019 Silvio Clecio +# Copyright (C) 2016-2024 Silvio Clecio # # Sagui library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -49,7 +49,7 @@ if(MINGW) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static") endif() -if(BUILD_TESTING) +if(BUILD_TESTING AND NOT APPLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition") endif() diff --git a/test/test_str.c b/test/test_str.c index a9a7bec8..0158eb9a 100644 --- a/test/test_str.c +++ b/test/test_str.c @@ -7,7 +7,7 @@ * * Cross-platform library which helps to develop web servers or frameworks. * - * Copyright (C) 2016-2020 Silvio Clecio + * Copyright (C) 2016-2024 Silvio Clecio * * Sagui library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -44,9 +44,9 @@ static void test_str_printf_va(struct sg_str *str, const char *fmt, va_list ap) { ASSERT(sg_str_printf_va(NULL, fmt, ap) == EINVAL); ASSERT(sg_str_printf_va(str, NULL, ap) == EINVAL); -#ifndef __arm__ +#if !(defined(__arm__) || defined(__arm64__)) ASSERT(sg_str_printf_va(str, fmt, NULL) == EINVAL); -#endif /* __arm__ */ +#endif /* !(__arm__ || __arm64__) */ sg_str_clear(str); sg_str_printf_va(str, fmt, ap); diff --git a/test/test_utils.c b/test/test_utils.c index fbeb34eb..d028b9ad 100644 --- a/test/test_utils.c +++ b/test/test_utils.c @@ -7,7 +7,7 @@ * * Cross-platform library which helps to develop web servers or frameworks. * - * Copyright (C) 2016-2020 Silvio Clecio + * Copyright (C) 2016-2024 Silvio Clecio * * Sagui library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -477,7 +477,9 @@ static void test_tmpdir(void) { ASSERT(strcmp(tmp, path) == 0); #elif defined(__ANDROID__) /* _WIN32 */ ASSERT(strcmp(tmp, "/data/local/tmp") == 0); -#else /* __ANDROID__ */ +#elif defined(__APPLE__) /* __ANDROID__*/ + ASSERT(strncmp(tmp, getenv("TMPDIR"), strlen(tmp)) == 0); +#else /* __APPLE__ */ ASSERT(strcmp(tmp, "/tmp") == 0); #endif /* _WIN32 */ sg_free(tmp);