Commit 318d0fe8 authored by Paul Bakker's avatar Paul Bakker
Browse files

Auto add 'exit' label in every test function. Failed assert now goes there

parent 4d0cfe80
...@@ -86,7 +86,7 @@ while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\// ...@@ -86,7 +86,7 @@ while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\//
{ {
die "Test function does not have 'void' as return type\n"; die "Test function does not have 'void' as return type\n";
} }
if ($function_decl !~ /^void (\w+)\(\s*(.*?)\s*\)\s*{(.*?)}/ms) if ($function_decl !~ /^void (\w+)\(\s*(.*?)\s*\)\s*{(.*)}/ms)
{ {
die "Function declaration not in expected format\n"; die "Function declaration not in expected format\n";
} }
...@@ -104,6 +104,12 @@ while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\// ...@@ -104,6 +104,12 @@ while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\//
$function_decl =~ s/^void /void test_suite_/; $function_decl =~ s/^void /void test_suite_/;
# Add exit label if not present
if ($function_decl !~ /^exit:$/m)
{
$function_decl =~ s/}\s*$/\nexit:\n return;\n}/;
}
if ($function_deps =~ /^depends_on:/) if ($function_deps =~ /^depends_on:/)
{ {
( $function_deps ) = $function_deps =~ /^depends_on:(.*)$/; ( $function_deps ) = $function_deps =~ /^depends_on:(.*)$/;
......
...@@ -29,7 +29,7 @@ static int test_assert( int correct, const char *test ) ...@@ -29,7 +29,7 @@ static int test_assert( int correct, const char *test )
#define TEST_ASSERT( TEST ) \ #define TEST_ASSERT( TEST ) \
do { test_assert( (TEST) ? 1 : 0, #TEST ); \ do { test_assert( (TEST) ? 1 : 0, #TEST ); \
if( test_errors) return; \ if( test_errors) goto exit; \
} while (0) } while (0)
int verify_string( char **str ) int verify_string( char **str )
......
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