mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-17 02:43:26 +00: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:
parent
f9ffd11e7a
commit
412a813ad4
@ -138,21 +138,21 @@
|
||||
|
||||
/** Allocate memory dynamically. If the allocation fails, skip the test case.
|
||||
*
|
||||
* This macro behaves like #ASSERT_ALLOC, except that if the allocation
|
||||
* 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 \
|
||||
{ \
|
||||
TEST_ASSERT((pointer) == NULL); \
|
||||
if ((length) != 0) \
|
||||
{ \
|
||||
(pointer) = mbedtls_calloc(sizeof(*(pointer)), \
|
||||
#define TEST_CALLOC_OR_SKIP(pointer, length) \
|
||||
do { \
|
||||
TEST_ASSERT((pointer) == NULL); \
|
||||
if ((length) != 0) { \
|
||||
(pointer) = mbedtls_calloc(sizeof(*(pointer)), \
|
||||
(length)); \
|
||||
TEST_ASSUME((pointer) != NULL); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
TEST_ASSUME((pointer) != NULL); \
|
||||
} \
|
||||
} 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);
|
||||
|
@ -107,7 +107,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));
|
||||
|
@ -1410,7 +1410,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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user