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:
@ -2,9 +2,26 @@
|
||||
#ifndef PROCPS_NG_TESTS_H
|
||||
#define PROCPS_NG_TESTS_H
|
||||
|
||||
struct test_func {
|
||||
int (*func)(void *data);
|
||||
char *name;
|
||||
};
|
||||
typedef int (*TestFunction)(void *data);
|
||||
|
||||
char *testname;
|
||||
|
||||
|
||||
static inline int run_tests(TestFunction *list, void *data)
|
||||
{
|
||||
int i;
|
||||
TestFunction current;
|
||||
|
||||
for (i=0; list[i] != NULL; i++) {
|
||||
testname = NULL;
|
||||
current = list[i];
|
||||
if (!current(data)) {
|
||||
fprintf(stderr, "FAIL: %s\n", testname);
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
fprintf(stderr, "PASS: %s\n", testname);
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user