提交 c3ab6b2b 编写于 作者: M Matthias Bolte

tests: Improve output of tests that decide to skip at runtime

Don't print OK/FAIL for tests that decide to be skipped after
calling virtTestMain. Delay printing of the indentation before
the first test until we know that the test didn't decide to be
skipped.

Also make the reconnect test use VIRT_TEST_MAIN.
上级 b1c9bf27
...@@ -300,7 +300,7 @@ xencapstest_SOURCES = \ ...@@ -300,7 +300,7 @@ xencapstest_SOURCES = \
xencapstest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS) xencapstest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
reconnect_SOURCES = \ reconnect_SOURCES = \
reconnect.c reconnect.c testutils.h testutils.c
reconnect_LDADD = $(LDADDS) reconnect_LDADD = $(LDADDS)
statstest_SOURCES = \ statstest_SOURCES = \
......
...@@ -11,7 +11,9 @@ static void errorHandler(void *userData ATTRIBUTE_UNUSED, ...@@ -11,7 +11,9 @@ static void errorHandler(void *userData ATTRIBUTE_UNUSED,
virErrorPtr error ATTRIBUTE_UNUSED) { virErrorPtr error ATTRIBUTE_UNUSED) {
} }
int main(void) { static int
mymain(void)
{
int id = 0; int id = 0;
int ro = 0; int ro = 0;
virConnectPtr conn; virConnectPtr conn;
...@@ -36,12 +38,12 @@ int main(void) { ...@@ -36,12 +38,12 @@ int main(void) {
} }
if (conn == NULL) { if (conn == NULL) {
fprintf(stderr, "First virConnectOpen() failed\n"); fprintf(stderr, "First virConnectOpen() failed\n");
exit(EXIT_FAILURE); return EXIT_FAILURE;
} }
dom = virDomainLookupByID(conn, id); dom = virDomainLookupByID(conn, id);
if (dom == NULL) { if (dom == NULL) {
fprintf(stderr, "First lookup for domain %d failed\n", id); fprintf(stderr, "First lookup for domain %d failed\n", id);
exit(EXIT_FAILURE); return EXIT_FAILURE;
} }
virDomainFree(dom); virDomainFree(dom);
virConnectClose(conn); virConnectClose(conn);
...@@ -51,16 +53,17 @@ int main(void) { ...@@ -51,16 +53,17 @@ int main(void) {
conn = virConnectOpen(NULL); conn = virConnectOpen(NULL);
if (conn == NULL) { if (conn == NULL) {
fprintf(stderr, "Second virConnectOpen() failed\n"); fprintf(stderr, "Second virConnectOpen() failed\n");
exit(EXIT_FAILURE); return EXIT_FAILURE;
} }
dom = virDomainLookupByID(conn, id); dom = virDomainLookupByID(conn, id);
if (dom == NULL) { if (dom == NULL) {
fprintf(stderr, "Second lookup for domain %d failed\n", id); fprintf(stderr, "Second lookup for domain %d failed\n", id);
exit(EXIT_FAILURE); return EXIT_FAILURE;
} }
virDomainFree(dom); virDomainFree(dom);
virConnectClose(conn); virConnectClose(conn);
printf("OK\n");
exit(EXIT_SUCCESS);
return EXIT_SUCCESS;
} }
VIRT_TEST_MAIN(mymain)
...@@ -76,6 +76,9 @@ void virtTestResult(const char *name, int ret, const char *msg, ...) ...@@ -76,6 +76,9 @@ void virtTestResult(const char *name, int ret, const char *msg, ...)
va_list vargs; va_list vargs;
va_start(vargs, msg); va_start(vargs, msg);
if (testCounter == 0 && !virTestGetVerbose())
fprintf(stderr, " ");
testCounter++; testCounter++;
if (virTestGetVerbose()) { if (virTestGetVerbose()) {
fprintf(stderr, "%3d) %-60s ", testCounter, name); fprintf(stderr, "%3d) %-60s ", testCounter, name);
...@@ -113,6 +116,9 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const ...@@ -113,6 +116,9 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
int i, ret = 0; int i, ret = 0;
double *ts = NULL; double *ts = NULL;
if (testCounter == 0 && !virTestGetVerbose())
fprintf(stderr, " ");
testCounter++; testCounter++;
if (testOOM < 2) { if (testOOM < 2) {
...@@ -562,8 +568,6 @@ int virtTestMain(int argc, ...@@ -562,8 +568,6 @@ int virtTestMain(int argc,
return EXIT_FAILURE; return EXIT_FAILURE;
} }
fprintf(stderr, "TEST: %s\n", progname); fprintf(stderr, "TEST: %s\n", progname);
if (!virTestGetVerbose())
fprintf(stderr, " ");
if (virThreadInitialize() < 0 || if (virThreadInitialize() < 0 ||
virErrorInitialize() < 0 || virErrorInitialize() < 0 ||
...@@ -688,7 +692,7 @@ cleanup: ...@@ -688,7 +692,7 @@ cleanup:
if (abs_srcdir_cleanup) if (abs_srcdir_cleanup)
VIR_FREE(abs_srcdir); VIR_FREE(abs_srcdir);
virResetLastError(); virResetLastError();
if (!virTestGetVerbose()) { if (!virTestGetVerbose() && ret != EXIT_AM_SKIP) {
int i; int i;
for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++) for (i = (testCounter % 40) ; i > 0 && i < 40 ; i++)
fprintf(stderr, " "); fprintf(stderr, " ");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册