[libvirt] [PATCH] tests/networkxml2conf: Fix to work again on non-Linux

Martin Kletzander mkletzan at redhat.com
Fri Dec 23 09:45:41 UTC 2016


On Thu, Dec 22, 2016 at 08:43:33PM +0100, Andrea Bolognani wrote:
>Since commit 478ddedc12b7 the name of the loopback interface
>in the generated dnsmasq configuration is OS-dependent.
>However, the test suite has not been updated to cope with the
>change, causing it to fail on FreeBSD and other non-Linux
>operating systems.
>
>Modify the networkxml2conf test case to read the expected
>output from different files based on the OS we're building on.
>---
>diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
>index a80d3b2..617c7ea 100644
>--- a/tests/networkxml2conftest.c
>+++ b/tests/networkxml2conftest.c
>@@ -71,11 +71,16 @@ testCompareXMLToConfHelper(const void *data)
>     const testInfo *info = data;
>     char *inxml = NULL;
>     char *outxml = NULL;
>+#ifdef __linux__
>+    const char *os = "linux";
>+#else
>+    const char *os = "other";
>+#endif
>

So this part ^^ is fine, let's assume it's the "how is the loopback
interface named" function.  But instead it could be: loopname = "lo" and
"lo0" respectively.

>     if (virAsprintf(&inxml, "%s/networkxml2confdata/%s.xml",
>                     abs_srcdir, info->name) < 0 ||
>-        virAsprintf(&outxml, "%s/networkxml2confdata/%s.conf",
>-                    abs_srcdir, info->name) < 0) {
>+        virAsprintf(&outxml, "%s/networkxml2confdata/%s-%s.conf",
>+                    abs_srcdir, info->name, os) < 0) {

LOL, "outxml" is not XML at all.

But anyway, I'm sorry to say this, but honestly?  Gross.  I'd rather
change except-interface=lo to except-interface=LOOPBACK_NAME and then
strstr() and memmove() the outxml.  Just my $.02, though.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161223/5e938d55/attachment-0001.sig>


More information about the libvir-list mailing list