New tests are required to cover some new XML syntax entry for
<lease/> option. This includes schema testing and other features
like unit attribute and lease value. This commit includes hostsfile
checks adding new files for each test case that is manipulating <host/>
tag.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
.../dhcp6-nat-network.hostsfile | 7 ++++
.../dhcp6-network.hostsfile | 5 +++
.../dhcp6host-routed-network.hostsfile | 7 ++++
.../networkxml2confdata/leasetime-hours.conf | 16 ++++++++
.../leasetime-hours.hostsfile | 2 +
tests/networkxml2confdata/leasetime-hours.xml | 19 +++++++++
.../leasetime-infinite.conf | 16 ++++++++
.../leasetime-infinite.hostsfile | 2 +
.../leasetime-infinite.xml | 19 +++++++++
.../leasetime-minutes.conf | 16 ++++++++
.../leasetime-minutes.hostsfile | 2 +
.../networkxml2confdata/leasetime-minutes.xml | 19 +++++++++
.../leasetime-seconds.conf | 16 ++++++++
.../leasetime-seconds.hostsfile | 2 +
.../networkxml2confdata/leasetime-seconds.xml | 19 +++++++++
...t-network-dns-srv-record-minimal.hostsfile | 2 +
.../nat-network-dns-srv-record.hostsfile | 2 +
.../nat-network-dns-txt-record.hostsfile | 2 +
.../nat-network-mtu.hostsfile | 2 +
.../nat-network-name-with-quotes.hostsfile | 2 +
.../networkxml2confdata/nat-network.hostsfile | 2 +
.../ptr-domains-auto.hostsfile | 2 +
tests/networkxml2conftest.c | 41 +++++++++++++++----
tests/networkxml2xmlin/leasetime-hours.xml | 19 +++++++++
tests/networkxml2xmlin/leasetime-infinite.xml | 19 +++++++++
tests/networkxml2xmlin/leasetime-minutes.xml | 19 +++++++++
tests/networkxml2xmlin/leasetime-seconds.xml | 19 +++++++++
tests/networkxml2xmlout/leasetime-hours.xml | 21 ++++++++++
.../networkxml2xmlout/leasetime-infinite.xml | 21 ++++++++++
tests/networkxml2xmlout/leasetime-minutes.xml | 21 ++++++++++
tests/networkxml2xmlout/leasetime-seconds.xml | 21 ++++++++++
tests/networkxml2xmltest.c | 4 ++
32 files changed, 378 insertions(+), 8 deletions(-)
create mode 100644 tests/networkxml2confdata/dhcp6-nat-network.hostsfile
create mode 100644 tests/networkxml2confdata/dhcp6-network.hostsfile
create mode 100644 tests/networkxml2confdata/dhcp6host-routed-network.hostsfile
create mode 100644 tests/networkxml2confdata/leasetime-hours.conf
create mode 100644 tests/networkxml2confdata/leasetime-hours.hostsfile
create mode 100644 tests/networkxml2confdata/leasetime-hours.xml
create mode 100644 tests/networkxml2confdata/leasetime-infinite.conf
create mode 100644 tests/networkxml2confdata/leasetime-infinite.hostsfile
create mode 100644 tests/networkxml2confdata/leasetime-infinite.xml
create mode 100644 tests/networkxml2confdata/leasetime-minutes.conf
create mode 100644 tests/networkxml2confdata/leasetime-minutes.hostsfile
create mode 100644 tests/networkxml2confdata/leasetime-minutes.xml
create mode 100644 tests/networkxml2confdata/leasetime-seconds.conf
create mode 100644 tests/networkxml2confdata/leasetime-seconds.hostsfile
create mode 100644 tests/networkxml2confdata/leasetime-seconds.xml
create mode 100644
tests/networkxml2confdata/nat-network-dns-srv-record-minimal.hostsfile
create mode 100644 tests/networkxml2confdata/nat-network-dns-srv-record.hostsfile
create mode 100644 tests/networkxml2confdata/nat-network-dns-txt-record.hostsfile
create mode 100644 tests/networkxml2confdata/nat-network-mtu.hostsfile
create mode 100644 tests/networkxml2confdata/nat-network-name-with-quotes.hostsfile
create mode 100644 tests/networkxml2confdata/nat-network.hostsfile
create mode 100644 tests/networkxml2confdata/ptr-domains-auto.hostsfile
create mode 100644 tests/networkxml2xmlin/leasetime-hours.xml
create mode 100644 tests/networkxml2xmlin/leasetime-infinite.xml
create mode 100644 tests/networkxml2xmlin/leasetime-minutes.xml
create mode 100644 tests/networkxml2xmlin/leasetime-seconds.xml
create mode 100644 tests/networkxml2xmlout/leasetime-hours.xml
create mode 100644 tests/networkxml2xmlout/leasetime-infinite.xml
create mode 100644 tests/networkxml2xmlout/leasetime-minutes.xml
create mode 100644 tests/networkxml2xmlout/leasetime-seconds.xml
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..5427767a98
--- /dev/null
+++ b/tests/networkxml2confdata/leasetime-hours.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="1" unit="hours"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="2" unit="hours"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="3" unit="hours"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
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..3528ddc19d
--- /dev/null
+++ b/tests/networkxml2confdata/leasetime-infinite.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="0"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="0"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="0"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
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..0de8e2b94b
--- /dev/null
+++ b/tests/networkxml2confdata/leasetime-minutes.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="10"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="20" unit="mins"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="30" unit="mins"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
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..c359df4292
--- /dev/null
+++ b/tests/networkxml2confdata/leasetime-seconds.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="200" unit="seconds"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="300" unit="seconds"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="400" unit="seconds"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
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 a8355272b9..f7518f1d1d 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -16,9 +16,11 @@
#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 *actual = NULL;
+ char *confactual = NULL;
+ char *hostsfileactual = NULL;
int ret = -1;
virNetworkDefPtr def = NULL;
virNetworkObjPtr obj = NULL;
@@ -43,28 +45,43 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
dnsmasqCapsPtr
if (dctx == NULL)
goto fail;
- if (networkDnsmasqConfContents(obj, pidfile, &actual, dctx, caps) < 0)
+ if (networkDnsmasqConfContents(obj, pidfile, &confactual,
+ &hostsfileactual, dctx, caps) < 0)
goto fail;
/* Any changes to this function ^^ should be reflected here too. */
#ifndef __linux__
char * tmp;
- if (!(tmp = virStringReplace(actual,
+ if (!(tmp = virStringReplace(confactual,
"except-interface=lo0\n",
"except-interface=lo\n")))
goto fail;
- VIR_FREE(actual);
+ VIR_FREE(confactual);
actual = g_steal_pointer(&tmp);
#endif
- if (virTestCompareToFile(actual, outconf) < 0)
+ 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:
- VIR_FREE(actual);
+ VIR_FREE(confactual);
VIR_FREE(pidfile);
virCommandFree(cmd);
virObjectUnref(xmlopt);
@@ -85,14 +102,18 @@ 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;
}
@@ -142,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 100644
index 0000000000..5427767a98
--- /dev/null
+++ b/tests/networkxml2xmlin/leasetime-hours.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="1" unit="hours"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="2" unit="hours"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="3" unit="hours"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlin/leasetime-infinite.xml
b/tests/networkxml2xmlin/leasetime-infinite.xml
new file mode 100644
index 0000000000..3528ddc19d
--- /dev/null
+++ b/tests/networkxml2xmlin/leasetime-infinite.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="0"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="0"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="0"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlin/leasetime-minutes.xml
b/tests/networkxml2xmlin/leasetime-minutes.xml
new file mode 100644
index 0000000000..6ed3814042
--- /dev/null
+++ b/tests/networkxml2xmlin/leasetime-minutes.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="10" unit="mins"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="20" unit="mins"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="30" unit="mins"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlin/leasetime-seconds.xml
b/tests/networkxml2xmlin/leasetime-seconds.xml
new file mode 100644
index 0000000000..c359df4292
--- /dev/null
+++ b/tests/networkxml2xmlin/leasetime-seconds.xml
@@ -0,0 +1,19 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <bridge name="virbr0"/>
+ <forward mode="nat" dev="eth1"/>
+ <ip address="192.168.122.1" netmask="255.255.255.0">
+ <dhcp>
+ <range start="192.168.122.2" end="192.168.122.254">
+ <lease expiry="200" unit="seconds"/>
+ </range>
+ <host mac="00:16:3e:77:e2:ed" name="a.example.com"
ip="192.168.122.10">
+ <lease expiry="300" unit="seconds"/>
+ </host>
+ <host mac="00:16:3e:3e:a9:1a" name="b.example.com"
ip="192.168.122.11">
+ <lease expiry="400" unit="seconds"/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlout/leasetime-hours.xml
b/tests/networkxml2xmlout/leasetime-hours.xml
new file mode 100644
index 0000000000..5c8bec8328
--- /dev/null
+++ b/tests/networkxml2xmlout/leasetime-hours.xml
@@ -0,0 +1,21 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward dev='eth1' mode='nat'>
+ <interface dev='eth1'/>
+ </forward>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.122.2' end='192.168.122.254'>
+ <lease expiry='1' unit='hours'/>
+ </range>
+ <host mac='00:16:3e:77:e2:ed' name='a.example.com'
ip='192.168.122.10'>
+ <lease expiry='2' unit='hours'/>
+ </host>
+ <host mac='00:16:3e:3e:a9:1a' name='b.example.com'
ip='192.168.122.11'>
+ <lease expiry='3' unit='hours'/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlout/leasetime-infinite.xml
b/tests/networkxml2xmlout/leasetime-infinite.xml
new file mode 100644
index 0000000000..a5a9e6c5ed
--- /dev/null
+++ b/tests/networkxml2xmlout/leasetime-infinite.xml
@@ -0,0 +1,21 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward dev='eth1' mode='nat'>
+ <interface dev='eth1'/>
+ </forward>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.122.2' end='192.168.122.254'>
+ <lease expiry='0'/>
+ </range>
+ <host mac='00:16:3e:77:e2:ed' name='a.example.com'
ip='192.168.122.10'>
+ <lease expiry='0'/>
+ </host>
+ <host mac='00:16:3e:3e:a9:1a' name='b.example.com'
ip='192.168.122.11'>
+ <lease expiry='0'/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlout/leasetime-minutes.xml
b/tests/networkxml2xmlout/leasetime-minutes.xml
new file mode 100644
index 0000000000..b5c698076f
--- /dev/null
+++ b/tests/networkxml2xmlout/leasetime-minutes.xml
@@ -0,0 +1,21 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward dev='eth1' mode='nat'>
+ <interface dev='eth1'/>
+ </forward>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.122.2' end='192.168.122.254'>
+ <lease expiry='10' unit='mins'/>
+ </range>
+ <host mac='00:16:3e:77:e2:ed' name='a.example.com'
ip='192.168.122.10'>
+ <lease expiry='20' unit='mins'/>
+ </host>
+ <host mac='00:16:3e:3e:a9:1a' name='b.example.com'
ip='192.168.122.11'>
+ <lease expiry='30' unit='mins'/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
diff --git a/tests/networkxml2xmlout/leasetime-seconds.xml
b/tests/networkxml2xmlout/leasetime-seconds.xml
new file mode 100644
index 0000000000..9d8efc2608
--- /dev/null
+++ b/tests/networkxml2xmlout/leasetime-seconds.xml
@@ -0,0 +1,21 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+ <forward dev='eth1' mode='nat'>
+ <interface dev='eth1'/>
+ </forward>
+ <bridge name='virbr0' stp='on' delay='0'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.122.2' end='192.168.122.254'>
+ <lease expiry='200' unit='seconds'/>
+ </range>
+ <host mac='00:16:3e:77:e2:ed' name='a.example.com'
ip='192.168.122.10'>
+ <lease expiry='300' unit='seconds'/>
+ </host>
+ <host mac='00:16:3e:3e:a9:1a' name='b.example.com'
ip='192.168.122.11'>
+ <lease expiry='400' unit='seconds'/>
+ </host>
+ </dhcp>
+ </ip>
+</network>
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;
--
2.24.1