Fix pkwrite test that were failing on mingw32

Apparently fread() writes some junk after the contents of the file. Don't look
at it.
This commit is contained in:
Manuel Pégourié-Gonnard 2015-08-18 19:49:40 +02:00
parent bd6d0aba25
commit 04b7eec539

View File

@ -25,16 +25,16 @@ void pk_write_pubkey_check( char *key_file )
mbedtls_pk_init( &key );
TEST_ASSERT( mbedtls_pk_parse_public_keyfile( &key, key_file ) == 0 );
ret = mbedtls_pk_write_pubkey_pem( &key, buf, sizeof( buf ) - 1);
TEST_ASSERT( ret >= 0 );
ret = mbedtls_pk_write_pubkey_pem( &key, buf, sizeof( buf ));
TEST_ASSERT( ret == 0 );
f = fopen( key_file, "r" );
TEST_ASSERT( f != NULL );
ilen = fread( check_buf, 1, sizeof( check_buf ) - 1, f );
ilen = fread( check_buf, 1, sizeof( check_buf ), f );
fclose( f );
TEST_ASSERT( ilen == strlen( (char *) buf ) );
TEST_ASSERT( strncmp( (char *) buf, (char *) check_buf, sizeof( buf ) ) == 0 );
TEST_ASSERT( memcmp( (char *) buf, (char *) check_buf, ilen ) == 0 );
exit:
mbedtls_pk_free( &key );
@ -57,16 +57,16 @@ void pk_write_key_check( char *key_file )
mbedtls_pk_init( &key );
TEST_ASSERT( mbedtls_pk_parse_keyfile( &key, key_file, NULL ) == 0 );
ret = mbedtls_pk_write_key_pem( &key, buf, sizeof( buf ) - 1);
ret = mbedtls_pk_write_key_pem( &key, buf, sizeof( buf ));
TEST_ASSERT( ret >= 0 );
f = fopen( key_file, "r" );
TEST_ASSERT( f != NULL );
ilen = fread( check_buf, 1, sizeof( check_buf ) - 1, f );
ilen = fread( check_buf, 1, sizeof( check_buf ), f );
fclose( f );
TEST_ASSERT( ilen == strlen( (char *) buf ) );
TEST_ASSERT( strncmp( (char *) buf, (char *) check_buf, sizeof( buf ) ) == 0 );
TEST_ASSERT( memcmp( (char *) buf, (char *) check_buf, ilen ) == 0 );
exit:
mbedtls_pk_free( &key );