From fec42c2057018d43b2b214f6e08668239d28db08 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 12 Jun 2024 10:51:47 +0200 Subject: [PATCH 1/4] added `macos-15` to CI --- .github/workflows/CI-unixish.yml | 30 ++++++++++++++++++++++-------- .github/workflows/scriptcheck.yml | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 66da4e21bdd..f745a21e177 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-13] + os: [ubuntu-22.04, macos-13, macos-15] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} @@ -75,7 +75,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-13] + os: [ubuntu-22.04, macos-13, macos-15] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} @@ -155,7 +155,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-13] + os: [ubuntu-22.04, macos-13, macos-15] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} @@ -189,7 +189,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-13] + os: [ubuntu-22.04, macos-13, macos-15] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} @@ -223,7 +223,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-13] + os: [ubuntu-22.04, macos-13, macos-15] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} @@ -247,7 +247,7 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, macos-13] + os: [ubuntu-22.04, macos-13, macos-15] include: - xdist_n: auto # FIXME: test_color_tty fails with xdist @@ -284,9 +284,10 @@ jobs: if: contains(matrix.os, 'macos') run: | # pcre was removed from runner images in November 2022 - brew install coreutils python3 pcre gnu-sed + brew install coreutils pcre gnu-sed - - name: Install missing Python packages + - name: Install missing Python packages on ubuntu + if: contains(matrix.os, 'ubuntu') run: | python3 -m pip install pip --upgrade python3 -m pip install pytest @@ -294,6 +295,19 @@ jobs: python3 -m pip install pytest-xdist python3 -m pip install psutil + # we need to use -break-system-packages --user because the common approaches do not work. + # using pip works but it appears to install the packages into a different Python installation so they are not found later on. + # using python3 -m pip without the additional flags fails since the packages are being managed by a different tool (brew) and that lacks some of the packages. + # using pipx also does not work. + - name: Install missing Python packages on macos + if: contains(matrix.os, 'macos') + run: | + python3 -m pip install --break-system-packages --user pip --upgrade + python3 -m pip install --break-system-packages --user pytest + python3 -m pip install --break-system-packages --user pytest-timeout + python3 -m pip install --break-system-packages --user pytest-xdist + python3 -m pip install --break-system-packages --user psutil + - name: Build cppcheck run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" diff --git a/.github/workflows/scriptcheck.yml b/.github/workflows/scriptcheck.yml index a02b8c09dc8..3394604d155 100644 --- a/.github/workflows/scriptcheck.yml +++ b/.github/workflows/scriptcheck.yml @@ -203,7 +203,7 @@ jobs: dmake: strategy: matrix: - os: [ubuntu-22.04, macos-13, windows-2025] + os: [ubuntu-22.04, macos-13, macos-15, windows-2025] fail-fast: false runs-on: ${{ matrix.os }} From 1312ab8e1bca8e88513713a69045aca059624855 Mon Sep 17 00:00:00 2001 From: firewave Date: Mon, 25 Nov 2024 14:25:20 +0100 Subject: [PATCH 2/4] test/cfg: mitigated `-Wimplicit-function-declaration` compiler warnings on macOS --- test/cfg/gnu.c | 12 +++++++++++- test/cfg/posix.c | 2 ++ test/cfg/runtests.sh | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c index d000b2c1007..7ae1fb100f4 100644 --- a/test/cfg/gnu.c +++ b/test/cfg/gnu.c @@ -58,6 +58,7 @@ int deallocuse_backtrace(int size) { return numEntries; } +#if !defined(__APPLE__) void leakReturnValNotUsed_get_current_dir_name(void) { // cppcheck-suppress leakReturnValNotUsed @@ -114,7 +115,6 @@ int nullPointer_gethostbyname_r(const char* name, struct hostent* ret, const cha return gethostbyname_r(name, ret, buf, buflen, result, h_errnop); } - int nullPointer_gethostbyaddr_r(const void* addr, socklen_t len, int type, struct hostent* ret, const char* buf, size_t buflen, struct hostent** result, const int* h_errnop) { // cppcheck-suppress nullPointer @@ -129,6 +129,7 @@ int nullPointer_gethostbyaddr_r(const void* addr, socklen_t len, int type, struc (void) gethostbyaddr_r(addr, len, type, ret, buf, buflen, result, NULL); return gethostbyaddr_r(addr, len, type, ret, buf, buflen, result, h_errnop); } +#endif int nullPointer_getopt_long(int argc, char **argv, const char *optstring, const struct option *longopts, int *longindex) @@ -154,6 +155,7 @@ int nullPointer_getopt_long_only(int argc, char* const* argv, const char* optstr return getopt_long_only(argc, argv, optstring, longopts, longindex); } +#if !defined(__APPLE__) int nullPointer_getservent_r(struct servent *restrict result_buf, const char *restrict buf, size_t buflen, struct servent **restrict result) { // cppcheck-suppress nullPointer @@ -173,6 +175,7 @@ void *bufferAccessOutOfBounds_memrchr(const void *s, int c, size_t n) (void)memrchr(buf,c,43); return memrchr(s,c,n); } +#endif void knownConditionTrueFalse_ffsl(long i) { @@ -192,6 +195,7 @@ void knownConditionTrueFalse_ffsll(long long i) if (ffsll(i) == 0) {} } +#if !defined(__APPLE__) int nullPointer_semtimedop(int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) { (void) semtimedop(semid, sops, nsops, NULL); // If the timeout argument is NULL, then semtimedop() behaves exactly like semop(). @@ -227,8 +231,10 @@ int uninitvar_getpw(uid_t uid, char *buf) // cppcheck-suppress uninitvar return getpw(someUid, buf); } +#endif // Declaration necessary because there is no specific / portable header. +// https://www.eyrie.org/~eagle/software/rra-c-util/xmalloc.html extern void *xcalloc(size_t nmemb, size_t size); extern void *xmalloc(size_t size); extern void *xrealloc(void *block, size_t newsize); @@ -294,8 +300,10 @@ void valid_code(int argInt1, va_list valist_arg, const int * parg) if (__builtin_expect(argInt1, 0)) {} if (__builtin_expect_with_probability(argInt1 + 1, 2, 0.5)) {} +#ifdef __GLIBC__ if (__glibc_unlikely(argInt1 != 0)) {} if (__glibc_likely(parg != NULL)) {} +#endif const void *ax1 = __builtin_assume_aligned(parg, 16); printf("%p", ax1); const void *ax2 = __builtin_assume_aligned(parg, 32, 8); @@ -489,6 +497,7 @@ void bufferAccessOutOfBounds() free(pAlloc2); } +#if !defined(__APPLE__) void leakReturnValNotUsed() { // cppcheck-suppress [unreadVariable, constVariablePointer] @@ -508,6 +517,7 @@ void leakReturnValNotUsed() if (42 == __builtin_expect(42, 0)) return; } +#endif #if !defined(__CYGWIN__) && !defined(__APPLE__) int nullPointer_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) diff --git a/test/cfg/posix.c b/test/cfg/posix.c index f54453a471c..a3603fbabbd 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -225,6 +225,7 @@ int nullPointer_getpwnam_r(const char *name, struct passwd *pwd, char *buffer, s return getpwnam_r(name, pwd, buffer, bufsize, result); } +#if !defined(__APPLE__) int nullPointer_fgetpwent_r(FILE *restrict stream, const struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp) { // cppcheck-suppress nullPointer @@ -248,6 +249,7 @@ int nullPointer_getpwent_r(const struct passwd *restrict pwbuf, char *restrict b (void) getpwent_r(pwbuf, buf, buflen, NULL); return getpwent_r(pwbuf, buf, buflen, pwbufp); } +#endif int nullPointer_getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result) { diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 7598ffb9165..330bc3e1f7b 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -44,7 +44,7 @@ CPPCHECK_OPT=( CXX=g++ CXX_OPT=("-fsyntax-only" "-w" "-std=c++2a") CC=gcc -CC_OPT=("-fsyntax-only" "-w" "-Wno-implicit-function-declaration" "-std=c11") # TODO: remove -Wno-implicit-function-declaration when warnings are fixed on MacOS +CC_OPT=("-fsyntax-only" "-w" "-std=c11") function get_pkg_config_cflags { # TODO: get rid of the error enabling/disabling? From fc24bf59297a0ce5d2eff9822913791c0b2095f2 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 29 Nov 2024 19:42:42 +0100 Subject: [PATCH 3/4] test-signalhandler.py: adjusted expected result for `macos-14` and up --- test/signal/test-signalhandler.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/signal/test-signalhandler.py b/test/signal/test-signalhandler.py index 62ab6d79c02..6def987e328 100644 --- a/test/signal/test-signalhandler.py +++ b/test/signal/test-signalhandler.py @@ -2,6 +2,9 @@ import os import sys import pytest +import platform + +from packaging.version import Version def __lookup_cppcheck_exe(exe_name): # path the script is located in @@ -64,7 +67,10 @@ def test_segv(): assert stderr == '' lines = stdout.splitlines() if sys.platform == "darwin": - assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).' + if Version(platform.mac_ver()[0]) >= Version('14'): + assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_ACCERR (at 0x0).' + else: + assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).' else: assert lines[0] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).' # no stacktrace on macOS From d8ecd54cdb27afde4bdba23e8df67832a8264dfa Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 4 Jul 2025 13:40:21 +0200 Subject: [PATCH 4/4] testmathlib.cpp: adjusted AppleClang preprocessor check in `toDoubleNumber()` --- test/testmathlib.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index 08bf728c345..9fef087267a 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -684,7 +684,8 @@ class TestMathLib : public TestFixture { ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: invalid"); -#if defined(_LIBCPP_VERSION) && (defined(__APPLE__) && defined(__MACH__)) + // AppleClang before 18 reports a different error +#if (defined(__APPLE__) && defined(__MACH__)) && (defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 180000)) ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("1invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: 1invalid"); ASSERT_THROW_INTERNAL_EQUALS(MathLib::toDoubleNumber("1.1invalid"), INTERNAL, "Internal Error. MathLib::toDoubleNumber: conversion failed: 1.1invalid"); #else