Refactored test suite template code

Restructed test suite helper and main code to support tests suite helper
functions, changed C++ comments to C-style, and made the generated
source code more navigable.
This commit is contained in:
SimonB 2016-02-17 23:34:30 +00:00 committed by Simon Butcher
parent 152ea18037
commit 0269dad5e5
3 changed files with 42 additions and 41 deletions

View file

@ -1,44 +1,6 @@
#include <string.h>
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#include <stdlib.h>
#define mbedtls_exit exit
#define mbedtls_free free
#define mbedtls_calloc calloc
#define mbedtls_fprintf fprintf
#define mbedtls_printf printf
#define mbedtls_snprintf snprintf
#endif
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
#include "mbedtls/memory_buffer_alloc.h"
#endif
static int test_errors = 0;
SUITE_PRE_DEP
#define TEST_SUITE_ACTIVE
static void test_fail( const char *test )
{
test_errors++;
if( test_errors == 1 )
mbedtls_printf( "FAILED\n" );
mbedtls_printf( " %s\n", test );
}
#define TEST_ASSERT( TEST ) \
do { \
if( ! (TEST) ) \
{ \
test_fail( #TEST ); \
goto exit; \
} \
} while( 0 )
int verify_string( char **str )
{
if( (*str)[0] != '"' ||
@ -190,7 +152,7 @@ int parse_arguments( char *buf, size_t len, char *params[50] )
p++;
}
// Replace newlines, question marks and colons in strings
/* Replace newlines, question marks and colons in strings */
for( i = 0; i < cnt; i++ )
{
p = params[i];