Commit 930906e98b for openssl.org
commit 930906e98bcac8524d13e7aa2ca5f7194166313b
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date: Mon Jun 1 23:27:55 2026 +0200
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 <norbertp@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
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 034d9881da..254a6a965f 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 35888423f8..6c16e4fe65 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 a3fdc59cc0..86eacd4008 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();