summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Bolte <matthias.bolte@googlemail.com>2011-06-27 16:55:13 +0200
committerMatthias Bolte <matthias.bolte@googlemail.com>2011-06-27 17:22:25 +0200
commit072ea80ff2480c64906e2b8f1f97ff3dc562e7bc (patch)
tree331347d18d3e1d19313b510e056dc52bb2b31157
parentqemu: Remove bogus error codes for NUMA memory tuning (diff)
downloadlibvirt-072ea80ff2480c64906e2b8f1f97ff3dc562e7bc.tar.gz
libvirt-072ea80ff2480c64906e2b8f1f97ff3dc562e7bc.tar.bz2
libvirt-072ea80ff2480c64906e2b8f1f97ff3dc562e7bc.zip
tests: Partly fix networkxml2argvtest being configure result dependent
Convert networkDnsmasqLeaseFileName to a replaceable function pointer that allow the testsuite to use a version of that function that is not depending on configure --localstatedir. This fixes 5 of 6 test failures, when configure --localstatedir isn't set to /var.
-rw-r--r--src/network/bridge_driver.c5
-rw-r--r--src/network/bridge_driver.h5
-rw-r--r--tests/networkxml2argvtest.c13
3 files changed, 22 insertions, 1 deletions
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f15a7a687..aa170d60a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -108,7 +108,7 @@ static void networkReloadIptablesRules(struct network_driver *driver);
static struct network_driver *driverState = NULL;
static char *
-networkDnsmasqLeaseFileName(const char *netname)
+networkDnsmasqLeaseFileNameDefault(const char *netname)
{
char *leasefile;
@@ -117,6 +117,9 @@ networkDnsmasqLeaseFileName(const char *netname)
return leasefile;
}
+networkDnsmasqLeaseFileNameFunc networkDnsmasqLeaseFileName =
+ networkDnsmasqLeaseFileNameDefault;
+
static char *
networkRadvdPidfileBasename(const char *netname)
{
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 8d82b6771..a106e3df5 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -34,4 +34,9 @@
int networkRegister(void);
int networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdout, char *pidfile);
+typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname);
+
+/* this allows the testsuite to replace the lease filename resolver function */
+extern networkDnsmasqLeaseFileNameFunc networkDnsmasqLeaseFileName;
+
#endif /* __VIR_NETWORK__DRIVER_H */
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index 16d57a9c7..62de191ee 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -85,11 +85,24 @@ cleanup:
return result;
}
+static char *
+testDnsmasqLeaseFileName(const char *netname)
+{
+ char *leasefile;
+
+ virAsprintf(&leasefile, "/var/lib/libvirt/dnsmasq/%s.leases",
+ netname);
+
+ return leasefile;
+}
+
static int
mymain(void)
{
int ret = 0;
+ networkDnsmasqLeaseFileName = testDnsmasqLeaseFileName;
+
#define DO_TEST(name) \
if (virtTestRun("Network XML-2-Argv " name, \
1, testCompareXMLToArgvHelper, (name)) < 0) \