commit 23ed93cfd97ea7f5131805f90e9e7d34bfcaff66 parent a3248db69b143ccbbe92560ff1409487cf8ac7cf Author: Kévin Le Gouguec <kevin.legouguec@airbus.com> Date: Wed, 28 Nov 2018 15:54:40 +0100 Mutualisation de l'entête d'utilitaires de tests Diffstat:
19 files changed, 48 insertions(+), 147 deletions(-)
diff --git a/crypto_aead/lilliputaei128v1/ref/test/helpers.h b/crypto_aead/lilliputaei128v1/ref/test/helpers.h @@ -1,33 +0,0 @@ -#ifndef HELPERS_H -#define HELPERS_H - -#include <stdint.h> -#include <stdio.h> - -#include "parameters.h" - - -#define ARRAY_NB(A) (sizeof(A)/sizeof(A[0])) -#define ARRAY_END(A) (A+ARRAY_NB(A)) - -#define REPORT_DIFFERENCE(VECTOR, ELEMENT) do { \ - fprintf(stderr, "%s: vector %s: %s differs from expected\n", \ - __FILE__, (VECTOR), (ELEMENT)); \ - } while (0) - -#define REPORT_INVALID(VECTOR) do { \ - fprintf(stderr, "%s: vector %s: ciphertext/tag invalid\n", \ - __FILE__, (VECTOR)); \ - } while (0) - - -static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) -{ - size_t filename_len = snprintf(NULL, 0, "%s/%s_%s.txt", folder, vector, name); - char filename[filename_len+1]; - snprintf(filename, sizeof(filename), "%s/%s_%s.txt", folder, vector, name); - return fopen(filename, "w"); -} - - -#endif /* HELPERS_H */ diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-ae-decrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-ae-decrypt.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-ae-encrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-ae-encrypt.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-ae-roundtrip.c b/crypto_aead/lilliputaei128v1/ref/test/test-ae-roundtrip.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-decrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-tbc-decrypt.c @@ -4,7 +4,7 @@ #include "cipher.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c b/crypto_aead/lilliputaei128v1/ref/test/test-tbc-encrypt.c @@ -4,7 +4,7 @@ #include "cipher.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c b/crypto_aead/lilliputaei128v1/ref/test/test-tweakey.c @@ -4,7 +4,7 @@ #include "tweakey.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei128v1/ref/test/traces-ae-128-i.c b/crypto_aead/lilliputaei128v1/ref/test/traces-ae-128-i.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" #include "debug.h" -#include "helpers.h" +#include "test-helpers.h" FILE *DUMP; diff --git a/crypto_aead/lilliputaei192v1/ref/test/helpers.h b/crypto_aead/lilliputaei192v1/ref/test/helpers.h @@ -1,33 +0,0 @@ -#ifndef HELPERS_H -#define HELPERS_H - -#include <stdint.h> -#include <stdio.h> - -#include "parameters.h" - - -#define ARRAY_NB(A) (sizeof(A)/sizeof(A[0])) -#define ARRAY_END(A) (A+ARRAY_NB(A)) - -#define REPORT_DIFFERENCE(VECTOR, ELEMENT) do { \ - fprintf(stderr, "%s: vector %s: %s differs from expected\n", \ - __FILE__, (VECTOR), (ELEMENT)); \ - } while (0) - -#define REPORT_INVALID(VECTOR) do { \ - fprintf(stderr, "%s: vector %s: ciphertext/tag invalid\n", \ - __FILE__, (VECTOR)); \ - } while (0) - - -static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) -{ - size_t filename_len = snprintf(NULL, 0, "%s/%s_%s.txt", folder, vector, name); - char filename[filename_len+1]; - snprintf(filename, sizeof(filename), "%s/%s_%s.txt", folder, vector, name); - return fopen(filename, "w"); -} - - -#endif /* HELPERS_H */ diff --git a/crypto_aead/lilliputaei192v1/ref/test/test-ae-roundtrip.c b/crypto_aead/lilliputaei192v1/ref/test/test-ae-roundtrip.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaei192v1/ref/test/traces-ae-192-i.c b/crypto_aead/lilliputaei192v1/ref/test/traces-ae-192-i.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" #include "debug.h" -#include "helpers.h" +#include "test-helpers.h" FILE *DUMP; diff --git a/crypto_aead/lilliputaeii128v1/ref/test/helpers.h b/crypto_aead/lilliputaeii128v1/ref/test/helpers.h @@ -1,33 +0,0 @@ -#ifndef HELPERS_H -#define HELPERS_H - -#include <stdint.h> -#include <stdio.h> - -#include "parameters.h" - - -#define ARRAY_NB(A) (sizeof(A)/sizeof(A[0])) -#define ARRAY_END(A) (A+ARRAY_NB(A)) - -#define REPORT_DIFFERENCE(VECTOR, ELEMENT) do { \ - fprintf(stderr, "%s: vector %s: %s differs from expected\n", \ - __FILE__, (VECTOR), (ELEMENT)); \ - } while (0) - -#define REPORT_INVALID(VECTOR) do { \ - fprintf(stderr, "%s: vector %s: ciphertext/tag invalid\n", \ - __FILE__, (VECTOR)); \ - } while (0) - - -static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) -{ - size_t filename_len = snprintf(NULL, 0, "%s/%s_%s.txt", folder, vector, name); - char filename[filename_len+1]; - snprintf(filename, sizeof(filename), "%s/%s_%s.txt", folder, vector, name); - return fopen(filename, "w"); -} - - -#endif /* HELPERS_H */ diff --git a/crypto_aead/lilliputaeii128v1/ref/test/test-ae-roundtrip.c b/crypto_aead/lilliputaeii128v1/ref/test/test-ae-roundtrip.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaeii128v1/ref/test/traces-ae-128-ii.c b/crypto_aead/lilliputaeii128v1/ref/test/traces-ae-128-ii.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" #include "debug.h" -#include "helpers.h" +#include "test-helpers.h" FILE *DUMP; diff --git a/crypto_aead/lilliputaeii192v1/ref/test/helpers.h b/crypto_aead/lilliputaeii192v1/ref/test/helpers.h @@ -1,33 +0,0 @@ -#ifndef HELPERS_H -#define HELPERS_H - -#include <stdint.h> -#include <stdio.h> - -#include "parameters.h" - - -#define ARRAY_NB(A) (sizeof(A)/sizeof(A[0])) -#define ARRAY_END(A) (A+ARRAY_NB(A)) - -#define REPORT_DIFFERENCE(VECTOR, ELEMENT) do { \ - fprintf(stderr, "%s: vector %s: %s differs from expected\n", \ - __FILE__, (VECTOR), (ELEMENT)); \ - } while (0) - -#define REPORT_INVALID(VECTOR) do { \ - fprintf(stderr, "%s: vector %s: ciphertext/tag invalid\n", \ - __FILE__, (VECTOR)); \ - } while (0) - - -static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) -{ - size_t filename_len = snprintf(NULL, 0, "%s/%s_%s.txt", folder, vector, name); - char filename[filename_len+1]; - snprintf(filename, sizeof(filename), "%s/%s_%s.txt", folder, vector, name); - return fopen(filename, "w"); -} - - -#endif /* HELPERS_H */ diff --git a/crypto_aead/lilliputaeii192v1/ref/test/test-ae-roundtrip.c b/crypto_aead/lilliputaeii192v1/ref/test/test-ae-roundtrip.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" -#include "helpers.h" +#include "test-helpers.h" struct vector diff --git a/crypto_aead/lilliputaeii192v1/ref/test/traces-ae-192-ii.c b/crypto_aead/lilliputaeii192v1/ref/test/traces-ae-192-ii.c @@ -4,7 +4,7 @@ #include "lilliput-ae.h" #include "debug.h" -#include "helpers.h" +#include "test-helpers.h" FILE *DUMP; diff --git a/src/common.mk b/src/common.mk @@ -49,8 +49,8 @@ results/src/cipher.o: src/cipher.h src/tweakey.h src/constants.h src/parameters. results/src/constants.o: src/constants.h results/src/lilliput-ae-i.o: src/lilliput-ae.h src/cipher.h src/constants.h src/parameters.h _parameters.h results/src/tweakey.o: src/tweakey.h src/constants.h src/parameters.h _parameters.h -results/test-*.o: test/helpers.h src/parameters.h _parameters.h -results/traces-%.o: test/helpers.h src/parameters.h _parameters.h +results/test-*.o: src/test-helpers.h src/parameters.h _parameters.h +results/traces-%.o: src/test-helpers.h src/parameters.h _parameters.h # TODO: should add order-only prerequisites to remove mkdirs inside recipes # TODO: add valgrind, although it does not seem to play well with ASAN diff --git a/src/test-helpers.h b/src/test-helpers.h @@ -0,0 +1,33 @@ +#ifndef TEST_HELPERS_H +#define TEST_HELPERS_H + +#include <stdint.h> +#include <stdio.h> + +#include "parameters.h" + + +#define ARRAY_NB(A) (sizeof(A)/sizeof(A[0])) +#define ARRAY_END(A) (A+ARRAY_NB(A)) + +#define REPORT_DIFFERENCE(VECTOR, ELEMENT) do { \ + fprintf(stderr, "%s: vector %s: %s differs from expected\n", \ + __FILE__, (VECTOR), (ELEMENT)); \ + } while (0) + +#define REPORT_INVALID(VECTOR) do { \ + fprintf(stderr, "%s: vector %s: ciphertext/tag invalid\n", \ + __FILE__, (VECTOR)); \ + } while (0) + + +static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name) +{ + size_t filename_len = snprintf(NULL, 0, "%s/%s_%s.txt", folder, vector, name); + char filename[filename_len+1]; + snprintf(filename, sizeof(filename), "%s/%s_%s.txt", folder, vector, name); + return fopen(filename, "w"); +} + + +#endif /* TEST_HELPERS_H */