procps/include/tests.h
Craig Small aa16ab0dc1 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.
2016-04-19 21:33:02 +10:00

28 lines
540 B
C

#ifndef PROCPS_NG_TESTS_H
#define PROCPS_NG_TESTS_H
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