[PATCH] virschematest: Replace g_lstat() with virFileIsLink()

Michal Privoznik posted 1 patch 2 months, 3 weeks ago
tests/virschematest.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] virschematest: Replace g_lstat() with virFileIsLink()
Posted by Michal Privoznik 2 months, 3 weeks ago
Inside of virschematest.c there's testSchemaDir() which iterates
over dentries in given directory but skips some files: those
without ".xml" suffix, hidden files, symlinks, etc.

Now, symlinks are detected as g_lstat() + S_ISLNK() combo which
works, except it fails to compile on mingw where is no concept of
symlinks. Replace the combo with a call to virFileIsLink() which
at least allows us to compile cleanly on mingw.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

The reason this isn't detected by our CI is that we explicitly build
libvirt with -Dtests=disabled which I missed when debugging latest build
error on mingw.

 tests/virschematest.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/virschematest.c b/tests/virschematest.c
index 20ac495f4a..83bc945711 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -125,8 +125,7 @@ testSchemaDir(const char *schema,
             continue;
         if (ent->d_name[0] == '.')
             continue;
-        if (g_lstat(ent->d_name, &sb) >= 0 &&
-            S_ISLNK(sb.st_mode))
+        if (virFileIsLink(ent->d_name))
             continue;
         if (filter &&
             !g_regex_match(filter, ent->d_name, 0, NULL))
-- 
2.44.2
Re: [PATCH] virschematest: Replace g_lstat() with virFileIsLink()
Posted by Peter Krempa 2 months, 3 weeks ago
On Tue, Aug 27, 2024 at 14:26:53 +0200, Michal Privoznik wrote:
> Inside of virschematest.c there's testSchemaDir() which iterates
> over dentries in given directory but skips some files: those
> without ".xml" suffix, hidden files, symlinks, etc.
> 
> Now, symlinks are detected as g_lstat() + S_ISLNK() combo which
> works, except it fails to compile on mingw where is no concept of
> symlinks. Replace the combo with a call to virFileIsLink() which
> at least allows us to compile cleanly on mingw.

Fixes: f997fcca71a16b102e6ee663a3fb86bed8de9d7d

> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---

Reviewed-by: Peter Krempa <pkrempa@redhat.com>