diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-25 10:48:41 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-05-25 10:48:41 +0530 |
| commit | 537b22d8731af4d8d6d20ce2eade5c0c4a5f2253 (patch) | |
| tree | 10e4a5683a7c0f692ed2b3ee537df2256e73df94 /tests/main.c | |
| parent | b0a585e21362137c90a6484de44889d2117d9c7a (diff) | |
coming up with a testing setup
Diffstat (limited to 'tests/main.c')
| -rw-r--r-- | tests/main.c | 40 |
1 files changed, 40 insertions, 0 deletions
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 <stdio.h> +#include <stdbool.h> +#include <time.h> + +#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++; + } +} |
