aboutsummaryrefslogtreecommitdiff
path: root/tests/suites/helpers.function
diff options
context:
space:
mode:
authorGilles Peskine <Gilles.Peskine@arm.com>2018-11-30 18:51:45 +0100
committerGilles Peskine <Gilles.Peskine@arm.com>2018-12-11 16:48:12 +0100
commit7f6e3a868af6c7aba1a16032017b15aca616eb3b (patch)
tree89f4c2fa0280456d417ace9d25bd810be896dc27 /tests/suites/helpers.function
parent69f976b1d6cf55801e5a268296131ffabef5219b (diff)
downloadmbedtls-7f6e3a868af6c7aba1a16032017b15aca616eb3b.zip
mbedtls-7f6e3a868af6c7aba1a16032017b15aca616eb3b.tar.gz
mbedtls-7f6e3a868af6c7aba1a16032017b15aca616eb3b.tar.bz2
Change ASSERT_ALLOC to take a size in elements, not bytes
`ASSERT_ALLOC(p, length)` now allocates `length` elements, i.e. `length * sizeof(*p)` bytes.
Diffstat (limited to 'tests/suites/helpers.function')
-rw-r--r--tests/suites/helpers.function25
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function
index f416b30..cbe3fa0 100644
--- a/tests/suites/helpers.function
+++ b/tests/suites/helpers.function
@@ -95,7 +95,7 @@ typedef struct data_tag
* You must set \p pointer to \c NULL before calling this macro and
* put `mbedtls_free( pointer )` in the test's cleanup code.
*
- * If \p size is zero, the resulting \p pointer will be \c NULL.
+ * If \p length is zero, the resulting \p pointer will be \c NULL.
* This is usually what we want in tests since API functions are
* supposed to accept null pointers when a buffer size is zero.
*
@@ -105,20 +105,21 @@ typedef struct data_tag
* \param pointer An lvalue where the address of the allocated buffer
* will be stored.
* This expression may be evaluated multiple times.
- * \param size Buffer size to allocate in bytes.
+ * \param length Number of elements to allocate.
* This expression may be evaluated multiple times.
*
*/
-#define ASSERT_ALLOC( pointer, size ) \
- do \
- { \
- TEST_ASSERT( ( pointer ) == NULL ); \
- if( ( size ) != 0 ) \
- { \
- ( pointer ) = mbedtls_calloc( 1, ( size ) ); \
- TEST_ASSERT( ( pointer ) != NULL ); \
- } \
- } \
+#define ASSERT_ALLOC( pointer, length ) \
+ do \
+ { \
+ TEST_ASSERT( ( pointer ) == NULL ); \
+ if( ( length ) != 0 ) \
+ { \
+ ( pointer ) = mbedtls_calloc( sizeof( *( pointer ) ), \
+ ( length ) ); \
+ TEST_ASSERT( ( pointer ) != NULL ); \
+ } \
+ } \
while( 0 )
/** Compare two buffers and fail the test case if they differ.