summaryrefslogtreecommitdiff
path: root/tests/runner.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 01:17:50 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 01:17:50 +0200
commitf24ec48b27d4cb8dd0555840206dedbb45f1423c (patch)
tree4cf772a476be6b06f52b80abc05f952a33209711 /tests/runner.c
parentf33203e15a00449152283cab2b878c0886fcede5 (diff)
Add a unit test harness and a first set of tests
make check builds tests/runner from the modules that link without the io subsystem and runs it.
Diffstat (limited to 'tests/runner.c')
-rw-r--r--tests/runner.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/runner.c b/tests/runner.c
new file mode 100644
index 0000000..d73c516
--- /dev/null
+++ b/tests/runner.c
@@ -0,0 +1,34 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
3
4 $id$ */
5
6/* System */
7#include <string.h>
8
9/* Opentracker */
10#include "test.h"
11
12struct module {
13 const char *name;
14 void (*run)(void);
15};
16
17static const struct module modules[] = {{"scan_urlencoded_query", test_scan_urlencoded_query},
18 {"ot_iovec", test_iovec},
19 {"ot_vector", test_vector},
20 {NULL, NULL}};
21
22/* Run every module, or only those whose name contains argv[1] */
23int main(int argc, char **argv) {
24 const struct module *m;
25
26 for (m = modules; m->name; ++m) {
27 if (argc > 1 && !strstr(m->name, argv[1]))
28 continue;
29 test_module(m->name);
30 m->run();
31 }
32
33 return test_summary();
34}