9d4ad41e74fd573d1223c64ce3c18c808bab2206
8 #include "test_suite.h"
10 static struct options_
{
11 unsigned int verbosity
;
16 void test_verbose(const char *fmt
, ...) {
19 if (options_
.verbosity
< 1)
23 vfprintf(stdout
, fmt
, ap
);
27 void test_info(const char *fmt
, ...) {
31 vfprintf(stdout
, fmt
, ap
);
35 void test_error(const char *fmt
, ...) {
39 vfprintf(stderr
, fmt
, ap
);
44 int run_test_(test_t
*t
) {
45 int r
= t
->test_fn(t
->test_data
, test_suite_data
);
46 test_info("-- test '%s': %s --\n", t
->test_name
, r
? "FAILED" : "OK");
50 int main(int argc
, char **argv
) {
54 while ( (c
= getopt(argc
, argv
, "vl")) != EOF
) {
60 test_info("available test suites:\n");
61 for (t
= test_suite
; t
->test_name
; t
++) {
62 test_info("\t%s\n", t
->test_name
);
70 if (test_suite_pre(test_suite_data
)) {
71 test_error("%s: %s", "test_suite_pre", "FAILED");
76 while (argc
- optind
) {
77 for (t
= test_suite
; t
->test_name
&& strcmp(argv
[optind
], t
->test_name
); t
++) {}
78 if (t
->test_name
== NULL
) {
79 test_error("unknown suite '%s'\n", argv
[optind
]);
87 for (t
= test_suite
; t
->test_name
; t
++) {
93 if (test_suite_post(test_suite_data
)) {
94 test_error("%s: %s\n", "test_suite_post", "FAILED");