tests: update template and add pids

Generalised the library API tests and created a common
test-runner. Instead of copy and pasting the same code in
each time.

First cut of pids API test, for _new so far.
This commit is contained in:
Craig Small
2016-04-19 21:33:02 +10:00
parent 714ea69c6d
commit aa16ab0dc1
8 changed files with 130 additions and 92 deletions

View File

@ -26,29 +26,18 @@
int check_linux_version(void *data)
{
testname = "procps_linux_version()";
return (procps_linux_version() > 0);
}
struct test_func tests[] = {
{ check_linux_version, "procps_linux_version()"},
{ NULL, NULL}
TestFunction test_funcs[] = {
check_linux_version,
NULL
};
int main(int argc, char *argv[])
{
int i;
struct test_func *current;
for(i=0; tests[i].func != NULL; i++) {
current = &tests[i];
if (!current->func(NULL)) {
fprintf(stderr, "FAIL: %s\n", current->name);
return EXIT_FAILURE;
} else {
fprintf(stderr, "PASS: %s\n", current->name);
}
}
return EXIT_SUCCESS;
return run_tests(test_funcs, NULL);
}