New test helper macro ASSERT_ALLOC_WEAK
The new macro ASSERT_ALLOC_WEAK does not fail the test case if the
memory allocation fails. This is useful for tests that allocate a
large amount of memory, but that aren't useful on platforms where
allocating such a large amount is not possible.
Ideally this macro should mark the test as skipped. We don't yet have
a facility for that but we're working on it. Once we have a skip
functionality, this macro should be changed to use it.
diff --git a/tests/suites/test_suite_asn1parse.function b/tests/suites/test_suite_asn1parse.function
index 9e9f509..f5ecd55 100644
--- a/tests/suites/test_suite_asn1parse.function
+++ b/tests/suites/test_suite_asn1parse.function
@@ -130,7 +130,7 @@
}
else
{
- ASSERT_ALLOC( buf, buffer_size );
+ ASSERT_ALLOC_WEAK( buf, buffer_size );
if( buffer_size > input->len )
{
memcpy( buf, input->x, input->len );
@@ -159,12 +159,6 @@
return( 1 );
exit:
- /* It may be impossible to allocate large lengths on embedded platforms.
- * Pass in this case (though it would be better to mark the test
- * as skipped). */
- if( buf == NULL )
- return( 1 );
-
mbedtls_free( buf );
return( 0 );
}