mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user