diff --git a/tests/testutils.c b/tests/testutils.c index 870a3b081a..eb3bd48b6a 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -838,6 +838,19 @@ int virTestMain(int argc, fprintf(stderr, "%*s", 40 - (int)(testCounter % 40), ""); fprintf(stderr, " %-3zu %s\n", testCounter, ret == 0 ? "OK" : "FAIL"); } + + switch (ret) { + case EXIT_FAILURE: + case EXIT_SUCCESS: + case EXIT_AM_SKIP: + case EXIT_AM_HARDFAIL: + break; + default: + fprintf(stderr, "Test callback returned invalid value: %d\n", ret); + ret = EXIT_AM_HARDFAIL; + break; + } + if (ret == EXIT_FAILURE && !virBitmapIsAllClear(failedTests)) { g_autofree char *failed = virBitmapFormat(failedTests); fprintf(stderr, "Some tests failed. Run them using:\n"); diff --git a/tests/testutils.h b/tests/testutils.h index e268a95612..6848323586 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -98,6 +98,10 @@ void virTestQuiesceLibvirtErrors(bool always); void virTestCounterReset(const char *prefix); const char *virTestCounterNext(void); +/** + * The @func shall return EXIT_FAILURE or EXIT_SUCCESS or + * EXIT_AM_SKIP or EXIT_AM_HARDFAIL. + */ int virTestMain(int argc, char **argv, int (*func)(void),