From: Jakub Zelenka Date: Mon, 1 Jun 2026 21:27:55 +0000 (+0200) Subject: mfail: do not count allocations for no file when checked X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=930906e98bcac8524d13e7aa2ca5f7194166313b;p=thirdparty%2Fopenssl.git mfail: do not count allocations for no file when checked This skips some debug and error allocations that cannot be handled Reviewed-by: Norbert Pocs Reviewed-by: Tomas Mraz MergeDate: Thu Jun 11 16:00:14 2026 (Merged from https://github.com/openssl/openssl/pull/31356) --- diff --git a/test/mfail/mfail.c b/test/mfail/mfail.c index 034d9881dac..254a6a965f4 100644 --- a/test/mfail/mfail.c +++ b/test/mfail/mfail.c @@ -54,6 +54,7 @@ static struct { int triggered; int counting; int slow_skipped; + int no_check; } mf; static int env_is_true(const char *name) @@ -92,12 +93,15 @@ static void mfail_print_bt(void) #endif } -static int should_fail(void) +static int should_fail(const char *file) { int idx; if (!mf.counting) return 0; + /* skip if checking errors and file is not set (debug and error parts) */ + if (!mf.no_check && file == NULL) + return 0; idx = mf.alloc_count++; @@ -116,7 +120,7 @@ static void *mf_malloc(size_t num, const char *file, int line) { if (num == 0) return NULL; - if (should_fail()) + if (should_fail(file)) return NULL; return malloc(num); } @@ -129,7 +133,7 @@ static void *mf_realloc(void *addr, size_t num, const char *file, int line) free(addr); return NULL; } - if (should_fail()) + if (should_fail(file)) return NULL; return realloc(addr, num); } @@ -216,6 +220,7 @@ void mfail_init(int seq, int flags) mf.triggered = 0; mf.counting = 0; mf.slow_skipped = 0; + mf.no_check = flags & MFAIL_FLAG_NO_CHECK; if (mf.single_point >= 0) { mf.mode = MFAIL_MODE_SINGLE; diff --git a/test/mfail/mfail.h b/test/mfail/mfail.h index 35888423f8c..6c16e4fe656 100644 --- a/test/mfail/mfail.h +++ b/test/mfail/mfail.h @@ -12,6 +12,7 @@ /* Flags for mfail_init(). */ #define MFAIL_FLAG_COUNT (1 << 0) +#define MFAIL_FLAG_NO_CHECK (1 << 1) /* Modes */ #define MFAIL_MODE_EXHAUSTIVE 0 diff --git a/test/testutil/driver.c b/test/testutil/driver.c index a3fdc59cc08..86eacd40087 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -330,7 +330,7 @@ static int mfail_run_test(const TEST_INFO *t, int idx) test_flush_stdout(); test_flush_tapout(); - mfail_init(0, 0); + mfail_init(0, no_check ? MFAIL_FLAG_NO_CHECK : 0); while (mfail_has_next()) { int phase = mfail_get_phase();