From 6c7e1785aac41a15ec1dee1acd551cfc9d4c2b09 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Fri, 9 Dec 2016 19:39:36 -0700 Subject: [PATCH] EXIT_TEST macro added for cleaner implementation and maintenance --- testsuite/testsuite.c | 13 +++---------- wolfcrypt/benchmark/benchmark.c | 6 +----- wolfcrypt/test/test.c | 13 +++---------- wolfssl/wolfcrypt/types.h | 5 +++++ 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index 220ada67e..3a2bc64ec 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -210,11 +210,7 @@ int testsuite_test(int argc, char** argv) #endif /* HAVE_WNR */ printf("\nAll tests passed!\n"); -#ifdef WOLFSSL_RIOT_OS - exit(0); -#else - return EXIT_SUCCESS; -#endif + EXIT_TEST(EXIT_SUCCESS); } void simple_test(func_args* args) @@ -415,11 +411,8 @@ int main(int argc, char** argv) if (server_args.return_code != 0) return server_args.return_code; printf("\nAll tests passed!\n"); -#ifdef WOLFSSL_RIOT_OS - exit(0); -#else - return EXIT_SUCCESS; -#endif + + EXIT_TEST(EXIT_SUCCESS); } diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index dcbfc8cf8..ee186aa27 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -483,11 +483,7 @@ int benchmark_test(void *args) ShowMemoryTracker(); #endif -#ifdef WOLFSSL_RIOT_OS - exit (0); -#else - return 0; -#endif + EXIT_TEST(0); } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 5ae622d02..b2656c1fb 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -262,11 +262,8 @@ static int err_sys(const char* msg, int es) { printf("%s error = %d\n", msg, es); -#ifdef WOLFSSL_RIOT_OS - exit(-1); -#else - return -1; /* error state */ -#endif + + EXIT_TEST(-1); } /* func_args from test.h, so don't have to pull in other junk */ @@ -733,11 +730,7 @@ int wolfcrypt_test(void* args) err_sys("Failed to free netRandom context", -1238); #endif /* HAVE_WNR */ -#ifdef WOLFSSL_RIOT_OS - exit(0); -#else - return args.return_code; -#endif + EXIT_TEST(args.return_code); } #endif /* NO_MAIN_DRIVER */ diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 8a2022808..5d04be8f6 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -407,6 +407,11 @@ #endif #endif /* WOLFSSL_AESNI or WOLFSSL_ARMASM */ + #ifdef WOLFSSL_RIOT_OS + #define EXIT_TEST(ret) exit(ret) + #else + #define EXIT_TEST(ret) return ret + #endif #ifdef __cplusplus } /* extern "C" */