mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-05-04 04:20:51 +02:00
Added new build option --enable-memtest or WOLFSSL_FORCE_MALLOC_FAIL_TEST which enables random malloc failures for testing. This test supresses the abort() calls to detect seg faults. A new script ./scripts/memtest.sh starts the test. If an issue is found it can be reviewed with the ./scripts/memtest.txt log and reproduced using the seed printed at top of unit test as --- RNG MALLOC FAIL AT 295--- and rerun using ./tests/unit.test 295.
This commit is contained in:
+8
-2
@@ -26,11 +26,17 @@
|
||||
#include <wolfssl/ssl.h>
|
||||
#include <wolfssl/test.h> /* thread and tcp stuff */
|
||||
|
||||
#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
|
||||
#define XABORT()
|
||||
#else
|
||||
#define XABORT() abort
|
||||
#endif
|
||||
|
||||
#define Fail(description, result) do { \
|
||||
printf("\nERROR - %s line %d failed with:", __FILE__, __LINE__); \
|
||||
printf("\n expected: "); printf description; \
|
||||
printf("\n result: "); printf result; printf("\n\n"); \
|
||||
abort(); \
|
||||
XABORT(); \
|
||||
} while(0)
|
||||
|
||||
#define Assert(test, description, result) if (!(test)) Fail(description, result)
|
||||
@@ -62,7 +68,7 @@
|
||||
#define AssertStr(x, y, op, er) do { \
|
||||
const char* _x = x; \
|
||||
const char* _y = y; \
|
||||
int _z = strcmp(_x, _y); \
|
||||
int _z = (_x && _y) ? strcmp(_x, _y) : -1; \
|
||||
\
|
||||
Assert(_z op 0, ("%s " #op " %s", #x, #y), \
|
||||
("\"%s\" " #er " \"%s\"", _x, _y));\
|
||||
|
||||
Reference in New Issue
Block a user