Files
wolfssl/tests/include.am
T
Andrew Hutchings 7b89d82b35 Fix mem_track.h compile failure on multi-threaded non-Linux builds
The memLock mutex and #include <pthread.h> in mem_track.h were
declared under #ifdef DO_MEM_LIST (Linux/macOS/Zephyr only), but
referenced under the broader guard

    !defined(SINGLE_THREADED) && \
    (defined(DO_MEM_LIST) || defined(DO_MEM_STATS))

Since DO_MEM_STATS is defined whenever WOLFSSL_TRACK_MEMORY +
USE_WOLFSSL_MEMORY are set without WOLFSSL_STATIC_MEMORY, any
non-Linux/Mac/Zephyr multi-threaded build failed to compile with
implicit pthread_mutex_lock declarations and undeclared memLock.

Replace the raw pthread mutex with wolfSSL's portable mutex API
(wc_InitMutex / wc_LockMutex / wc_UnLockMutex / wc_FreeMutex) so
locking works on every platform wolfSSL already ports to.
InitMemoryTracker now calls wc_InitMutex before
wolfSSL_SetAllocators installs TrackMalloc, guarded by a
memLockInit flag for idempotency. CleanupMemoryTracker calls
wc_FreeMutex after restoring the default allocators so no
in-flight allocation races a freed mutex. The four mutex guards
in TrackMalloc/TrackFree and the two in InitMemoryTracker/
ShowMemoryTracker are unified on the same condition as the
memLock declaration itself.

ZD #21763
2026-05-11 16:20:35 +01:00

99 lines
3.9 KiB
Plaintext

# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root
if BUILD_TESTS
noinst_PROGRAMS += tests/unit.test
tests_unit_test_SOURCES = \
tests/unit.c \
tests/api.c \
tests/utils.c \
testsuite/utils.c \
tests/suites.c \
tests/w64wrapper.c \
tests/srp.c \
tests/quic.c \
examples/client/client.c \
examples/server/server.c
if BUILD_WOLFCRYPT_TESTS
tests_unit_test_SOURCES += wolfcrypt/test/test.c
endif
tests_unit_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS) $(WOLFSENTRY_INCLUDE)
tests_unit_test_LDADD = src/libwolfssl@LIBSUFFIX@.la $(LIB_STATIC_ADD) $(WOLFSENTRY_LIB)
tests_unit_test_DEPENDENCIES = src/libwolfssl@LIBSUFFIX@.la
include tests/api/include.am
endif
EXTRA_DIST += tests/unit.h \
tests/test.conf \
tests/test-sha2.conf \
tests/test-tls13.conf \
tests/test-tls13-down.conf \
tests/test-tls13-ecc.conf \
tests/test-tls13-psk.conf \
tests/test-tls13-pq-standalone.conf \
tests/test-tls13-pq-hybrid.conf \
tests/test-tls13-pq-hybrid-extra.conf \
tests/test-tls13-slhdsa-shake.conf \
tests/test-tls13-slhdsa-sha2.conf \
tests/test-tls13-slhdsa-fail.conf \
tests/test-dtls13-pq-standalone.conf \
tests/test-dtls13-pq-standalone-frag.conf \
tests/test-dtls13-pq-hybrid-frag.conf \
tests/test-dtls13-pq-hybrid-extra.conf \
tests/test-dtls13-pq-hybrid-extra-frag.conf \
tests/test-psk.conf \
tests/test-psk-no-id.conf \
tests/test-psk-no-id-sha2.conf \
tests/test-dtls.conf \
tests/test-dtls-downgrade.conf \
tests/test-dtls-fails.conf \
tests/test-dtls-fails-cipher.conf \
tests/test-dtls-group.conf \
tests/test-dtls-mtu.conf \
tests/test-dtls-reneg-client.conf \
tests/test-dtls-reneg-server.conf \
tests/test-dtls-resume.conf \
tests/test-dtls-sha2.conf \
tests/test-dtls-srtp.conf \
tests/test-dtls-srtp-fails.conf \
tests/test-dtls13.conf \
tests/test-dtls13-downgrade.conf \
tests/test-dtls13-downgrade-fails.conf \
tests/test-dtls13-psk.conf \
tests/test-dtls13-cid.conf \
tests/test-sctp.conf \
tests/test-sctp-sha2.conf \
tests/test-sig.conf \
tests/test-rsapss.conf \
tests/test-ed25519.conf \
tests/test-ed448.conf \
tests/test-enckeys.conf \
tests/test-maxfrag.conf \
tests/test-maxfrag-dtls.conf \
tests/test-fails.conf \
tests/test-chains.conf \
tests/test-altchains.conf \
tests/test-trustpeer.conf \
tests/test-dhprime.conf \
tests/test-p521.conf \
tests/test-ecc-cust-curves.conf \
tests/test-sm2.conf \
tests/NCONF_test.cnf \
tests/test-tls-downgrade.conf \
tests/TXT_DB.txt \
tests/utils.h \
tests/emnet/IP/IP.h \
tests/emnet/emnet_shim.c \
tests/emnet/emnet_nonblock_test.c \
tests/emnet/Makefile \
tests/freertos-mem-track-repro/user_settings.h \
tests/freertos-mem-track-repro/repro.c \
tests/freertos-mem-track-repro/FreeRTOS.h \
tests/freertos-mem-track-repro/semphr.h \
tests/freertos-mem-track-repro/task.h \
tests/freertos-mem-track-repro/run.sh
DISTCLEANFILES+= tests/.libs/unit.test