Adapted .function files and .data files to new test framework
Changes include:
- Integers marked with '#' in the .function files.
- Strings should have "" in .data files.
- String comparison instead of preprocessor-like replace for e.g. '=='
- Params and variables cannot have the same name in .function files
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index b6383d7..f0defa3 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -74,30 +74,44 @@
END_CASE
BEGIN_CASE
-x509_verify:crt_file:ca_file:crl_file:cn_name:result:flags:verify_callback
+x509_verify:crt_file:ca_file:crl_file:cn_name_str:#result:#flags_result:verify_callback
{
x509_cert crt;
x509_cert ca;
x509_crl crl;
int flags = 0;
int res;
+ int (*f_vrfy)(void *, x509_cert *, int, int *) = NULL;
+ char * cn_name = NULL;
memset( &crt, 0, sizeof( x509_cert ) );
memset( &ca, 0, sizeof( x509_cert ) );
memset( &crl, 0, sizeof( x509_crl ) );
+ if( strcmp( {cn_name_str}, "NULL" ) != 0 )
+ cn_name = {cn_name_str};
+
+ if( strcmp( {verify_callback}, "NULL" ) == 0 )
+ f_vrfy = NULL;
+ else if( strcmp( {verify_callback}, "verify_none" ) == 0 )
+ f_vrfy = verify_none;
+ else if( strcmp( {verify_callback}, "verify_all" ) == 0 )
+ f_vrfy = verify_all;
+ else
+ TEST_ASSERT( "No known verify callback selected" == 0 );
+
TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 );
TEST_ASSERT( x509parse_crtfile( &ca, {ca_file} ) == 0 );
TEST_ASSERT( x509parse_crlfile( &crl, {crl_file} ) == 0 );
- res = x509parse_verify( &crt, &ca, &crl, {cn_name}, &flags, {verify_callback}, NULL );
+ res = x509parse_verify( &crt, &ca, &crl, cn_name, &flags, f_vrfy, NULL );
x509_free( &crt );
x509_free( &ca );
x509_crl_free( &crl );
TEST_ASSERT( res == ( {result} ) );
- TEST_ASSERT( flags == ( {flags} ) );
+ TEST_ASSERT( flags == ( {flags_result} ) );
}
END_CASE
@@ -106,13 +120,18 @@
{
x509_cert crt;
char buf[2000];
- int res;
+ int res = 0;
memset( &crt, 0, sizeof( x509_cert ) );
memset( buf, 0, 2000 );
TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 );
- res = x509parse_dn_gets( buf, 2000, &crt.{entity} );
+ if( strcmp( {entity}, "subject" ) == 0 )
+ res = x509parse_dn_gets( buf, 2000, &crt.subject );
+ else if( strcmp( {entity}, "issuer" ) == 0 )
+ res = x509parse_dn_gets( buf, 2000, &crt.issuer );
+ else
+ TEST_ASSERT( "Unknown entity" == 0 );
x509_free( &crt );
@@ -124,28 +143,38 @@
END_CASE
BEGIN_CASE
-x509_time_expired:crt_file:entity:result
+x509_time_expired:crt_file:entity:#result
{
x509_cert crt;
memset( &crt, 0, sizeof( x509_cert ) );
TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 );
- TEST_ASSERT( x509parse_time_expired( &crt.{entity} ) == {result} );
+
+ if( strcmp( {entity}, "valid_from" ) == 0 )
+ TEST_ASSERT( x509parse_time_expired( &crt.valid_from ) == {result} );
+ else if( strcmp( {entity}, "valid_to" ) == 0 )
+ TEST_ASSERT( x509parse_time_expired( &crt.valid_to ) == {result} );
+ else
+ TEST_ASSERT( "Unknown entity" == 0 );
x509_free( &crt );
}
END_CASE
BEGIN_CASE
-x509parse_keyfile_rsa:key_file:password:result
+x509parse_keyfile_rsa:key_file:password:#result
{
rsa_context rsa;
int res;
+ char *pwd = {password};
memset( &rsa, 0, sizeof( rsa_context ) );
- res = x509parse_keyfile_rsa( &rsa, {key_file}, {password} );
+ if( strcmp( pwd, "NULL" ) == 0 )
+ pwd = NULL;
+
+ res = x509parse_keyfile_rsa( &rsa, {key_file}, pwd );
TEST_ASSERT( res == {result} );
@@ -159,7 +188,7 @@
END_CASE
BEGIN_CASE
-x509parse_public_keyfile_rsa:key_file:result
+x509parse_public_keyfile_rsa:key_file:#result
{
rsa_context rsa;
int res;
@@ -180,7 +209,7 @@
END_CASE
BEGIN_CASE
-x509parse_public_keyfile_ec:key_file:result
+x509parse_public_keyfile_ec:key_file:#result
{
pk_context ctx;
int res;
@@ -204,7 +233,7 @@
END_CASE
BEGIN_CASE
-x509parse_keyfile_ec:key_file:password:result
+x509parse_keyfile_ec:key_file:password:#result
{
pk_context ctx;
int res;
@@ -228,7 +257,7 @@
END_CASE
BEGIN_CASE
-x509parse_crt:crt_data:result_str:result
+x509parse_crt:crt_data:result_str:#result
{
x509_cert crt;
unsigned char buf[2000];
@@ -257,7 +286,7 @@
END_CASE
BEGIN_CASE
-x509parse_crl:crl_data:result_str:result
+x509parse_crl:crl_data:result_str:#result
{
x509_crl crl;
unsigned char buf[2000];
@@ -286,12 +315,13 @@
END_CASE
BEGIN_CASE
-x509parse_key_rsa:key_data:result_str:result
+x509parse_key_rsa:key_data:result_str:#result
{
rsa_context rsa;
unsigned char buf[2000];
unsigned char output[2000];
int data_len;
+ ((void) result_str);
memset( &rsa, 0, sizeof( rsa_context ) );
memset( buf, 0, 2000 );