Commit 94b916c7 authored by Paul Bakker's avatar Paul Bakker
Browse files

Split assignment and assert check into seperate lines in tests

parent dd0aae92
......@@ -39,7 +39,8 @@ void base64_decode( char *src_string, char *dst_string, int result )
memset(dst_str, 0x00, 1000);
strncpy( (char *) src_str, src_string, sizeof(src_str) - 1 );
TEST_ASSERT( res = base64_decode( dst_str, &len, src_str, strlen( (char *) src_str ) ) == result );
res = base64_decode( dst_str, &len, src_str, strlen( (char *) src_str ) );
TEST_ASSERT( res == result );
if( result == 0 )
{
TEST_ASSERT( strcmp( (char *) dst_str, dst_string ) == 0 );
......
......@@ -113,7 +113,8 @@ void ecdsa_det_test_vectors( int id, char *d_str, int md_alg,
TEST_ASSERT( mpi_read_string( &r_check, 16, r_str ) == 0 );
TEST_ASSERT( mpi_read_string( &s_check, 16, s_str ) == 0 );
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
hlen = md_info->size;
md( md_info, (const unsigned char *) msg, strlen( msg ), hash );
......
......@@ -14,9 +14,12 @@ void ecp_curve_info( int id, int tls_id, int size, char *name )
{
const ecp_curve_info *by_id, *by_tls, *by_name;
TEST_ASSERT( ( by_id = ecp_curve_info_from_grp_id( id ) ) != NULL );
TEST_ASSERT( ( by_tls = ecp_curve_info_from_tls_id( tls_id ) ) != NULL );
TEST_ASSERT( ( by_name = ecp_curve_info_from_name( name ) ) != NULL );
by_id = ecp_curve_info_from_grp_id( id );
by_tls = ecp_curve_info_from_tls_id( tls_id );
by_name = ecp_curve_info_from_name( name );
TEST_ASSERT( by_id != NULL );
TEST_ASSERT( by_tls != NULL );
TEST_ASSERT( by_name != NULL );
TEST_ASSERT( by_id == by_tls );
TEST_ASSERT( by_id == by_name );
......@@ -547,7 +550,8 @@ void ecp_tls_write_read_group( int id )
TEST_ASSERT( ecp_use_known_dp( &grp1, id ) == 0 );
TEST_ASSERT( ecp_tls_write_group( &grp1, &len, buf, 10 ) == 0 );
TEST_ASSERT( ( ret = ecp_tls_read_group( &grp2, &vbuf, len ) ) == 0 );
ret = ecp_tls_read_group( &grp2, &vbuf, len );
TEST_ASSERT( ret == 0 );
if( ret == 0 )
{
......
......@@ -44,7 +44,8 @@ void hmac_drbg_entropy_usage( int md_alg )
entropy.len = sizeof( buf );
entropy.p = buf;
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
/* Init must use entropy */
last_len = entropy.len;
......@@ -110,7 +111,9 @@ void hmac_drbg_seed_file( int md_alg, char *path, int ret )
const md_info_t *md_info;
hmac_drbg_context ctx;
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
TEST_ASSERT( hmac_drbg_init( &ctx, md_info, rnd_std_rand, NULL,
NULL, 0 ) == 0 );
......@@ -133,7 +136,8 @@ void hmac_drbg_buf( int md_alg )
memset( buf, 0, sizeof( buf ) );
memset( out, 0, sizeof( out ) );
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
TEST_ASSERT( hmac_drbg_init_buf( &ctx, md_info, buf, sizeof( buf ) ) == 0 );
/* Make sure it never tries to reseed (would segfault otherwise) */
......@@ -174,7 +178,8 @@ void hmac_drbg_no_reseed( int md_alg,
p_entropy.len = unhexify( entropy, entropy_hex );
p_entropy.p = entropy;
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
/* Test the simplified buffer-based variant */
memcpy( data, entropy, p_entropy.len );
......@@ -231,7 +236,9 @@ void hmac_drbg_nopr( int md_alg,
p_entropy.len = unhexify( entropy, entropy_hex );
p_entropy.p = entropy;
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
TEST_ASSERT( hmac_drbg_init( &ctx, md_info, entropy_func, &p_entropy,
custom, custom_len ) == 0 );
TEST_ASSERT( hmac_drbg_reseed( &ctx, add1, add1_len ) == 0 );
......@@ -272,7 +279,9 @@ void hmac_drbg_pr( int md_alg,
p_entropy.len = unhexify( entropy, entropy_hex );
p_entropy.p = entropy;
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
md_info = md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
TEST_ASSERT( hmac_drbg_init( &ctx, md_info, entropy_func, &p_entropy,
custom, custom_len ) == 0 );
hmac_drbg_set_prediction_resistance( &ctx, POLARSSL_HMAC_DRBG_PR_ON );
......
......@@ -27,7 +27,8 @@ void md_process( )
*/
for( md_type_ptr = md_list(); *md_type_ptr != 0; md_type_ptr++ )
{
TEST_ASSERT( ( info = md_info_from_type( *md_type_ptr ) ) != NULL );
info = md_info_from_type( *md_type_ptr );
TEST_ASSERT( info != NULL );
TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 );
TEST_ASSERT( md_process( &ctx, buf ) == 0 );
TEST_ASSERT( md_free_ctx( &ctx ) == 0 );
......@@ -42,7 +43,8 @@ void md_info( int md_type, char *md_name, int md_size )
const int *md_type_ptr;
int found;
TEST_ASSERT( ( md_info = md_info_from_type( md_type ) ) != NULL );
md_info = md_info_from_type( md_type );
TEST_ASSERT( md_info != NULL );
TEST_ASSERT( md_info == md_info_from_string( md_name ) );
TEST_ASSERT( md_get_type( md_info ) == (md_type_t) md_type );
......
......@@ -117,8 +117,8 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
f = fopen( cert_check_file, "r" );
TEST_ASSERT( f != NULL );
TEST_ASSERT( ( olen = fread( check_buf, 1, sizeof(check_buf), f ) ) <
sizeof(check_buf) );
olen = fread( check_buf, 1, sizeof(check_buf), f );
TEST_ASSERT( olen < sizeof(check_buf) );
fclose( f );
TEST_ASSERT( olen >= pem_len - 1 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment