From 4c30a83cbb022fd23d414473ac2d878e1f5b5d24 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 14 Aug 2001 21:11:24 +0000 Subject: Proper support for tests spannint multiple .o files -Erik --- test/testsuite.h | 88 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) (limited to 'test/testsuite.h') diff --git a/test/testsuite.h b/test/testsuite.h index c80804b83..39d31d85b 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -24,15 +24,58 @@ #ifndef TESTSUITE_H #define TESTSUITE_H +#ifdef __NO_TESTCODE__ + +extern size_t test_number; + + +extern void init_testsuite(const char* testname); +extern void done_testing(void) __attribute__((noreturn)); +extern void success_msg(int result, const char* command); +extern void error_msg(int result, int line, const char* file, const char* command); + +#else + size_t test_number = 0; static int failures = 0; +void error_msg(int result, int line, const char* file, const char* command) +{ + failures++; + + printf("\nFAILED TEST %d: \n\t%s\n", test_number, command); + printf("AT LINE: %d, FILE: %s\n\n", line, file); +} + +void success_msg(int result, const char* command) +{ +#if 0 + printf("passed test: %s == 0\n", command); +#endif +} + +void done_testing(void) +{ + if (0 < failures) { + printf("Failed %d tests\n", failures); + exit(EXIT_FAILURE); + } else { + printf("All functions tested sucessfully\n"); + exit( EXIT_SUCCESS ); + } +} + +void init_testsuite(const char* testname) +{ + printf("%s", testname); + test_number = 0; + failures = 0; + atexit(done_testing); +} + +#endif -void init_testsuite(const char* testname); -void done_testing(void) __attribute__((noreturn)); -void success_msg(int result, const char* command); -void error_msg(int result, int line, const char* file, const char* command); #define TEST_STRING_OUTPUT( command, expected_result ) \ @@ -70,41 +113,4 @@ void error_msg(int result, int line, const char* file, const char* command); #define STR_CMD(cmd) cmd - - - -void error_msg(int result, int line, const char* file, const char* command) -{ - failures++; - - printf("\nFAILED TEST %d: \n\t%s\n", test_number, command); - printf("AT LINE: %d, FILE: %s\n\n", line, file); -} - -void success_msg(int result, const char* command) -{ -#if 0 - printf("passed test: %s == 0\n", command); -#endif -} - -void done_testing(void) -{ - if (0 < failures) { - printf("Failed %d tests\n", failures); - exit(EXIT_FAILURE); - } else { - printf("All functions tested sucessfully\n"); - exit( EXIT_SUCCESS ); - } -} - -void init_testsuite(const char* testname) -{ - printf("%s", testname); - test_number = 0; - failures = 0; - atexit(done_testing); -} - #endif /* TESTSUITE_H */ -- cgit v1.2.3