Removal of the TEST_VALID_PARAM macro and its usages

Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
This commit is contained in:
TRodziewicz 2021-05-27 13:52:59 +02:00
parent 062f353804
commit 7019955c76
22 changed files with 1 additions and 165 deletions

View file

@ -177,29 +177,6 @@
} \ } \
} while( 0 ) } while( 0 )
/**
* \brief This macro tests the statement passed to it as a test step or
* individual test in a test case. The macro assumes the test will not fail.
*
* It assumes the library function under test cannot return a value and
* assumes errors can only be indicated by calls to
* MBEDTLS_PARAM_FAILED().
*
* This macro is intended to test that functions returning void
* accept all of the parameter values they're supposed to accept - eg
* that they don't call MBEDTLS_PARAM_FAILED() when a parameter
* that's allowed to be NULL happens to be NULL.
*
* Note: for functions that return something other that void,
* checking that they accept all the parameters they're supposed to
* accept is best done by using TEST_ASSERT() and checking the return
* value as well.
*
* \param TEST The test expression to be tested.
*/
#define TEST_VALID_PARAM( TEST ) \
TEST_ASSERT( ( TEST, 1 ) );
/** Allocate memory dynamically and fail the test case if this fails. /** Allocate memory dynamically and fail the test case if this fails.
* *
* You must set \p pointer to \c NULL before calling this macro and * You must set \p pointer to \c NULL before calling this macro and

View file

@ -413,12 +413,6 @@ void aes_misc_params( )
size_t size; size_t size;
#endif #endif
/* These calls accept NULL */
TEST_VALID_PARAM( mbedtls_aes_free( NULL ) );
#if defined(MBEDTLS_CIPHER_MODE_XTS)
TEST_VALID_PARAM( mbedtls_aes_xts_free( NULL ) );
#endif
#if defined(MBEDTLS_CIPHER_MODE_CBC) #if defined(MBEDTLS_CIPHER_MODE_CBC)
TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT, TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT,
15, 15,

View file

@ -1,6 +1,3 @@
ARIA - Valid parameters
aria_valid_param:
ARIA - Invalid parameters ARIA - Invalid parameters
aria_invalid_param: aria_invalid_param:

View file

