mirror of
https://github.com/openssl/openssl.git
synced 2026-05-07 20:12:39 +00:00
test/{handshake-,load_key_certs_crls_,x509_}memfail.c: count allocs properly
Memory allocation failure testing (and counting) is done both for malloc and realloc calls, so the sum of those ought to be reported. Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.foundation> Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org> MergeDate: Thu Apr 30 06:59:07 2026 (Merged from https://github.com/openssl/openssl/pull/30991)
This commit is contained in:
committed by
Nikola Pajkovsky
parent
b3dea427c4
commit
486404334c
@@ -29,10 +29,11 @@
|
||||
* - rcount: Number of reallocs counted
|
||||
* - fcount: Number of frees counted
|
||||
* - scount: Number of mallocs counted prior to workload
|
||||
* - srcount: Number of reallocs counted prior to workload
|
||||
*/
|
||||
static char *cert = NULL;
|
||||
static char *privkey = NULL;
|
||||
static int mcount, rcount, fcount, scount;
|
||||
static int mcount, rcount, fcount, scount, srcount;
|
||||
|
||||
/**
|
||||
* @brief Performs an SSL/TLS handshake between a test client and server.
|
||||
@@ -135,15 +136,16 @@ static int test_report_alloc_counts(void)
|
||||
CRYPTO_get_alloc_counts(&mcount, &rcount, &fcount);
|
||||
/*
|
||||
* Report our memory allocations from the count run
|
||||
* NOTE: We report a number of allocations to skip here
|
||||
* (the scount value). These are the allocations that took
|
||||
* place while the test harness itself was getting setup
|
||||
* (i.e. calling OPENSSL_init_crypto/etc). We can't fail
|
||||
* NOTE: We report a number of (re)allocations to skip here
|
||||
* (the scount + srcount value). These are the allocations
|
||||
* that took place while the test harness itself was getting
|
||||
* setup (i.e. calling OPENSSL_init_crypto/etc). We can't fail
|
||||
* those allocations as they will cause the test to fail before
|
||||
* we have even run the workload. So report them so we can
|
||||
* allow them to function before we start doing any real testing
|
||||
*/
|
||||
TEST_info("skip: %d count %d\n", scount, mcount - scount);
|
||||
TEST_info("skip: %d count %d\n",
|
||||
scount + srcount, mcount + rcount - scount - srcount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ int setup_tests(void)
|
||||
goto err;
|
||||
|
||||
if (strcmp(opmode, "count") == 0) {
|
||||
CRYPTO_get_alloc_counts(&scount, &rcount, &fcount);
|
||||
CRYPTO_get_alloc_counts(&scount, &srcount, &fcount);
|
||||
ADD_TEST(test_record_alloc_counts);
|
||||
ADD_TEST(test_report_alloc_counts);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
char *default_config_file = NULL;
|
||||
|
||||
static char *certfile = NULL;
|
||||
static int mcount, rcount, fcount, scount;
|
||||
static int mcount, rcount, fcount, scount, srcount;
|
||||
|
||||
static int do_load_key_certs_crls(int allow_failure)
|
||||
{
|
||||
@@ -60,7 +60,8 @@ static int test_alloc_failures(void)
|
||||
static int test_report_alloc_counts(void)
|
||||
{
|
||||
CRYPTO_get_alloc_counts(&mcount, &rcount, &fcount);
|
||||
TEST_info("skip: %d count %d\n", scount, mcount - scount);
|
||||
TEST_info("skip: %d count %d\n",
|
||||
scount + srcount, mcount + rcount - scount - srcount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ int setup_tests(void)
|
||||
goto err;
|
||||
|
||||
if (strcmp(opmode, "count") == 0) {
|
||||
CRYPTO_get_alloc_counts(&scount, &rcount, &fcount);
|
||||
CRYPTO_get_alloc_counts(&scount, &srcount, &fcount);
|
||||
ADD_TEST(test_record_alloc_counts);
|
||||
ADD_TEST(test_report_alloc_counts);
|
||||
} else {
|
||||
|
||||
+8
-7
@@ -21,7 +21,7 @@
|
||||
#include "testutil.h"
|
||||
|
||||
static char *certfile = NULL;
|
||||
static int mcount, rcount, fcount, scount;
|
||||
static int mcount, rcount, fcount, scount, srcount;
|
||||
|
||||
static int do_x509(int allow_failure)
|
||||
{
|
||||
@@ -91,15 +91,16 @@ static int test_report_alloc_counts(void)
|
||||
CRYPTO_get_alloc_counts(&mcount, &rcount, &fcount);
|
||||
/*
|
||||
* Report our memory allocations from the count run
|
||||
* NOTE: We report a number of allocations to skip here
|
||||
* (the scount value). These are the allocations that took
|
||||
* place while the test harness itself was getting setup
|
||||
* (i.e. calling OPENSSL_init_crypto/etc). We can't fail
|
||||
* NOTE: We report a number of (re)allocations to skip here
|
||||
* (the scount + srcount value). These are the allocations
|
||||
* that took place while the test harness itself was getting
|
||||
* setup (i.e. calling OPENSSL_init_crypto/etc). We can't fail
|
||||
* those allocations as they will cause the test to fail before
|
||||
* we have even run the workload. So report them so we can
|
||||
* allow them to function before we start doing any real testing
|
||||
*/
|
||||
TEST_info("skip: %d count %d\n", scount, mcount - scount);
|
||||
TEST_info("skip: %d count %d\n",
|
||||
scount + srcount, mcount + rcount - scount - srcount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ int setup_tests(void)
|
||||
goto err;
|
||||
|
||||
if (strcmp(opmode, "count") == 0) {
|
||||
CRYPTO_get_alloc_counts(&scount, &rcount, &fcount);
|
||||
CRYPTO_get_alloc_counts(&scount, &srcount, &fcount);
|
||||
ADD_TEST(test_record_alloc_counts);
|
||||
ADD_TEST(test_report_alloc_counts);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user