summaryrefslogtreecommitdiff
path: root/test/test-helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-helpers.h')
-rw-r--r--test/test-helpers.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/test/test-helpers.h b/test/test-helpers.h
index 1991542..67b15a1 100644
--- a/test/test-helpers.h
+++ b/test/test-helpers.h
@@ -1,7 +1,7 @@
#ifndef TEST_HELPERS_H
#define TEST_HELPERS_H
-#include <stdint.h>
+#include <inttypes.h>
#include <stdio.h>
#include "parameters.h"
@@ -21,13 +21,34 @@
} while (0)
-static inline FILE* open_dump_file(const char *folder, const char* vector, const char *name)
+/* Used to update vectors when constants change. */
+static inline void dump_c_initializer(size_t len, uint8_t buf[len])
{
- 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");
+ printf("{\n");
+
+ const size_t columns = 8;
+
+ for (size_t i=0; i<len; i++)
+ {
+ printf("0x%02"PRIx8, buf[i]);
+
+ if (i == len-1)
+ {
+ printf("\n");
+ }
+ else if (i%columns == columns-1)
+ {
+ printf(",\n");
+ }
+ else
+ {
+ printf(", ");
+ }
+ }
+
+ printf("}\n");
}
+
#endif /* TEST_HELPERS_H */