1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-10 05:17:59 +03:00

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.
This commit is contained in:
Matthias Bolte 2011-06-27 16:55:13 +02:00
parent 79306739db
commit 072ea80ff2
3 changed files with 22 additions and 1 deletions

View File

@ -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)
{

View File

@ -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 */

View File

@ -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) \