[libvirt] [PATCH] Improve error reporting in test suites

Daniel P. Berrange berrange at redhat.com
Wed Oct 13 11:11:24 UTC 2010


Before running each test case clear the thread local error
indicator. After running each test case, dispatch any error
that was reported

* tests/testutils.c: Fix error reporting in test suites
---
 tests/testutils.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index 8171f10..70e7538 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -124,8 +124,12 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
 
         if (ts)
             GETTIMEOFDAY(&before);
+        virResetLastError();
         if ((ret = body(data)) != 0)
             break;
+        virErrorPtr err = virGetLastError();
+        if (err)
+            virDispatchError(NULL);
         if (ts)	{
             GETTIMEOFDAY(&after);
             ts[i] = DIFF_MSEC(&after, &before);
-- 
1.7.2.3




More information about the libvir-list mailing list