# HG changeset patch # User Timo Sirainen # Date 1481548594 -7200 # Node ID 083846b77c3b6c2731055c1dca28e1b3a505b8d5 # Parent aa676841ed890888c00857f0449c3144c0a63ce2 lib-test: Introduce test_fatal_func_t as typedef and comment how it works. diff -r aa676841ed89 -r 083846b77c3b src/lib-test/test-common.c --- a/src/lib-test/test-common.c Mon Dec 12 09:41:02 2016 +0200 +++ b/src/lib-test/test-common.c Mon Dec 12 15:16:34 2016 +0200 @@ -256,7 +256,7 @@ } } -static void run_one_fatal(enum fatal_test_state (*fatal_function)(int)) +static void run_one_fatal(test_fatal_func_t *fatal_function) { static int index = 0; for (;;) { @@ -287,7 +287,7 @@ } } } -static void test_run_fatals(enum fatal_test_state (*fatal_functions[])(int index)) +static void test_run_fatals(test_fatal_func_t *fatal_functions[]) { unsigned int i; @@ -321,7 +321,7 @@ return test_deinit(); } int test_run_with_fatals(void (*test_functions[])(void), - enum fatal_test_state (*fatal_functions[])(int)) + test_fatal_func_t *fatal_functions[]) { test_init(); test_run_funcs(test_functions); diff -r aa676841ed89 -r 083846b77c3b src/lib-test/test-common.h --- a/src/lib-test/test-common.h Mon Dec 12 09:41:02 2016 +0200 +++ b/src/lib-test/test-common.h Mon Dec 12 15:16:34 2016 +0200 @@ -68,12 +68,18 @@ FATAL_TEST_FAILURE, /* single stage has failed, continue */ FATAL_TEST_ABORT, /* something's gone horrifically wrong */ }; +/* The fatal function is called first with stage=0. After each call the stage + is increased by 1. The idea is that each stage would be running an + individual test that is supposed to crash. The function is called until + FATAL_TEST_FINISHED or FATAL_TEST_ABORT is returned. */ +typedef enum fatal_test_state test_fatal_func_t(int stage); + struct named_fatal { const char *name; - enum fatal_test_state (*func)(int); + test_fatal_func_t *func; }; int test_run_with_fatals(void (*test_functions[])(void), - enum fatal_test_state (*fatal_functions[])(int)); + test_fatal_func_t *fatal_functions[]); int test_run_named_with_fatals(const char *match, struct named_test tests[], struct named_fatal fatals[]);