diff --git a/tests/testutils.c b/tests/testutils.c index 9180e86ed2d22f537252d48c8e2e7fa312f62418..f4fbad2f1caaf324bd9c03de44bd94bb858b7a01 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -842,9 +843,11 @@ virTestSetEnvPath(void) int virtTestMain(int argc, char **argv, - const char *lib, - int (*func)(void)) + int (*func)(void), + ...) { + const char *lib; + va_list ap; int ret; char *testRange = NULL; #ifdef TEST_OOM @@ -854,8 +857,10 @@ int virtTestMain(int argc, if (getenv("VIR_TEST_FILE_ACCESS")) VIRT_TEST_PRELOAD(TEST_MOCK); - if (lib) + va_start(ap, func); + while ((lib = va_arg(ap, const char *))) VIRT_TEST_PRELOAD(lib); + va_end(ap); progname = last_component(argv[0]); if (STRPREFIX(progname, "lt-")) diff --git a/tests/testutils.h b/tests/testutils.h index d1caf20e70a178daf1bb80e1002bcab195ba20ed..c8929024ededd197d59aaa74fba36442d6acc831 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -102,13 +102,13 @@ const char *virtTestCounterNext(void); int virtTestMain(int argc, char **argv, - const char *lib, - int (*func)(void)); + int (*func)(void), + ...); /* Setup, then call func() */ # define VIRT_TEST_MAIN(func) \ int main(int argc, char **argv) { \ - return virtTestMain(argc, argv, NULL, func); \ + return virtTestMain(argc, argv, func, NULL); \ } # define VIRT_TEST_PRELOAD(lib) \ @@ -131,9 +131,9 @@ int virtTestMain(int argc, } \ } while (0) -# define VIRT_TEST_MAIN_PRELOAD(func, lib) \ +# define VIRT_TEST_MAIN_PRELOAD(func, ...) \ int main(int argc, char **argv) { \ - return virtTestMain(argc, argv, lib, func); \ + return virtTestMain(argc, argv, func, __VA_ARGS__, NULL); \ } virCapsPtr virTestGenericCapsInit(void);