merge testprof/test_driver.c to testprof/common.c

This commit is contained in:
Steffen Jaeckel 2017-05-24 21:06:40 +02:00
parent 0a23c6d32e
commit f7d3c2bfa1
4 changed files with 22 additions and 28 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -1,18 +0,0 @@
#include <tomcrypt_test.h>
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$ */

View File

@ -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);