]> xenbits.xensource.com Git - libvirt.git/commitdiff
storagevolxml2argvtest: Report better error messages on test failure
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Jun 2013 08:49:15 +0000 (10:49 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 5 Jun 2013 12:43:16 +0000 (14:43 +0200)
If the creation of the commandline failed, libvirt always reported "out
of memory" from the virCommandToString function rather than the proper
error that happened in virStorageBackendCreateQemuImgCmd. Error out
earlier.

tests/storagevolxml2argvtest.c

index e1507b449572d3fc559484931f267b6fde7abeb4..92ab2f2a5277456f0c75948c8786d11879795847 100644 (file)
@@ -60,9 +60,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
     cmd = virStorageBackendCreateQemuImgCmd(conn, &poolobj, vol, inputvol,
                                             flags, create_tool, imgformat);
-
-    actualCmdline = virCommandToString(cmd);
-    if (!actualCmdline) {
+    if (!cmd) {
         if (shouldFail) {
             virResetLastError();
             ret = 0;
@@ -70,6 +68,9 @@ testCompareXMLToArgvFiles(bool shouldFail,
         goto cleanup;
     }
 
+    if (!(actualCmdline = virCommandToString(cmd)))
+        goto cleanup;
+
     len = virtTestLoadFile(cmdline, &expectedCmdline);
     if (len < 0)
         goto cleanup;