1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

Make test suites compatible with #include <assert.h>

Don't use the macro name assert. It's technically permitted as long as
<assert.h> is not included, but it's fragile, because it means the
code and any header that it includes must not include <assert.h>.
This commit is contained in:
Gilles Peskine
2019-06-07 14:52:07 +02:00
parent 5d26e7cbfe
commit e7655df7be
3 changed files with 13 additions and 13 deletions

View File

@ -13,11 +13,11 @@
*/
#define INCR_ASSERT(p, start, len, step) do \
{ \
assert( ( p ) >= ( start ) ); \
assert( sizeof( *( p ) ) == sizeof( *( start ) ) ); \
TEST_HELPER_ASSERT( ( p ) >= ( start ) ); \
TEST_HELPER_ASSERT( sizeof( *( p ) ) == sizeof( *( start ) ) ); \
/* <= is checked to support use inside a loop where \
pointer is incremented after reading data. */ \
assert( (uint32_t)( ( ( p ) - ( start ) ) + ( step ) ) <= ( len ) );\
TEST_HELPER_ASSERT( (uint32_t)( ( ( p ) - ( start ) ) + ( step ) ) <= ( len ) );\
( p ) += ( step ); \
} \
while( 0 )
@ -127,7 +127,7 @@ uint8_t * receive_data( uint32_t * data_len )
/* Read data length */
*data_len = receive_uint32();
data = (uint8_t *)malloc( *data_len );
assert( data != NULL );
TEST_HELPER_ASSERT( data != NULL );
greentea_getc(); // read ';' received after key i.e. *data_len
@ -221,7 +221,7 @@ void ** parse_parameters( uint8_t count, uint8_t * data, uint32_t data_len,
hex_count = find_hex_count(count, data, data_len);
params = (void **)malloc( sizeof( void *) * ( count + hex_count ) );
assert( params != NULL );
TEST_HELPER_ASSERT( params != NULL );
cur = params;
p = data;
@ -360,7 +360,7 @@ int execute_tests( int args, const char ** argv )
{
/* Read dependency count */
count = *p;
assert( count < data_len );
TEST_HELPER_ASSERT( count < data_len );
INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) );
ret = verify_dependencies( count, p );
if ( ret != DEPENDENCY_SUPPORTED )