@ -16,13 +16,6 @@
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE */
void aria_valid_param( )
{
TEST_VALID_PARAM( mbedtls_aria_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:NOT_DEFINED */ /* BEGIN_CASE depends_on:NOT_DEFINED */
void aria_invalid_param( ) void aria_invalid_param( )
{ {

View file

@ -1,6 +1,3 @@
BLOWFISH - Valid parameters
blowfish_valid_param:
BLOWFISH - Invalid parameters BLOWFISH - Invalid parameters
blowfish_invalid_param: blowfish_invalid_param:

View file

@ -7,13 +7,6 @@
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE */
void blowfish_valid_param( )
{
TEST_VALID_PARAM( mbedtls_blowfish_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:NOT_DEFINED */ /* BEGIN_CASE depends_on:NOT_DEFINED */
void blowfish_invalid_param( ) void blowfish_invalid_param( )
{ {

View file

@ -1,6 +1,3 @@
Camellia - Valid parameters
camellia_valid_param:
Camellia - Invalid parameters Camellia - Invalid parameters
camellia_invalid_param: camellia_invalid_param:

View file

@ -7,13 +7,6 @@
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE */
void camellia_valid_param( )
{
TEST_VALID_PARAM( mbedtls_camellia_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:NOT_DEFINED */ /* BEGIN_CASE depends_on:NOT_DEFINED */
void camellia_invalid_param( ) void camellia_invalid_param( )
{ {

View file

@ -1,9 +1,6 @@
CCM self test CCM self test
mbedtls_ccm_self_test: mbedtls_ccm_self_test:
CCM - Valid parameters
ccm_valid_param:
CCM init #1 AES-128: OK CCM init #1 AES-128: OK
depends_on:MBEDTLS_AES_C depends_on:MBEDTLS_AES_C
mbedtls_ccm_setkey:MBEDTLS_CIPHER_ID_AES:128:0 mbedtls_ccm_setkey:MBEDTLS_CIPHER_ID_AES:128:0

View file

@ -291,12 +291,3 @@ exit:
mbedtls_ccm_free( &ctx ); mbedtls_ccm_free( &ctx );
} }
/* END_CASE */ /* END_CASE */
/* BEGIN_CASE */
void ccm_valid_param( )
{
TEST_VALID_PARAM( mbedtls_ccm_free( NULL ) );
exit:
return;
}
/* END_CASE */

View file

@ -222,12 +222,6 @@ void cipher_invalid_param_conditional( )
(void)valid_mode; /* In some configurations this is unused */ (void)valid_mode; /* In some configurations this is unused */
/* mbedtls_cipher_init() */
TEST_VALID_PARAM( mbedtls_cipher_init( &valid_ctx ) );
/* mbedtls_cipher_setup() */
TEST_VALID_PARAM( mbedtls_cipher_setup( &valid_ctx, valid_info ) );
TEST_EQUAL( TEST_EQUAL(
MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA,
mbedtls_cipher_setkey( &valid_ctx, mbedtls_cipher_setkey( &valid_ctx,
@ -236,7 +230,7 @@ void cipher_invalid_param_conditional( )
invalid_operation ) ); invalid_operation ) );
exit: exit:
TEST_VALID_PARAM( mbedtls_cipher_free( &valid_ctx ) ); ;
} }
/* END_CASE */ /* END_CASE */

View file

@ -1,6 +1,3 @@
ECDH - Valid parameters
ecdh_valid_param:
ECDH - Invalid parameters ECDH - Invalid parameters
ecdh_invalid_param: ecdh_invalid_param:

View file

@ -43,13 +43,6 @@ exit:
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE */
void ecdh_valid_param( )
{
TEST_VALID_PARAM( mbedtls_ecdh_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:NOT_DEFINED */ /* BEGIN_CASE depends_on:NOT_DEFINED */
void ecdh_invalid_param( ) void ecdh_invalid_param( )
{ {

View file

@ -1,6 +1,3 @@
ECP valid params
ecp_valid_param:
ECP invalid params ECP invalid params
ecp_invalid_param: ecp_invalid_param:

View file

@ -22,22 +22,6 @@
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE */
void ecp_valid_param( )
{
TEST_VALID_PARAM( mbedtls_ecp_group_free( NULL ) );
TEST_VALID_PARAM( mbedtls_ecp_keypair_free( NULL ) );
TEST_VALID_PARAM( mbedtls_ecp_point_free( NULL ) );
#if defined(MBEDTLS_ECP_RESTARTABLE)
TEST_VALID_PARAM( mbedtls_ecp_restart_free( NULL ) );
#endif /* MBEDTLS_ECP_RESTARTABLE */
exit:
return;
}
/* END_CASE */
/* BEGIN_CASE depends_on:NOT_DEFINED */ /* BEGIN_CASE depends_on:NOT_DEFINED */
void ecp_invalid_param( ) void ecp_invalid_param( )
{ {

View file

@ -201,15 +201,6 @@ exit:
} }
/* END_CASE */ /* END_CASE */
/* BEGIN_CASE */
void gcm_valid_param( )
{
TEST_VALID_PARAM( mbedtls_gcm_free( NULL ) );
exit:
return;
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
void gcm_selftest( ) void gcm_selftest( )
{ {

View file

@ -1,5 +1,2 @@
GCM - Invalid parameters GCM - Invalid parameters
gcm_invalid_param: gcm_invalid_param:
GCM - Valid parameters
gcm_valid_param:

View file

@ -1,6 +1,3 @@
MPI - Valid parameters
mpi_valid_param:
Arguments with no value Arguments with no value
mpi_null: mpi_null:

View file

@ -71,13 +71,6 @@ static int f_rng_bytes_left( void *state, unsigned char *buf, size_t len )
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE */
void mpi_valid_param( )
{
TEST_VALID_PARAM( mbedtls_mpi_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE */ /* BEGIN_CASE */
void mpi_null( ) void mpi_null( )
{ {

View file

@ -211,12 +211,6 @@ void valid_parameters( )
mbedtls_pk_init( &pk ); mbedtls_pk_init( &pk );
TEST_VALID_PARAM( mbedtls_pk_free( NULL ) );
#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
TEST_VALID_PARAM( mbedtls_pk_restart_free( NULL ) );
#endif
TEST_ASSERT( mbedtls_pk_setup( &pk, NULL ) == TEST_ASSERT( mbedtls_pk_setup( &pk, NULL ) ==
MBEDTLS_ERR_PK_BAD_INPUT_DATA ); MBEDTLS_ERR_PK_BAD_INPUT_DATA );

View file

@ -1,6 +1,3 @@
SHA-1 - Valid parameters
sha1_valid_param:
# Test the operation of SHA-1 and SHA-2 # Test the operation of SHA-1 and SHA-2
SHA-1 Test Vector NIST CAVS #1 SHA-1 Test Vector NIST CAVS #1
depends_on:MBEDTLS_SHA1_C depends_on:MBEDTLS_SHA1_C
@ -42,9 +39,6 @@ SHA-1 Test Vector NIST CAVS #10
depends_on:MBEDTLS_SHA1_C depends_on:MBEDTLS_SHA1_C
mbedtls_sha1:"8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff":"11863b483809ef88413ca9b0084ac4a5390640af" mbedtls_sha1:"8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff":"11863b483809ef88413ca9b0084ac4a5390640af"
SHA-256 Valid parameters
sha256_valid_param:
SHA-256 Invalid parameters SHA-256 Invalid parameters
sha256_invalid_param: sha256_invalid_param:
@ -107,9 +101,6 @@ mbedtls_sha256:"8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e
SHA-512 Invalid parameters SHA-512 Invalid parameters
sha512_invalid_param: sha512_invalid_param:
SHA-512 Valid parameters
sha512_valid_param:
SHA-384 Test Vector NIST CAVS #1 SHA-384 Test Vector NIST CAVS #1
depends_on:MBEDTLS_SHA384_C depends_on:MBEDTLS_SHA384_C
sha384:"":"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" sha384:"":"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"

View file

@ -4,13 +4,6 @@
#include "mbedtls/sha512.h" #include "mbedtls/sha512.h"
/* END_HEADER */ /* END_HEADER */
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */
void sha1_valid_param( )
{
TEST_VALID_PARAM( mbedtls_sha1_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */ /* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */
void mbedtls_sha1( data_t * src_str, data_t * hash ) void mbedtls_sha1( data_t * src_str, data_t * hash )
{ {
@ -25,13 +18,6 @@ void mbedtls_sha1( data_t * src_str, data_t * hash )
} }
/* END_CASE */ /* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */
void sha256_valid_param( )
{
TEST_VALID_PARAM( mbedtls_sha256_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:NOT_DEFINED */ /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:NOT_DEFINED */
void sha256_invalid_param( ) void sha256_invalid_param( )
{ {
@ -81,13 +67,6 @@ void mbedtls_sha256( data_t * src_str, data_t * hash )
} }
/* END_CASE */ /* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */
void sha512_valid_param( )
{
TEST_VALID_PARAM( mbedtls_sha512_free( NULL ) );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:NOT_DEFINED */ /* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:NOT_DEFINED */
void sha512_invalid_param( ) void sha512_invalid_param( )
{ {