mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
For tests, rename ASSERT_ALLOC_WEAK() to TEST_CALLOC_OR_SKIP()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
@ -161,18 +161,18 @@
|
||||
* This macro behaves like #TEST_CALLOC_OR_FAIL, except that if the allocation
|
||||
* fails, it marks the test as skipped rather than failed.
|
||||
*/
|
||||
#define ASSERT_ALLOC_WEAK(pointer, length) \
|
||||
do \
|
||||
{ \
|
||||
#define TEST_CALLOC_OR_SKIP(pointer, length) \
|
||||
do { \
|
||||
TEST_ASSERT((pointer) == NULL); \
|
||||
if ((length) != 0) \
|
||||
{ \
|
||||
if ((length) != 0) { \
|
||||
(pointer) = mbedtls_calloc(sizeof(*(pointer)), \
|
||||
(length)); \
|
||||
TEST_ASSUME((pointer) != NULL); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
} while (0)
|
||||
|
||||
/* For backwards compatibility */
|
||||
#define ASSERT_ALLOC_WEAK(pointer, length) TEST_CALLOC_OR_SKIP(pointer, length)
|
||||
|
||||
/** Compare two buffers and fail the test case if they differ.
|
||||
*
|
||||
|
@ -139,7 +139,7 @@ int get_len_step(const data_t *input, size_t buffer_size,
|
||||
end = buf + 1;
|
||||
p = end;
|
||||
} else {
|
||||
ASSERT_ALLOC_WEAK(buf, buffer_size);
|
||||
TEST_CALLOC_OR_SKIP(buf, buffer_size);
|
||||
if (buffer_size > input->len) {
|
||||
memcpy(buf, input->x, input->len);
|
||||
memset(buf + input->len, 'A', buffer_size - input->len);
|
||||
|
@ -48,7 +48,7 @@ void ccm_lengths(int msg_len, int iv_len, int add_len, int tag_len, int res)
|
||||
|
||||
mbedtls_ccm_init(&ctx);
|
||||
|
||||
ASSERT_ALLOC_WEAK(add, add_len);
|
||||
TEST_CALLOC_OR_SKIP(add, add_len);
|
||||
memset(key, 0, sizeof(key));
|
||||
memset(msg, 0, sizeof(msg));
|
||||
memset(iv, 0, sizeof(iv));
|
||||
|
@ -471,7 +471,7 @@ void import_large_key(int type_arg, int byte_size_arg,
|
||||
|
||||
/* Skip the test case if the target running the test cannot
|
||||
* accommodate large keys due to heap size constraints */
|
||||
ASSERT_ALLOC_WEAK(buffer, buffer_size);
|
||||
TEST_CALLOC_OR_SKIP(buffer, buffer_size);
|
||||
memset(buffer, 'K', byte_size);
|
||||
|
||||
PSA_ASSERT(psa_crypto_init());
|
||||
|
Reference in New Issue
Block a user