]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virschematest: Don't skip all "directory" tests
authorPeter Krempa <pkrempa@redhat.com>
Thu, 28 Nov 2024 07:48:49 +0000 (08:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 28 Nov 2024 09:28:49 +0000 (10:28 +0100)
Due to a bug in the optimization to avoid testing symlinked tests
multiple times all tests were skipped.

In commit f997fcca71a16b102e6ee663 I made an attempt to optimize the
tests by avoiding testing symlinks. This optimization was buggy as I've
passed the 'd_name' field of 'struct dirent' which is just the filename
to 'g_lstat()'. 'g_lstat()' obviously always failed with ENOENT. As the
logic checked only for successful return of 'g_lstat()' the optimizatio
was a dud.

Now in 4d8ebbfee83edb2 the 'g_lstat()' call was replaced by
'virFileIsLink()' checking all non-zero values. This meant that if
'virFileIsLink()' failed the test was skipped. Now since a bad argument
was passed this failed always and thus was always skipped making
'virschematest' useless.

Fix it by passing the full path of the test and also explicitly check
for '1' return value instead of any non-zero.

Fixes: f997fcca71a16b102e6ee663a3fb86bed8de9d7d
Fixes: 4d8ebbfee83edb26b19a62465b9f98d0126db991
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/virschematest.c

index 5d3fa32de4455945ee1f3033a1fab6cc60be3486..e08ae2173893d3d393b8f611e8da7169dfacb2f6 100644 (file)
@@ -124,8 +124,6 @@ testSchemaDir(const char *schema,
             continue;
         if (ent->d_name[0] == '.')
             continue;
-        if (virFileIsLink(ent->d_name))
-            continue;
         if (filter &&
             !g_regex_match(filter, ent->d_name, 0, NULL))
             continue;
@@ -134,11 +132,14 @@ testSchemaDir(const char *schema,
             g_strv_contains(entry->skip, ent->d_name))
             continue;
 
+        xml_path = g_strdup_printf("%s/%s", dir_path, ent->d_name);
+
+        if (virFileIsLink(xml_path) == 1)
+            continue;
+
         if (entry->exceptions)
             exception = g_strv_contains(entry->exceptions, ent->d_name);
 
-        xml_path = g_strdup_printf("%s/%s", dir_path, ent->d_name);
-
         if (testSchemaFile(schema, validator, xml_path, exception) < 0)
             ret = -1;
     }