diff options
| author | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-11-28 15:54:40 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@airbus.com> | 2018-11-28 15:54:40 +0100 |
| commit | 23ed93cfd97ea7f5131805f90e9e7d34bfcaff66 (patch) | |
| tree | c9fb46afae4065c1afb62cb222c65baafe182567 /src/test-helpers.h | |
| parent | a3248db69b143ccbbe92560ff1409487cf8ac7cf (diff) | |
| download | lilliput-ae-implem-23ed93cfd97ea7f5131805f90e9e7d34bfcaff66.tar.xz | |
Mutualisation de l'entête d'utilitaires de tests
Diffstat (limited to 'src/test-helpers.h')
| -rw-r--r-- | src/test-helpers.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test-helpers.h b/src/test-helpers.h new file mode 100644 index 0000000..1991542 --- /dev/null +++ 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 */ |
