Commit 0ab000d3 authored by Davide Galassi's avatar Davide Galassi

Removed fprintf to stderr from unit tests

Avoid messy unsorted output in the CI output
parent a72b1a82
Pipeline #30410022 passed with stages
in 1 minute and 31 seconds
......@@ -239,18 +239,18 @@ static void dispatch(int argc, char *argv[])
else if (strcmp(test, "aes_gcm_decrypt") == 0)
aes_gcm_decrypt(argc, argv);
else
fprintf(stdout, "Test '%s' not defined\n", test);
printf("Test '%s' not defined\n", test);
}
void aes_test(void)
{
fprintf(stdout, "* AES NIST AESAVS KAT\n");
printf("* AES NIST AESAVS KAT\n");
func_test("aes_test.data", dispatch);
fprintf(stdout, "* AES GCM NIST Encrypt Validation (iv,txt,aad,mac)\n");
printf("* AES GCM NIST Encrypt Validation (iv,txt,aad,mac)\n");
func_test("aes_gcm_en_test.data", dispatch);
fprintf(stdout, "* AES GCM NIST Decrypt Validation (iv,txt,aad,mac)\n");
printf("* AES GCM NIST Decrypt Validation (iv,txt,aad,mac)\n");
func_test("aes_gcm_de_test.data", dispatch);
fprintf(stdout, "* AES-192 GCM NIST Encrypt Validation (iv,txt,aad,mac)\n");
printf("* AES-192 GCM NIST Encrypt Validation (iv,txt,aad,mac)\n");
func_test("aes_gcm_en_192_test.data", dispatch);
fprintf(stdout, "\n");
printf("\n");
}
......@@ -38,15 +38,15 @@ static void base64_dispatch(int argc, char *argv[])
else if (strcmp(test, "decode") == 0)
decode(argc, argv);
else
fprintf(stderr, "Test '%s' not defined\n", test);
printf("Test '%s' not defined\n", test);
}
void base64_test(void)
{
fprintf(stderr, "* Base-64\n");
printf("* Base-64\n");
func_test("base64_test.data", base64_dispatch);
fprintf(stdout, "\n");
printf("\n");
}
......@@ -135,9 +135,9 @@ void memxor_test(void)
{
int i;
fprintf(stdout, "* XOR\n");
printf("* XOR\n");
ASSERT(USED_MAX < BUFSIZ);
for (i = 0; i < NTESTS; i++)
run(tests[i].name, tests[i].func, setup, NULL);
fprintf(stdout, "\n");
printf("\n");
}
......@@ -189,7 +189,7 @@ static void mpi_dispatch(int argc, char *argv[])
else if (strcmp(test, "mpi_sub") == 0)
mpi_sub(argc, argv);
else
fprintf(stderr, "Test '%s' not defined\n", test);
printf("Test '%s' not defined\n", test);
mpi_teardown();
}
......@@ -198,7 +198,7 @@ static void mpi_dispatch(int argc, char *argv[])
void mpi_test(void)
{
fprintf(stderr, "* MPI\n");
printf("* MPI\n");
func_test("mpi_test.data", mpi_dispatch);
fprintf(stderr, "\n");
printf("\n");
}
......@@ -34,7 +34,7 @@ void func_test(const char *datafile, dispatch_func_t dispatch)
file = fopen(datafile, "r");
if (file == NULL) {
fprintf(stderr, "Error: data file \"%s\" not found\n", datafile);
printf("Error: data file \"%s\" not found\n", datafile);
return;
}
......@@ -46,7 +46,7 @@ void func_test(const char *datafile, dispatch_func_t dispatch)
continue;
left = sizeof(argbuf);
if (test_verb != 0)
fprintf(stdout, " %s\n", argbuf);
printf(" %s\n", argbuf);
/* Collect test function name and parameters */
cnt = strlen(argbuf) + 1;
curr = argbuf + cnt;
......@@ -65,7 +65,7 @@ void func_test(const char *datafile, dispatch_func_t dispatch)
dispatch(i, params);
test_runs++;
if (test_fails != fails)
fprintf(stderr, " %s\n", argbuf);
printf(" %s\n", argbuf);
}
fclose(file);
}
......@@ -84,7 +84,7 @@ void run(const char *name, void (* test)(void),
fails = test_fails;
test();
if (test_fails != fails)
fprintf(stderr, " %s\n", name);
printf(" %s\n", name);
if (teardown != NULL)
teardown();
}
......
......@@ -36,7 +36,7 @@ void run(const char *name, void (* test)(void),
#define ASSERT(test) do { \
if ((test) == 0) { \
test_fails++; \
TRACE(">>> ASSERTION FAIL (%s:%d): %s\n", \
printf("!!! ASSERTION FAIL (%s:%d): %s\n", \
__FILE__, __LINE__, #test); \
return; \
} \
......@@ -65,37 +65,21 @@ void run(const char *name, void (* test)(void),
ASSERT_EQ((e), 0)
#ifdef NDEBUG
#define TRACE(fmt, ...)
#define PRINT_HEX(msg, buf, siz)
#define PRINT_ASC(msg, buf, siz)
#define PRINT_MPI(msg, mpi, rad)
#else /* !NDEBUG */
# define TRACE(...) do { \
fprintf(stdout, __VA_ARGS__); \
fflush(stdout); \
} while(0)
# define PRINT_HEX(msg, buf, siz) do { \
size_t __siz = siz; \
unsigned char *__p = buf; \
if (msg) TRACE("%s: ", msg); \
while (__siz-- > 0) TRACE("%02x", *__p++); \
TRACE("\n"); \
if (msg) printf("%s: ", msg); \
while (__siz-- > 0) printf("%02x", *__p++); \
printf("\n"); \
} while(0)
# define PRINT_ASC(msg, buf, siz) \
TRACE("%s: %.*s\n", msg, (int)(siz), buf)
printf("%s: %.*s\n", msg, (int)(siz), buf)
# define PRINT_MPI(msg, mpi, rad) do { \
TRACE("%s:\t", msg); \
printf("%s:\t", msg); \
cry_mpi_print(mpi, rad); \
} while(0)
#endif /* NDEBUG */
#endif /* _TEST_H_ */
......@@ -3,7 +3,7 @@
void version_test(void)
{
fprintf(stdout, "* Version: %d.%d.%d\n", CRY_MAJOR, CRY_MINOR, CRY_PATCH);
printf("* Version: %d.%d.%d\n", CRY_MAJOR, CRY_MINOR, CRY_PATCH);
ASSERT(cry_version() == CRY_VERSION);
fprintf(stdout, "\n");
printf("\n");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment