virschematest: Don't skip all "directory" tests

Due to a bug in the optimization to avoid testing symlinked tests
multiple times all tests were skipped.

In commit f997fcca71 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 4d8ebbfee8 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: f997fcca71
Fixes: 4d8ebbfee8
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2024-11-28 08:48:49 +01:00
parent 99dadf9e08
commit f850c2a569

View File

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