Fix X.509 CRT parsing test if MBEDTLS_X509_REMOVE_INFO is set
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index 82f7da5..54a39ff 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -830,6 +830,8 @@
#if !defined(MBEDTLS_X509_REMOVE_INFO)
unsigned char output[2000];
int res;
+#else
+ ((void) result_str);
#endif
mbedtls_x509_crt_init( &crt );
@@ -844,15 +846,11 @@
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
}
-#else
- ((void) result_str);
+ memset( output, 0, 2000 );
#endif
mbedtls_x509_crt_free( &crt );
mbedtls_x509_crt_init( &crt );
-#if !defined(MBEDTLS_X509_REMOVE_INFO)
- memset( output, 0, 2000 );
-#endif
TEST_ASSERT( mbedtls_x509_crt_parse_der_nocopy( &crt, buf->x, buf->len ) == ( result ) );
#if !defined(MBEDTLS_X509_REMOVE_INFO)
@@ -867,15 +865,14 @@
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
}
-#else
- ((void)result_str);
-#endif
+ memset( output, 0, 2000 );
+#endif /* !MBEDTLS_X509_REMOVE_INFO */
mbedtls_x509_crt_free( &crt );
mbedtls_x509_crt_init( &crt );
- memset( output, 0, 2000 );
TEST_ASSERT( mbedtls_x509_crt_parse_der_with_ext_cb( &crt, buf->x, buf->len, 0, NULL, NULL ) == ( result ) );
+#if !defined(MBEDTLS_X509_REMOVE_INFO)
if( ( result ) == 0 )
{
res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
@@ -885,12 +882,14 @@
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
}
+ memset( output, 0, 2000 );
+#endif /* !MBEDTLS_X509_REMOVE_INFO */
mbedtls_x509_crt_free( &crt );
mbedtls_x509_crt_init( &crt );
- memset( output, 0, 2000 );
TEST_ASSERT( mbedtls_x509_crt_parse_der_with_ext_cb( &crt, buf->x, buf->len, 1, NULL, NULL ) == ( result ) );
+#if !defined(MBEDTLS_X509_REMOVE_INFO)
if( ( result ) == 0 )
{
res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
@@ -900,6 +899,7 @@
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
}
+#endif /* !MBEDTLS_X509_REMOVE_INFO */
exit:
mbedtls_x509_crt_free( &crt );