diff --git a/testprof/common.c b/testprof/common.c index 7912941..028768f 100644 --- a/testprof/common.c +++ b/testprof/common.c @@ -15,6 +15,18 @@ Steffen Jaeckel */ +void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm) +{ + if (res != CRYPT_OK) { + fprintf(stderr, "%s (%d)%s%s\n%s:%d:%s\n", + error_to_string(res), res, + (algorithm ? " - " : ""), (algorithm ? algorithm : ""), + file, line, cmd); + if (res != CRYPT_NOP) { + exit(EXIT_FAILURE); + } + } +} void print_hex(const char* what, const void* v, const unsigned long l) { diff --git a/testprof/common.h b/testprof/common.h index d4f21d6..7e67ee3 100644 --- a/testprof/common.h +++ b/testprof/common.h @@ -5,6 +5,16 @@ extern prng_state yarrow_prng; +#ifdef LTC_VERBOSE +#define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0) +#define DOX(x, str) do { fprintf(stderr, "%s - %s:\n", #x, (str)); run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0) +#else +#define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0) +#define DOX(x, str) do { run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0) +#endif + +void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm); + void print_hex(const char* what, const void* v, const unsigned long l); #ifndef compare_testvector int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which); diff --git a/testprof/test_driver.c b/testprof/test_driver.c deleted file mode 100644 index b728f91..0000000 --- a/testprof/test_driver.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm) -{ - if (res != CRYPT_OK) { - fprintf(stderr, "%s (%d)%s%s\n%s:%d:%s\n", - error_to_string(res), res, - (algorithm ? " - " : ""), (algorithm ? algorithm : ""), - file, line, cmd); - if (res != CRYPT_NOP) { - exit(EXIT_FAILURE); - } - } -} - -/* $Source$ */ -/* $Revision$ */ -/* $Date$ */ diff --git a/testprof/tomcrypt_test.h b/testprof/tomcrypt_test.h index 04fad82..6ad1408 100644 --- a/testprof/tomcrypt_test.h +++ b/testprof/tomcrypt_test.h @@ -30,16 +30,6 @@ typedef struct { int (*entry)(void); } test_entry; -void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm); - -#ifdef LTC_VERBOSE -#define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0) -#define DOX(x, str) do { fprintf(stderr, "%s - %s:\n", #x, (str)); run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0) -#else -#define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0) -#define DOX(x, str) do { run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0) -#endif - /* TESTS */ int cipher_hash_test(void); int modes_test(void);