]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Fix detection of expected errors
authorJiri Denemark <jdenemar@redhat.com>
Mon, 29 Nov 2010 13:11:53 +0000 (14:11 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 29 Nov 2010 15:35:20 +0000 (16:35 +0100)
tests/nwfilterxml2xmltest.c
tests/qemuxml2argvtest.c

index 070aa98a7dad855932e4ebfb710b9cdc8f692bb1..9cad9130ada3dc8ea272616f495e4f8dc4539cd2 100644 (file)
@@ -25,7 +25,7 @@ static char *abs_srcdir;
 
 static int testCompareXMLToXMLFiles(const char *inxml,
                                     const char *outxml,
-                                    bool expect_warning) {
+                                    bool expect_error) {
     char inXmlData[MAX_FILE];
     char *inXmlPtr = &(inXmlData[0]);
     char outXmlData[MAX_FILE];
@@ -33,26 +33,21 @@ static int testCompareXMLToXMLFiles(const char *inxml,
     char *actual = NULL;
     int ret = -1;
     virNWFilterDefPtr dev = NULL;
-    char *log;
 
     if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0)
         goto fail;
     if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0)
         goto fail;
 
-    if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))
-        goto fail;
+    virResetLastError();
 
-    if ((log = virtTestLogContentAndReset()) == NULL)
+    if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))
         goto fail;
 
-    if ((*log != '\0') != expect_warning) {
-        free(log);
+    if (!!virGetLastError() != expect_error)
         goto fail;
-    }
-    free(log);
 
-    if (expect_warning) {
+    if (expect_error) {
         /* need to suppress the errors */
         virResetLastError();
     }
index b149ef4272cb300de7296f459499ad07973b2749..c5e04486d19a708bdea0aadf2efd5342a2b496a5 100644 (file)
@@ -84,6 +84,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
 
     free(virtTestLogContentAndReset());
+    virResetLastError();
 
     if (qemudBuildCommandLine(conn, &driver,
                               vmdef, &monitor_chr, 0, flags,
@@ -91,11 +92,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
                               NULL, NULL, migrateFrom, NULL) < 0)
         goto fail;
 
-    if ((log = virtTestLogContentAndReset()) == NULL)
-        goto fail;
-
-    if (!!strstr(log, ": error :") != expectError) {
-        if (virTestGetDebug())
+    if (!!virGetLastError() != expectError) {
+        if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
             fprintf(stderr, "\n%s", log);
         goto fail;
     }