summaryrefslogtreecommitdiffstats
path: root/local/tests.h
blob: 324cc2252e5d42dfdb38746f7cd5daae0db14a0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef PROCPS_NG_TESTS_H
#define PROCPS_NG_TESTS_H

#include <stdio.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