[PATCH 3/3] tests: Use virDirOpenSorted()

Michal Privoznik mprivozn at redhat.com
Fri Dec 23 08:35:30 UTC 2022


Since the directory content is not returned in a sorted manner it
may be harder than necessary to find a particular test case. For
instance domaincapstest runs individual test cases in "random"
order. At the first glance it may seem that we are missing a
particular version test. Well, now that we have
virDirOpenSorted() the test cases can run in more predictable
way.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 tests/testutilsqemu.c | 4 ++--
 tests/virschematest.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 7648ead735..5ca5558b45 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -736,7 +736,7 @@ testQemuGetLatestCapsForArch(const char *arch,
 
     fullsuffix = g_strdup_printf("%s.%s", arch, suffix);
 
-    if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
+    if (virDirOpenSorted(&dir, TEST_QEMU_CAPS_PATH) < 0)
         return NULL;
 
     while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
@@ -824,7 +824,7 @@ testQemuCapsIterate(const char *suffix,
         return -1;
     }
 
-    if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
+    if (virDirOpenSorted(&dir, TEST_QEMU_CAPS_PATH) < 0)
         return -1;
 
     while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
diff --git a/tests/virschematest.c b/tests/virschematest.c
index 19720c3021..66a430f239 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -90,7 +90,7 @@ testSchemaDir(const char *schema,
     int rc;
     g_autoptr(GRegex) filter = NULL;
 
-    if (virDirOpen(&dir, dir_path) < 0) {
+    if (virDirOpenSorted(&dir, dir_path) < 0) {
         virTestPropagateLibvirtError();
         return -1;
     }
-- 
2.38.2



More information about the libvir-list mailing list