From 537b22d8731af4d8d6d20ce2eade5c0c4a5f2253 Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Mon, 25 May 2026 10:48:41 +0530 Subject: coming up with a testing setup --- tests/main.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/main.c (limited to 'tests/main.c') diff --git a/tests/main.c b/tests/main.c new file mode 100644 index 0000000..9333aec --- /dev/null +++ b/tests/main.c @@ -0,0 +1,40 @@ +#include +#include +#include + +#define TEST_MOD +#include "../generated/tests.c" + +double diff_time(struct timespec a, struct timespec b) { + double a_time = (double)a.tv_sec + a.tv_nsec * 1e-9; + double b_time = (double)b.tv_sec + b.tv_nsec * 1e-9; + + return a_time - b_time; +} + +int main() { + int i = 0; + while (i < total_test_count) { + char padded_testname[max_test_name_size + 2]; + int j = 0; + while (test_names[i][j] != 0) { + padded_testname[j] = test_names[i][j]; + j++; + } + while (j < max_test_name_size + 2) { + padded_testname[j++] = ' '; + } + padded_testname[j] = 0; + printf("%s", padded_testname); + fflush(stdout); + + struct timespec begin, end; + + clock_gettime(CLOCK_MONOTONIC, &begin); + bool result = tests[i](); + clock_gettime(CLOCK_MONOTONIC, &end); + + printf(" %s %.2lfs\n", result ? "P" : "F", diff_time(end, begin)); + i++; + } +} -- cgit v1.2.3