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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux