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

Ján Tomko jtomko at redhat.com
Fri Dec 23 13:40:08 UTC 2022


On a Friday in 2022, Michal Privoznik wrote:
>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.
>

I'm not convinced such predictability is needed - the test cases should be
isolated. On a higher level we run the individual test programs in
parallel, with no expectation of ordering.

>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;

Here we only take note of the highest version number, sorting does not
give us anything extra.

Jano

>
>     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;
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20221223/3015123c/attachment.sig>


More information about the libvir-list mailing list