[libvirt] [PATCH] tests: Handle networkxml2argvtest being configure --localstatedir dependant

networkxml2argvtest indirectly calls networkDnsmasqLeaseFileName that depends on configure --localstatedir. Therefore, the .argv files used in the test have to be created with this localstatedir. Move the .argv to .argv.in files with a @localstatedir@ placeholder. --- tests/.gitignore | 1 + tests/Makefile.am | 13 ++++++++++++- ...lated-network.argv => isolated-network.argv.in} | 2 +- ...ns-hosts.argv => nat-network-dns-hosts.argv.in} | 2 +- ...ord.argv => nat-network-dns-txt-record.argv.in} | 2 +- .../{nat-network.argv => nat-network.argv.in} | 2 +- ...etboot-network.argv => netboot-network.argv.in} | 2 +- ...-network.argv => netboot-proxy-network.argv.in} | 2 +- ...{routed-network.argv => routed-network.argv.in} | 0 9 files changed, 19 insertions(+), 7 deletions(-) rename tests/networkxml2argvdata/{isolated-network.argv => isolated-network.argv.in} (68%) rename tests/networkxml2argvdata/{nat-network-dns-hosts.argv => nat-network-dns-hosts.argv.in} (64%) rename tests/networkxml2argvdata/{nat-network-dns-txt-record.argv => nat-network-dns-txt-record.argv.in} (84%) rename tests/networkxml2argvdata/{nat-network.argv => nat-network.argv.in} (83%) rename tests/networkxml2argvdata/{netboot-network.argv => netboot-network.argv.in} (80%) rename tests/networkxml2argvdata/{netboot-proxy-network.argv => netboot-proxy-network.argv.in} (79%) rename tests/networkxml2argvdata/{routed-network.argv => routed-network.argv.in} (100%) diff --git a/tests/.gitignore b/tests/.gitignore index 7f26dd7..be8d321 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -10,6 +10,7 @@ conftest esxutilstest eventtest interfacexml2xmltest +networkxml2argvdata/*.argv networkxml2xmltest nodedevxml2xmltest nodeinfotest diff --git a/tests/Makefile.am b/tests/Makefile.am index 7db9d1f..3c4b7ee 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -50,7 +50,8 @@ EXTRA_DIST = \ networkschematest \ networkxml2xmlin \ networkxml2xmlout \ - networkxml2argvdata \ + $(wildcard networkxml2argvdata/*.argv.in) \ + $(wildcard networkxml2argvdata/*.xml) \ nodedevschemadata \ nodedevschematest \ nodeinfodata \ @@ -358,10 +359,20 @@ networkxml2xmltest_SOURCES = \ testutils.c testutils.h networkxml2xmltest_LDADD = $(LDADDS) +networkxml2argvdata_argv_in = $(wildcard networkxml2argvdata/*.argv.in) +networkxml2argvdata_argv = $(networkxml2argvdata_argv_in:%.argv.in=%.argv) + networkxml2argvtest_SOURCES = \ networkxml2argvtest.c \ testutils.c testutils.h networkxml2argvtest_LDADD = ../src/libvirt_driver_network.la $(LDADDS) +networkxml2argvtest_DEPENDENCIES = $(networkxml2argvdata_argv) + +$(srcdir)/networkxml2argvdata/%.argv: $(srcdir)/networkxml2argvdata/%.argv.in + $(AM_V_GEN)sed \ + -e 's![@]localstatedir[@]!$(localstatedir)!g' \ + < $< > $@-t && \ + mv $@-t $@ nwfilterxml2xmltest_SOURCES = \ nwfilterxml2xmltest.c \ diff --git a/tests/networkxml2argvdata/isolated-network.argv b/tests/networkxml2argvdata/isolated-network.argv.in similarity index 68% rename from tests/networkxml2argvdata/isolated-network.argv rename to tests/networkxml2argvdata/isolated-network.argv.in index f801396..c05768d 100644 --- a/tests/networkxml2argvdata/isolated-network.argv +++ b/tests/networkxml2argvdata/isolated-network.argv.in @@ -1,5 +1,5 @@ /usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \ --except-interface lo --dhcp-option=3 --listen-address 192.168.152.1 \ --dhcp-range 192.168.152.2,192.168.152.254 \ ---dhcp-leasefile=/var/lib/libvirt/dnsmasq/private.leases --dhcp-lease-max=253 \ +--dhcp-leasefile=@localstatedir@/lib/libvirt/dnsmasq/private.leases --dhcp-lease-max=253 \ --dhcp-no-override\ diff --git a/tests/networkxml2argvdata/nat-network-dns-hosts.argv b/tests/networkxml2argvdata/nat-network-dns-hosts.argv.in similarity index 64% rename from tests/networkxml2argvdata/nat-network-dns-hosts.argv rename to tests/networkxml2argvdata/nat-network-dns-hosts.argv.in index dce075b..5545f9f 100644 --- a/tests/networkxml2argvdata/nat-network-dns-hosts.argv +++ b/tests/networkxml2argvdata/nat-network-dns-hosts.argv.in @@ -1,3 +1,3 @@ /usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \ --except-interface lo --listen-address 192.168.122.1 \ ---addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\ +--addn-hosts=@localstatedir@/lib/libvirt/dnsmasq/default.addnhosts\ diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv.in similarity index 84% rename from tests/networkxml2argvdata/nat-network-dns-txt-record.argv rename to tests/networkxml2argvdata/nat-network-dns-txt-record.argv.in index 9d74543..f799634 100644 --- a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv +++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv.in @@ -4,5 +4,5 @@ --listen-address 2001:db8:ac10:fe01::1 \ --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 \ --dhcp-range 192.168.122.2,192.168.122.254 \ ---dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases \ +--dhcp-leasefile=@localstatedir@/lib/libvirt/dnsmasq/default.leases \ --dhcp-lease-max=253 --dhcp-no-override\ diff --git a/tests/networkxml2argvdata/nat-network.argv b/tests/networkxml2argvdata/nat-network.argv.in similarity index 83% rename from tests/networkxml2argvdata/nat-network.argv rename to tests/networkxml2argvdata/nat-network.argv.in index 181623f..680241b 100644 --- a/tests/networkxml2argvdata/nat-network.argv +++ b/tests/networkxml2argvdata/nat-network.argv.in @@ -3,5 +3,5 @@ --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 \ --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 \ --dhcp-range 192.168.122.2,192.168.122.254 \ ---dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases \ +--dhcp-leasefile=@localstatedir@/lib/libvirt/dnsmasq/default.leases \ --dhcp-lease-max=253 --dhcp-no-override\ diff --git a/tests/networkxml2argvdata/netboot-network.argv b/tests/networkxml2argvdata/netboot-network.argv.in similarity index 80% rename from tests/networkxml2argvdata/netboot-network.argv rename to tests/networkxml2argvdata/netboot-network.argv.in index 27ffaa1..57cda0e 100644 --- a/tests/networkxml2argvdata/netboot-network.argv +++ b/tests/networkxml2argvdata/netboot-network.argv.in @@ -1,6 +1,6 @@ /usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com \ --conf-file= --except-interface lo --listen-address 192.168.122.1 \ --dhcp-range 192.168.122.2,192.168.122.254 \ ---dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \ +--dhcp-leasefile=@localstatedir@/lib/libvirt/dnsmasq/netboot.leases \ --dhcp-lease-max=253 --dhcp-no-override --enable-tftp \ --tftp-root /var/lib/tftproot --dhcp-boot pxeboot.img\ diff --git a/tests/networkxml2argvdata/netboot-proxy-network.argv b/tests/networkxml2argvdata/netboot-proxy-network.argv.in similarity index 79% rename from tests/networkxml2argvdata/netboot-proxy-network.argv rename to tests/networkxml2argvdata/netboot-proxy-network.argv.in index 3e0c5a5..723539e 100644 --- a/tests/networkxml2argvdata/netboot-proxy-network.argv +++ b/tests/networkxml2argvdata/netboot-proxy-network.argv.in @@ -1,5 +1,5 @@ /usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com \ --conf-file= --except-interface lo --listen-address 192.168.122.1 \ --dhcp-range 192.168.122.2,192.168.122.254 \ ---dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \ +--dhcp-leasefile=@localstatedir@/lib/libvirt/dnsmasq/netboot.leases \ --dhcp-lease-max=253 --dhcp-no-override --dhcp-boot pxeboot.img,,10.20.30.40\ diff --git a/tests/networkxml2argvdata/routed-network.argv b/tests/networkxml2argvdata/routed-network.argv.in similarity index 100% rename from tests/networkxml2argvdata/routed-network.argv rename to tests/networkxml2argvdata/routed-network.argv.in -- 1.7.0.4

On 06/25/2011 08:41 AM, Matthias Bolte wrote:
networkxml2argvtest indirectly calls networkDnsmasqLeaseFileName that depends on configure --localstatedir. Therefore, the .argv files used in the test have to be created with this localstatedir.
Move the .argv to .argv.in files with a @localstatedir@ placeholder.
ACK.

On 06/25/2011 06:41 AM, Matthias Bolte wrote:
networkxml2argvtest indirectly calls networkDnsmasqLeaseFileName that depends on configure --localstatedir. Therefore, the .argv files used in the test have to be created with this localstatedir.
Move the .argv to .argv.in files with a @localstatedir@ placeholder.
Will this work in VPATH builds? Previously, we have done hacks where the test directory can provide an override string; if the override is NULL (the default, for use in libvirtd), then use @localstatedir@, but if the override is provided (from the test case), then use that instead. That is, by changing networkDnsmasqLeaseFileName to honor an override, we can avoid having to use all these .argv.in test files, and avoid having to worry about VPATH builds generating the .argv in a different location than the .argv.in files. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/6/25 Eric Blake <eblake@redhat.com>:
On 06/25/2011 06:41 AM, Matthias Bolte wrote:
networkxml2argvtest indirectly calls networkDnsmasqLeaseFileName that depends on configure --localstatedir. Therefore, the .argv files used in the test have to be created with this localstatedir.
Move the .argv to .argv.in files with a @localstatedir@ placeholder.
Will this work in VPATH builds? Previously, we have done hacks where the test directory can provide an override string; if the override is NULL (the default, for use in libvirtd), then use @localstatedir@, but if the override is provided (from the test case), then use that instead.
Where are we doing that in libvirtd, I can't find something like that. Also how would you do that in general? Environment variable? LD_PRELOAD to replace networkDnsmasqLeaseFileName for testing (assuming that LD_PRELOAD works in this case)? -- Matthias Bolte http://photron.blogspot.com

On 06/25/2011 10:10 AM, Matthias Bolte wrote:
2011/6/25 Eric Blake <eblake@redhat.com>:
On 06/25/2011 06:41 AM, Matthias Bolte wrote:
networkxml2argvtest indirectly calls networkDnsmasqLeaseFileName that depends on configure --localstatedir. Therefore, the .argv files used in the test have to be created with this localstatedir.
Move the .argv to .argv.in files with a @localstatedir@ placeholder.
Will this work in VPATH builds? Previously, we have done hacks where the test directory can provide an override string; if the override is NULL (the default, for use in libvirtd), then use @localstatedir@, but if the override is provided (from the test case), then use that instead.
Where are we doing that in libvirtd, I can't find something like that.
Also how would you do that in general? Environment variable? LD_PRELOAD to replace networkDnsmasqLeaseFileName for testing (assuming that LD_PRELOAD works in this case)?
Function override. See for example how openvz_conf.h declares openvzLocateConfFile, which is normally set to openvzLocateConfFileDefault and uses configure arguments to determine the string to create, but within tests/openvzutilstest, is overridden to a test-only variant that hard-codes the location to instead be relative to the test directory. That is, the networkDnsmasqLeaseFileName function can easily be reworked into a function pointer, with the current definition being installed by default, but with an alternate function pointer installed during the test that avoids any reference to configure arguments. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/6/27 Eric Blake <eblake@redhat.com>:
On 06/25/2011 10:10 AM, Matthias Bolte wrote:
2011/6/25 Eric Blake <eblake@redhat.com>:
On 06/25/2011 06:41 AM, Matthias Bolte wrote:
networkxml2argvtest indirectly calls networkDnsmasqLeaseFileName that depends on configure --localstatedir. Therefore, the .argv files used in the test have to be created with this localstatedir.
Move the .argv to .argv.in files with a @localstatedir@ placeholder.
Will this work in VPATH builds? Previously, we have done hacks where the test directory can provide an override string; if the override is NULL (the default, for use in libvirtd), then use @localstatedir@, but if the override is provided (from the test case), then use that instead.
Where are we doing that in libvirtd, I can't find something like that.
Also how would you do that in general? Environment variable? LD_PRELOAD to replace networkDnsmasqLeaseFileName for testing (assuming that LD_PRELOAD works in this case)?
Function override. See for example how openvz_conf.h declares openvzLocateConfFile, which is normally set to openvzLocateConfFileDefault and uses configure arguments to determine the string to create, but within tests/openvzutilstest, is overridden to a test-only variant that hard-codes the location to instead be relative to the test directory.
That is, the networkDnsmasqLeaseFileName function can easily be reworked into a function pointer, with the current definition being installed by default, but with an alternate function pointer installed during the test that avoids any reference to configure arguments.
Oh, true. I did the openvzLocateConfFileDefault approach :) I'll fix it that way. -- Matthias Bolte http://photron.blogspot.com
participants (3)
-
Eric Blake
-
Laine Stump
-
Matthias Bolte