diff --git a/tests/networkxml2confdata/dhcp6-nat-network.hostsfile b/tests/networkxml2confdata/dhcp6-nat-network.hostsfile new file mode 100644 index 0000000000..de659b98c5 --- /dev/null +++ b/tests/networkxml2confdata/dhcp6-nat-network.hostsfile @@ -0,0 +1,7 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com +id:0:4:7e:7d:f0:7d:a8:bc:c5:d2:13:32:11:ed:16:ea:84:63,[2001:db8:ac10:fd01::1:20] +paul,[2001:db8:ac10:fd01::1:21] +id:0:3:0:1:0:16:3e:11:22:33,peter.xyz,[2001:db8:ac10:fd01::1:22] +id:0:3:0:1:0:16:3e:44:55:33,[2001:db8:ac10:fd01::1:23] +id:0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66,badbob,[2001:db8:ac10:fd01::1:24] diff --git a/tests/networkxml2confdata/dhcp6-network.hostsfile b/tests/networkxml2confdata/dhcp6-network.hostsfile new file mode 100644 index 0000000000..9dfb172ce7 --- /dev/null +++ b/tests/networkxml2confdata/dhcp6-network.hostsfile @@ -0,0 +1,5 @@ +id:0:4:7e:7d:f0:7d:a8:bc:c5:d2:13:32:11:ed:16:ea:84:63,[2001:db8:ac10:fd01::1:20] +paul,[2001:db8:ac10:fd01::1:21] +id:0:3:0:1:0:16:3e:11:22:33,peter.xyz,[2001:db8:ac10:fd01::1:22] +id:0:3:0:1:0:16:3e:44:55:33,[2001:db8:ac10:fd01::1:23] +id:0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66,badbob,[2001:db8:ac10:fd01::1:24] diff --git a/tests/networkxml2confdata/dhcp6host-routed-network.hostsfile b/tests/networkxml2confdata/dhcp6host-routed-network.hostsfile new file mode 100644 index 0000000000..de659b98c5 --- /dev/null +++ b/tests/networkxml2confdata/dhcp6host-routed-network.hostsfile @@ -0,0 +1,7 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com +id:0:4:7e:7d:f0:7d:a8:bc:c5:d2:13:32:11:ed:16:ea:84:63,[2001:db8:ac10:fd01::1:20] +paul,[2001:db8:ac10:fd01::1:21] +id:0:3:0:1:0:16:3e:11:22:33,peter.xyz,[2001:db8:ac10:fd01::1:22] +id:0:3:0:1:0:16:3e:44:55:33,[2001:db8:ac10:fd01::1:23] +id:0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66,badbob,[2001:db8:ac10:fd01::1:24] diff --git a/tests/networkxml2confdata/leasetime-hours.conf b/tests/networkxml2confdata/leasetime-hours.conf new file mode 100644 index 0000000000..1599d4633e --- /dev/null +++ b/tests/networkxml2confdata/leasetime-hours.conf @@ -0,0 +1,16 @@ +##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE +##OVERWRITTEN AND LOST. Changes to this configuration should be made using: +## virsh net-edit default +## or other application using the libvirt API. +## +## dnsmasq conf file created by libvirt +strict-order +except-interface=lo +bind-dynamic +interface=virbr0 +dhcp-range=192.168.122.2,192.168.122.254,255.255.255.0,1h +dhcp-no-override +dhcp-authoritative +dhcp-lease-max=253 +dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile +addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/leasetime-hours.hostsfile b/tests/networkxml2confdata/leasetime-hours.hostsfile new file mode 100644 index 0000000000..fb6bca4c41 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-hours.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com,2h +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com,3h diff --git a/tests/networkxml2confdata/leasetime-hours.xml b/tests/networkxml2confdata/leasetime-hours.xml new file mode 100644 index 0000000000..5c8bec8328 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-hours.xml @@ -0,0 +1,21 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2confdata/leasetime-infinite.conf b/tests/networkxml2confdata/leasetime-infinite.conf new file mode 100644 index 0000000000..883ced6ade --- /dev/null +++ b/tests/networkxml2confdata/leasetime-infinite.conf @@ -0,0 +1,16 @@ +##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE +##OVERWRITTEN AND LOST. Changes to this configuration should be made using: +## virsh net-edit default +## or other application using the libvirt API. +## +## dnsmasq conf file created by libvirt +strict-order +except-interface=lo +bind-dynamic +interface=virbr0 +dhcp-range=192.168.122.2,192.168.122.254,255.255.255.0,infinite +dhcp-no-override +dhcp-authoritative +dhcp-lease-max=253 +dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile +addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/leasetime-infinite.hostsfile b/tests/networkxml2confdata/leasetime-infinite.hostsfile new file mode 100644 index 0000000000..e92bdc6142 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-infinite.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com,infinite +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com,infinite diff --git a/tests/networkxml2confdata/leasetime-infinite.xml b/tests/networkxml2confdata/leasetime-infinite.xml new file mode 100644 index 0000000000..a5a9e6c5ed --- /dev/null +++ b/tests/networkxml2confdata/leasetime-infinite.xml @@ -0,0 +1,21 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2confdata/leasetime-minutes.conf b/tests/networkxml2confdata/leasetime-minutes.conf new file mode 100644 index 0000000000..c093501a35 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-minutes.conf @@ -0,0 +1,16 @@ +##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE +##OVERWRITTEN AND LOST. Changes to this configuration should be made using: +## virsh net-edit default +## or other application using the libvirt API. +## +## dnsmasq conf file created by libvirt +strict-order +except-interface=lo +bind-dynamic +interface=virbr0 +dhcp-range=192.168.122.2,192.168.122.254,255.255.255.0,10m +dhcp-no-override +dhcp-authoritative +dhcp-lease-max=253 +dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile +addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/leasetime-minutes.hostsfile b/tests/networkxml2confdata/leasetime-minutes.hostsfile new file mode 100644 index 0000000000..787d82f08e --- /dev/null +++ b/tests/networkxml2confdata/leasetime-minutes.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com,20m +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com,30m diff --git a/tests/networkxml2confdata/leasetime-minutes.xml b/tests/networkxml2confdata/leasetime-minutes.xml new file mode 100644 index 0000000000..1cbc285685 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-minutes.xml @@ -0,0 +1,21 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2confdata/leasetime-seconds.conf b/tests/networkxml2confdata/leasetime-seconds.conf new file mode 100644 index 0000000000..8b2a81c308 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-seconds.conf @@ -0,0 +1,16 @@ +##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE +##OVERWRITTEN AND LOST. Changes to this configuration should be made using: +## virsh net-edit default +## or other application using the libvirt API. +## +## dnsmasq conf file created by libvirt +strict-order +except-interface=lo +bind-dynamic +interface=virbr0 +dhcp-range=192.168.122.2,192.168.122.254,255.255.255.0,200s +dhcp-no-override +dhcp-authoritative +dhcp-lease-max=253 +dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile +addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts diff --git a/tests/networkxml2confdata/leasetime-seconds.hostsfile b/tests/networkxml2confdata/leasetime-seconds.hostsfile new file mode 100644 index 0000000000..ce77f2dcb9 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-seconds.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com,300s +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com,400s diff --git a/tests/networkxml2confdata/leasetime-seconds.xml b/tests/networkxml2confdata/leasetime-seconds.xml new file mode 100644 index 0000000000..9d8efc2608 --- /dev/null +++ b/tests/networkxml2confdata/leasetime-seconds.xml @@ -0,0 +1,21 @@ + + default + 81ff0d90-c91e-6742-64da-4a736edb9a9b + + + + + + + + + + + + + + + + + + diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.hostsfile b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record.hostsfile b/tests/networkxml2confdata/nat-network-dns-srv-record.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/nat-network-dns-srv-record.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2confdata/nat-network-dns-txt-record.hostsfile b/tests/networkxml2confdata/nat-network-dns-txt-record.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/nat-network-dns-txt-record.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2confdata/nat-network-mtu.hostsfile b/tests/networkxml2confdata/nat-network-mtu.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/nat-network-mtu.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2confdata/nat-network-name-with-quotes.hostsfile b/tests/networkxml2confdata/nat-network-name-with-quotes.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/nat-network-name-with-quotes.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2confdata/nat-network.hostsfile b/tests/networkxml2confdata/nat-network.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/nat-network.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2confdata/ptr-domains-auto.hostsfile b/tests/networkxml2confdata/ptr-domains-auto.hostsfile new file mode 100644 index 0000000000..deb3f00ac1 --- /dev/null +++ b/tests/networkxml2confdata/ptr-domains-auto.hostsfile @@ -0,0 +1,2 @@ +00:16:3e:77:e2:ed,192.168.122.10,a.example.com +00:16:3e:3e:a9:1a,192.168.122.11,b.example.com diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 83b89dd361..5d0bba7924 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -16,7 +16,8 @@ #define VIR_FROM_THIS VIR_FROM_NONE static int -testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr caps) +testCompareXMLToConfFiles(const char *inxml, const char *outconf, + char *outhostsfile, dnsmasqCapsPtr caps) { char *confactual = NULL; char *hostsfileactual = NULL; @@ -63,6 +64,20 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr if (virTestCompareToFile(confactual, outconf) < 0) goto fail; + if (virFileExists(outhostsfile)) { + if (!hostsfileactual) { + VIR_TEST_DEBUG("%s: hostsfile exists but the configuration did " + "not specify any host", outhostsfile); + goto fail; + } else if (virTestCompareToFile(hostsfileactual, outhostsfile) < 0) { + goto fail; + } + } else if (hostsfileactual) { + VIR_TEST_DEBUG("%s: file does not exist but actual data was expected", + outhostsfile); + goto fail; + } + ret = 0; fail: @@ -88,14 +103,17 @@ testCompareXMLToConfHelper(const void *data) const testInfo *info = data; char *inxml = NULL; char *outconf = NULL; + char *outhostsfile = NULL; inxml = g_strdup_printf("%s/networkxml2confdata/%s.xml", abs_srcdir, info->name); outconf = g_strdup_printf("%s/networkxml2confdata/%s.conf", abs_srcdir, info->name); + outhostsfile = g_strdup_printf("%s/networkxml2confdata/%s.hostsfile", abs_srcdir, info->name); - result = testCompareXMLToConfFiles(inxml, outconf, info->caps); + result = testCompareXMLToConfFiles(inxml, outconf, outhostsfile, info->caps); VIR_FREE(inxml); VIR_FREE(outconf); + VIR_FREE(outhostsfile); return result; } @@ -145,6 +163,10 @@ mymain(void) DO_TEST("dhcp6host-routed-network", dhcpv6); DO_TEST("ptr-domains-auto", dhcpv6); DO_TEST("dnsmasq-options", dhcpv6); + DO_TEST("leasetime-seconds", full); + DO_TEST("leasetime-minutes", full); + DO_TEST("leasetime-hours", full); + DO_TEST("leasetime-infinite", full); virObjectUnref(dhcpv6); virObjectUnref(full); diff --git a/tests/networkxml2xmlin/leasetime-hours.xml b/tests/networkxml2xmlin/leasetime-hours.xml new file mode 120000 index 0000000000..5a6bed3d5f --- /dev/null +++ b/tests/networkxml2xmlin/leasetime-hours.xml @@ -0,0 +1 @@ +../networkxml2confdata/leasetime-hours.xml \ No newline at end of file diff --git a/tests/networkxml2xmlin/leasetime-infinite.xml b/tests/networkxml2xmlin/leasetime-infinite.xml new file mode 120000 index 0000000000..706e4cdf11 --- /dev/null +++ b/tests/networkxml2xmlin/leasetime-infinite.xml @@ -0,0 +1 @@ +../networkxml2confdata/leasetime-infinite.xml \ No newline at end of file diff --git a/tests/networkxml2xmlin/leasetime-minutes.xml b/tests/networkxml2xmlin/leasetime-minutes.xml new file mode 120000 index 0000000000..2c19b06a8a --- /dev/null +++ b/tests/networkxml2xmlin/leasetime-minutes.xml @@ -0,0 +1 @@ +../networkxml2confdata/leasetime-minutes.xml \ No newline at end of file diff --git a/tests/networkxml2xmlin/leasetime-seconds.xml b/tests/networkxml2xmlin/leasetime-seconds.xml new file mode 120000 index 0000000000..f182cfa2f1 --- /dev/null +++ b/tests/networkxml2xmlin/leasetime-seconds.xml @@ -0,0 +1 @@ +../networkxml2confdata/leasetime-seconds.xml \ No newline at end of file diff --git a/tests/networkxml2xmlout/leasetime-hours.xml b/tests/networkxml2xmlout/leasetime-hours.xml new file mode 120000 index 0000000000..d3cf0fb342 --- /dev/null +++ b/tests/networkxml2xmlout/leasetime-hours.xml @@ -0,0 +1 @@ +../networkxml2xmlin/leasetime-hours.xml \ No newline at end of file diff --git a/tests/networkxml2xmlout/leasetime-infinite.xml b/tests/networkxml2xmlout/leasetime-infinite.xml new file mode 120000 index 0000000000..2390f7a3a7 --- /dev/null +++ b/tests/networkxml2xmlout/leasetime-infinite.xml @@ -0,0 +1 @@ +../networkxml2xmlin/leasetime-infinite.xml \ No newline at end of file diff --git a/tests/networkxml2xmlout/leasetime-minutes.xml b/tests/networkxml2xmlout/leasetime-minutes.xml new file mode 120000 index 0000000000..09ebdb9c14 --- /dev/null +++ b/tests/networkxml2xmlout/leasetime-minutes.xml @@ -0,0 +1 @@ +../networkxml2xmlin/leasetime-minutes.xml \ No newline at end of file diff --git a/tests/networkxml2xmlout/leasetime-seconds.xml b/tests/networkxml2xmlout/leasetime-seconds.xml new file mode 120000 index 0000000000..7036ca6713 --- /dev/null +++ b/tests/networkxml2xmlout/leasetime-seconds.xml @@ -0,0 +1 @@ +../networkxml2xmlin/leasetime-seconds.xml \ No newline at end of file diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index ec679e72ee..700744785a 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -160,6 +160,10 @@ mymain(void) DO_TEST("metadata"); DO_TEST("set-mtu"); DO_TEST("dnsmasq-options"); + DO_TEST("leasetime-seconds"); + DO_TEST("leasetime-minutes"); + DO_TEST("leasetime-hours"); + DO_TEST("leasetime-infinite"); DO_TEST("isolated-ports"); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;