]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test: storage: Remove double testing in testStorageLookup
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Jan 2021 13:57:35 +0000 (14:57 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Jan 2021 06:49:57 +0000 (07:49 +0100)
The function attempts two calls to virStorageSourceChainLookup to see
whether the function handles NULL correctly. This isn't very useful and
additionally upcoming patch will remove the 'idx' parameter thus the
test becomes obsolete. Remove it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
tests/virstoragetest.c

index 0e168ce7300bc5f2f38f0381ae6a57615c729dea..99007dd662d5e41cdae629266d1106f61c03679f 100644 (file)
@@ -365,36 +365,6 @@ testStorageLookup(const void *args)
         ret = -1;
     }
 
-     /* Test twice to ensure optional parameter doesn't cause NULL deref. */
-    result = virStorageSourceChainLookup(data->chain, data->from,
-                                         idx ? NULL : data->name,
-                                         idx, NULL);
-
-    if (!data->expResult) {
-        if (virGetLastErrorCode() == VIR_ERR_OK) {
-            fprintf(stderr, "call should have failed\n");
-            ret = -1;
-        }
-        virResetLastError();
-    } else {
-        if (virGetLastErrorCode()) {
-            fprintf(stderr, "call should not have warned\n");
-            ret = -1;
-        }
-    }
-
-    if (!result) {
-        if (data->expResult) {
-            fprintf(stderr, "result 1: expected %s, got NULL\n",
-                    data->expResult);
-            ret = -1;
-        }
-    } else if (STRNEQ_NULLABLE(data->expResult, result->path)) {
-        fprintf(stderr, "result 1: expected %s, got %s\n",
-                NULLSTR(data->expResult), NULLSTR(result->path));
-        ret = -1;
-    }
-
     result = virStorageSourceChainLookup(data->chain, data->from,
                                          data->name, idx, &actualParent);
     if (!data->expResult)
@@ -402,12 +372,12 @@ testStorageLookup(const void *args)
 
     if (!result) {
         if (data->expResult) {
-            fprintf(stderr, "result 2: expected %s, got NULL\n",
+            fprintf(stderr, "result: expected %s, got NULL\n",
                     data->expResult);
             ret = -1;
         }
     } else if (STRNEQ_NULLABLE(data->expResult, result->path)) {
-        fprintf(stderr, "result 2: expected %s, got %s\n",
+        fprintf(stderr, "result: expected %s, got %s\n",
                 NULLSTR(data->expResult), NULLSTR(result->path));
         ret = -1;
     }