test: switch the unit tests to something resembling a test suite

The tests have inadvertent dependencies on each other so let's avoid
those by changing to a system that returns a null-terminated list of
test functions and our test runner iterates over those and forks off one
process per function.
This commit is contained in:
Peter Hutterer
2024-01-05 11:26:26 +10:00
parent 133e0d651c
commit 46b579e8d5
26 changed files with 338 additions and 252 deletions

View File

@@ -24,7 +24,7 @@ print_int(void* ptr, void* v)
printf("%d", *x);
}
static int
static void
test1(void)
{
HashTable h;
@@ -79,10 +79,10 @@ test1(void)
ht_destroy(h);
return ok;
assert(ok);
}
static int
static void
test2(void)
{
HashTable h;
@@ -122,10 +122,10 @@ test2(void)
printf("Test with empty keys FAILED\n");
}
return ok;
assert(ok);
}
static int
static void
test3(void)
{
int ok = 1;
@@ -152,15 +152,17 @@ test3(void)
ht_destroy(h);
return ok;
assert(ok);
}
int
const testfunc_t*
hashtabletest_test(void)
{
int ok = test1();
ok = ok && test2();
ok = ok && test3();
return ok ? 0 : 1;
static const testfunc_t testfuncs[] = {
test1,
test2,
test3,
NULL,
};
return testfuncs;
}