Prefer ASSERT_ALLOC to calloc+TEST_ASSERT in PSA tests
To allocate memory dynamically in a test, call ASSERT_ALLOC which
takes care of calling calloc and of checking for NULL.
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index c194a07..f8c9c74 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -407,7 +407,6 @@
public_key_type = PSA_KEY_TYPE_PUBLIC_KEY_OF_KEYPAIR( private_key_type );
public_key_length = PSA_KEY_EXPORT_MAX_SIZE( public_key_type, key_bits );
ASSERT_ALLOC( public_key, public_key_length );
- TEST_ASSERT( public_key != NULL );
PSA_ASSERT( psa_export_public_key( handle,
public_key, public_key_length,
&public_key_length ) );
diff --git a/tests/suites/test_suite_psa_crypto_storage_file.function b/tests/suites/test_suite_psa_crypto_storage_file.function
index bf86ebb..e596be1 100644
--- a/tests/suites/test_suite_psa_crypto_storage_file.function
+++ b/tests/suites/test_suite_psa_crypto_storage_file.function
@@ -36,8 +36,7 @@
}
/* Read from the file with psa_crypto_storage_load. */
- loaded_data = mbedtls_calloc( 1, capacity );
- TEST_ASSERT( loaded_data != NULL );
+ ASSERT_ALLOC( loaded_data, capacity );
status = psa_crypto_storage_load( id_to_load, loaded_data, file_size );
/* Check we get the expected status. */
@@ -82,8 +81,7 @@
TEST_EQUAL( file_size, data->len );
/* Check that the file contents are what we expect */
- loaded_data = mbedtls_calloc( 1, data->len );
- TEST_ASSERT( loaded_data != NULL );
+ ASSERT_ALLOC( loaded_data, data->len );
num_read = fread( loaded_data, 1, file_size, file );
TEST_EQUAL( num_read, file_size );