summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2012-02-02 16:16:43 -0700
committerEric Blake <eblake@redhat.com>2012-02-03 10:41:46 -0700
commit8fe454ce90899945b1d16674668a0208657b6e61 (patch)
tree80cf4fbffcfab6e8d6ff43b1064e111cbafefdc9
parentbuild: prohibit raw malloc and free (diff)
downloadlibvirt-8fe454ce90899945b1d16674668a0208657b6e61.tar.gz
libvirt-8fe454ce90899945b1d16674668a0208657b6e61.tar.bz2
libvirt-8fe454ce90899945b1d16674668a0208657b6e61.zip
build: expand rule to cover testsuite
The bulk of this patch was done with: sed -i 's/\(\bfree *(/VIR_FREE(/g' tests/*.c followed by fixing the few compile errors that resulted. * cfg.mk (exclude_file_name_regexp--sc_prohibit_raw_allocation): Remove tests from exemption. * tests/testutils.h: Add common header. * tests/commandhelper.c: Fix offenders. * tests/cputest.c: Likewise. * tests/domainsnapshotxml2xmltest.c: Likewise. * tests/interfacexml2xmltest.c: Likewise. * tests/networkxml2argvtest.c: Likewise. * tests/networkxml2xmltest.c: Likewise. * tests/nodedevxml2xmltest.c: Likewise. * tests/nodeinfotest.c: Likewise. * tests/nwfilterxml2xmltest.c: Likewise. * tests/qemuargv2xmltest.c: Likewise. * tests/qemuxml2argvtest.c: Likewise. * tests/qemuxml2xmltest.c: Likewise. * tests/qemuxmlnstest.c: Likewise. * tests/qparamtest.c: Likewise. * tests/sexpr2xmltest.c: Likewise. * tests/storagepoolxml2xmltest.c: Likewise. * tests/storagevolxml2xmltest.c: Likewise. * tests/testutils.c: Likewise. * tests/virshtest.c: Likewise. * tests/xencapstest.c: Likewise. * tests/xmconfigtest.c: Likewise. * tests/xml2sexprtest.c: Likewise.
-rw-r--r--cfg.mk2
-rw-r--r--tests/commandhelper.c6
-rw-r--r--tests/cputest.c36
-rw-r--r--tests/domainsnapshotxml2xmltest.c6
-rw-r--r--tests/interfacexml2xmltest.c6
-rw-r--r--tests/networkxml2argvtest.c10
-rw-r--r--tests/networkxml2xmltest.c10
-rw-r--r--tests/nodedevxml2xmltest.c6
-rw-r--r--tests/nodeinfotest.c10
-rw-r--r--tests/nwfilterxml2xmltest.c10
-rw-r--r--tests/qemuargv2xmltest.c20
-rw-r--r--tests/qemuxml2argvtest.c28
-rw-r--r--tests/qemuxml2xmltest.c10
-rw-r--r--tests/qemuxmlnstest.c23
-rw-r--r--tests/qparamtest.c2
-rw-r--r--tests/sexpr2xmltest.c10
-rw-r--r--tests/storagepoolxml2xmltest.c10
-rw-r--r--tests/storagevolxml2xmltest.c14
-rw-r--r--tests/testutils.c9
-rw-r--r--tests/testutils.h3
-rw-r--r--tests/virshtest.c4
-rw-r--r--tests/xencapstest.c10
-rw-r--r--tests/xmconfigtest.c10
-rw-r--r--tests/xml2sexprtest.c10
24 files changed, 134 insertions, 131 deletions
diff --git a/cfg.mk b/cfg.mk
index f91c90c6e..f9c155834 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -744,7 +744,7 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = \
^((po|tests)/|docs/.*py$$|tools/(virsh|console)\.c$$)
exclude_file_name_regexp--sc_prohibit_raw_allocation = \
- ^(src/util/memory\.[ch]|(examples|python|tests)/.*)$$
+ ^(src/util/memory\.[ch]|(examples|python)/.*)$$
exclude_file_name_regexp--sc_prohibit_readlink = ^src/util/util\.c$$
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index cba208a20..71d93becf 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -1,7 +1,7 @@
/*
* commandhelper.c: Auxiliary program for commandtest
*
- * Copyright (C) 2010-2011 Red Hat, Inc.
+ * Copyright (C) 2010-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -42,8 +42,8 @@ static int envsort(const void *a, const void *b) {
char *akey = strndup(astr, aeq - astr);
char *bkey = strndup(bstr, beq - bstr);
int ret = strcmp(akey, bkey);
- free(akey);
- free(bkey);
+ VIR_FREE(akey);
+ VIR_FREE(bkey);
return ret;
}
diff --git a/tests/cputest.c b/tests/cputest.c
index 17e14f7d5..15614a785 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -104,7 +104,7 @@ cpuTestLoadXML(const char *arch, const char *name)
cleanup:
xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
- free(xml);
+ VIR_FREE(xml);
return cpu;
}
@@ -129,7 +129,7 @@ cpuTestLoadMultiXML(const char *arch,
goto error;
n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
- if (n <= 0 || !(cpus = calloc(n, sizeof(virCPUDefPtr))))
+ if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0))
goto error;
for (i = 0; i < n; i++) {
@@ -142,8 +142,8 @@ cpuTestLoadMultiXML(const char *arch,
*count = n;
cleanup:
- free(xml);
- free(nodes);
+ VIR_FREE(xml);
+ VIR_FREE(nodes);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
return cpus;
@@ -152,7 +152,7 @@ error:
if (cpus) {
for (i = 0; i < n; i++)
virCPUDefFree(cpus[i]);
- free(cpus);
+ VIR_FREE(cpus);
cpus = NULL;
}
goto cleanup;
@@ -190,9 +190,9 @@ cpuTestCompareXML(const char *arch,
ret = 0;
cleanup:
- free(xml);
- free(expected);
- free(actual);
+ VIR_FREE(xml);
+ VIR_FREE(expected);
+ VIR_FREE(actual);
return ret;
}
@@ -381,10 +381,10 @@ cleanup:
if (cpus) {
for (i = 0; i < ncpus; i++)
virCPUDefFree(cpus[i]);
- free(cpus);
+ VIR_FREE(cpus);
}
virCPUDefFree(baseline);
- free(result);
+ VIR_FREE(result);
return ret;
}
@@ -414,7 +414,7 @@ cpuTestUpdate(const void *arg)
cleanup:
virCPUDefFree(host);
virCPUDefFree(cpu);
- free(result);
+ VIR_FREE(result);
return ret;
}
@@ -473,11 +473,13 @@ static int
cpuTestRun(const char *name, const struct data *data)
{
char *label = NULL;
+ char *tmp;
if (virAsprintf(&label, "CPU %s(%s): %s", apis[data->api], data->arch, name) < 0)
return -1;
- free(virtTestLogContentAndReset());
+ tmp = virtTestLogContentAndReset();
+ VIR_FREE(tmp);
if (virtTestRun(label, 1, cpuTest[data->api], data) < 0) {
if (virTestGetDebug()) {
@@ -485,14 +487,14 @@ cpuTestRun(const char *name, const struct data *data)
if ((log = virtTestLogContentAndReset()) &&
strlen(log) > 0)
fprintf(stderr, "\n%s\n", log);
- free(log);
+ VIR_FREE(log);
}
- free(label);
+ VIR_FREE(label);
return -1;
}
- free(label);
+ VIR_FREE(label);
return 0;
}
@@ -513,7 +515,7 @@ mymain(void)
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
cpuMapOverride(map) < 0) {
- free(map);
+ VIR_FREE(map);
return EXIT_FAILURE;
}
@@ -632,7 +634,7 @@ mymain(void)
DO_TEST_GUESTDATA("x86", "host", "host+host-model-nofallback",
models, "Penryn", -1);
- free(map);
+ VIR_FREE(map);
return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
index 5c2e67023..978a2d441 100644
--- a/tests/domainsnapshotxml2xmltest.c
+++ b/tests/domainsnapshotxml2xmltest.c
@@ -51,8 +51,8 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
ret = 0;
fail:
- free(inXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(actual);
virDomainSnapshotDefFree(def);
return ret;
}
@@ -77,7 +77,7 @@ testCompareXMLToXMLHelper(const void *data)
ret = testCompareXMLToXMLFiles(xml_in, info->uuid, info->internal);
cleanup:
- free(xml_in);
+ VIR_FREE(xml_in);
return ret;
}
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c
index dc08ea794..c5c5415dd 100644
--- a/tests/interfacexml2xmltest.c
+++ b/tests/interfacexml2xmltest.c
@@ -39,8 +39,8 @@ testCompareXMLToXMLFiles(const char *xml)
ret = 0;
fail:
- free(xmlData);
- free(actual);
+ VIR_FREE(xmlData);
+ VIR_FREE(actual);
virInterfaceDefFree(dev);
return ret;
}
@@ -57,7 +57,7 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(xml);
- free (xml);
+ VIR_FREE(xml);
return result;
}
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index 5c6e29d2e..e000be93f 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -91,9 +91,9 @@ static int testCompareXMLToArgvFiles(const char *inxml, const char *outargv) {
ret = 0;
fail:
- free(inXmlData);
- free(outArgvData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outArgvData);
+ VIR_FREE(actual);
VIR_FREE(pidfile);
virCommandFree(cmd);
virNetworkObjFree(obj);
@@ -118,8 +118,8 @@ testCompareXMLToArgvHelper(const void *data)
result = testCompareXMLToArgvFiles(inxml, outxml);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index 6cb9d900a..77528a858 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -42,9 +42,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virNetworkDefFree(dev);
return ret;
}
@@ -72,8 +72,8 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml, info->flags);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index d0deaebb6..ad9316114 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -38,8 +38,8 @@ testCompareXMLToXMLFiles(const char *xml)
ret = 0;
fail:
- free(xmlData);
- free(actual);
+ VIR_FREE(xmlData);
+ VIR_FREE(actual);
virNodeDeviceDefFree(dev);
return ret;
}
@@ -56,7 +56,7 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(xml);
- free(xml);
+ VIR_FREE(xml);
return result;
}
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 0952a6b58..32d964ef4 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -81,8 +81,8 @@ linuxTestCompareFiles(const char *cpuinfofile,
ret = 0;
fail:
- free(expectData);
- free(actualData);
+ VIR_FREE(expectData);
+ VIR_FREE(actualData);
return ret;
}
@@ -117,9 +117,9 @@ linuxTestNodeInfo(const void *data)
result = linuxTestCompareFiles(cpuinfo, sysfs_cpuinfo, output);
cleanup:
- free(cpuinfo);
- free(output);
- free(sysfs_cpuinfo);
+ VIR_FREE(cpuinfo);
+ VIR_FREE(output);
+ VIR_FREE(sysfs_cpuinfo);
return result;
}
diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c
index 39afa5cc7..db7fe785c 100644
--- a/tests/nwfilterxml2xmltest.c
+++ b/tests/nwfilterxml2xmltest.c
@@ -55,9 +55,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virNWFilterDefFree(dev);
return ret;
}
@@ -85,8 +85,8 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 28434ffe4..51f5aed28 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -52,10 +52,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
if ((log = virtTestLogContentAndReset()) == NULL)
goto fail;
if ((*log != '\0') != expect_warning) {
- free(log);
+ VIR_FREE(log);
goto fail;
}
- free(log);
+ VIR_FREE(log);
if (!(actualxml = virDomainDefFormat(vmdef, 0)))
goto fail;
@@ -72,9 +72,9 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
fail:
- free(expectxml);
- free(actualxml);
- free(cmd);
+ VIR_FREE(expectxml);
+ VIR_FREE(actualxml);
+ VIR_FREE(cmd);
virDomainDefFree(vmdef);
return ret;
}
@@ -103,8 +103,8 @@ testCompareXMLToArgvHelper(const void *data)
result = testCompareXMLToArgvFiles(xml, args, !!info->extraFlags);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
@@ -192,8 +192,8 @@ mymain(void)
driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
DO_TEST("graphics-vnc-tls");
driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
- free(driver.vncSASLdir);
- free(driver.vncTLSx509certdir);
+ VIR_FREE(driver.vncSASLdir);
+ VIR_FREE(driver.vncTLSx509certdir);
driver.vncSASLdir = driver.vncTLSx509certdir = NULL;
DO_TEST("graphics-sdl");
@@ -238,7 +238,7 @@ mymain(void)
DO_TEST_FULL("qemu-ns-no-env", 1, NULL);
- free(driver.stateDir);
+ VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 23234f2a5..c8ce77fcf 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -120,7 +120,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
if (!(emulator = strdup(vmdef->emulator + 1)))
goto out;
- free(vmdef->emulator);
+ VIR_FREE(vmdef->emulator);
vmdef->emulator = NULL;
if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
abs_srcdir, emulator) < 0)
@@ -164,8 +164,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
qemuDomainPCIAddressSetFree(pciaddrs);
}
-
- free(virtTestLogContentAndReset());
+ log = virtTestLogContentAndReset();
+ VIR_FREE(log);
virResetLastError();
/* We do not call qemuCapsExtractVersionInfo() before calling
@@ -233,10 +233,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
out:
- free(log);
- free(emulator);
- free(expectargv);
- free(actualargv);
+ VIR_FREE(log);
+ VIR_FREE(emulator);
+ VIR_FREE(expectargv);
+ VIR_FREE(actualargv);
virCommandFree(cmd);
virDomainDefFree(vmdef);
virUnrefConnect(conn);
@@ -275,8 +275,8 @@ testCompareXMLToArgvHelper(const void *data)
info->expectFailure);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
@@ -307,7 +307,7 @@ mymain(void)
return EXIT_FAILURE;
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
cpuMapOverride(map) < 0) {
- free(map);
+ VIR_FREE(map);
return EXIT_FAILURE;
}
@@ -499,8 +499,8 @@ mymain(void)
driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
DO_TEST("graphics-vnc-tls", false, NONE);
driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
- free(driver.vncSASLdir);
- free(driver.vncTLSx509certdir);
+ VIR_FREE(driver.vncSASLdir);
+ VIR_FREE(driver.vncTLSx509certdir);
driver.vncSASLdir = driver.vncTLSx509certdir = NULL;
DO_TEST("graphics-sdl", false, NONE);
@@ -738,9 +738,9 @@ mymain(void)
DO_TEST("pseries-vio-address-clash", true, QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
- free(driver.stateDir);
+ VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
- free(map);
+ VIR_FREE(map);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 346e31093..b0f80d3ff 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -48,9 +48,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virDomainDefFree(def);
return ret;
}
@@ -81,8 +81,8 @@ testCompareXMLToXMLHelper(const void *data)
}
cleanup:
- free(xml_in);
- free(xml_out);
+ VIR_FREE(xml_in);
+ VIR_FREE(xml_out);
return ret;
}
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 0432cc42f..6ae588062 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -69,7 +69,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
if (!(emulator = strdup(vmdef->emulator + 1)))
goto fail;
- free(vmdef->emulator);
+ VIR_FREE(vmdef->emulator);
vmdef->emulator = NULL;
if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
abs_srcdir, emulator) < 0)
@@ -107,7 +107,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
}
- free(virtTestLogContentAndReset());
+ log = virtTestLogContentAndReset();
+ VIR_FREE(log);
virResetLastError();
/* We do not call qemuCapsExtractVersionInfo() before calling
@@ -159,10 +160,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
fail:
- free(log);
- free(emulator);
- free(expectargv);
- free(actualargv);
+ VIR_FREE(log);
+ VIR_FREE(emulator);
+ VIR_FREE(expectargv);
+ VIR_FREE(actualargv);
virCommandFree(cmd);
virDomainDefFree(vmdef);
virUnrefConnect(conn);
@@ -198,8 +199,8 @@ testCompareXMLToArgvHelper(const void *data)
info->json, info->expectError);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
@@ -231,7 +232,7 @@ mymain(void)
return EXIT_FAILURE;
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
cpuMapOverride(map) < 0) {
- free(map);
+ VIR_FREE(map);
return EXIT_FAILURE;
}
@@ -275,9 +276,9 @@ mymain(void)
DO_TEST("qemu-ns-commandline-ns0", false, NONE);
DO_TEST("qemu-ns-commandline-ns1", false, NONE);
- free(driver.stateDir);
+ VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
- free(map);
+ VIR_FREE(map);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/qparamtest.c b/tests/qparamtest.c
index 6dfac4361..78551c6e0 100644
--- a/tests/qparamtest.c
+++ b/tests/qparamtest.c
@@ -71,7 +71,7 @@ qparamFormatTest(const void *data)
ret = 0;
fail:
- free(output);
+ VIR_FREE(output);
free_qparam_set(actual);
return ret;
}
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
index 126a78c57..12d908610 100644
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -67,9 +67,9 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
ret = 0;
fail:
- free(xmlData);
- free(sexprData);
- free(gotxml);
+ VIR_FREE(xmlData);
+ VIR_FREE(sexprData);
+ VIR_FREE(gotxml);
virDomainDefFree(def);
if (conn)
virUnrefConnect(conn);
@@ -101,8 +101,8 @@ testCompareHelper(const void *data)
result = testCompareFiles(xml, args, info->version);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index f2c178065..886f310ed 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -41,9 +41,9 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
ret = 0;
fail:
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virStoragePoolDefFree(dev);
return ret;
}
@@ -65,8 +65,8 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml);
cleanup:
- free(inxml);
- free(outxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index c8dddbb71..742a02c90 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -49,10 +49,10 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
ret = 0;
fail:
- free(poolXmlData);
- free(inXmlData);
- free(outXmlData);
- free(actual);
+ VIR_FREE(poolXmlData);
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
virStoragePoolDefFree(pool);
virStorageVolDefFree(dev);
return ret;
@@ -84,9 +84,9 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(poolxml, inxml, outxml);
cleanup:
- free(poolxml);
- free(inxml);
- free(outxml);
+ VIR_FREE(poolxml);
+ VIR_FREE(inxml);
+ VIR_FREE(outxml);
return result;
}
diff --git a/tests/testutils.c b/tests/testutils.c
index fccea17cf..867854650 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -128,8 +128,7 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
fprintf(stderr, "%2d) %-65s ... ", testCounter, title);
}
- if (nloops > 1 && (ts = calloc(nloops,
- sizeof(double)))==NULL)
+ if (nloops > 1 && (VIR_ALLOC_N(ts, nloops) < 0))
return -1;
for (i=0; i < nloops; i++) {
@@ -181,7 +180,7 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
}
}
- free(ts);
+ VIR_FREE(ts);
return ret;
}
@@ -236,7 +235,7 @@ virtTestLoadFile(const char *file, char **buf)
if (ferror(fp)) {
fprintf (stderr, "%s: read failed: %s\n", file, strerror(errno));
VIR_FORCE_FCLOSE(fp);
- free(*buf);
+ VIR_FREE(*buf);
return -1;
}
}
@@ -512,7 +511,7 @@ virtTestErrorHook(int n, void *data ATTRIBUTE_UNUSED)
if (symbols[i])
fprintf(stderr, " TRACE: %s\n", symbols[i]);
}
- free(symbols);
+ VIR_FREE(symbols);
}
}
#endif
diff --git a/tests/testutils.h b/tests/testutils.h
index 03d8dc688..2fde1b575 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -1,7 +1,7 @@
/*
* utils.c: test utils
*
- * Copyright (C) 2005, 2008-2011 Red Hat, Inc.
+ * Copyright (C) 2005, 2008-2012 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -12,6 +12,7 @@
# define __VIT_TEST_UTILS_H__
# include <stdio.h>
+# include "memory.h"
# define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
# define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken */
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 9a39d46f5..6474c1922 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -76,7 +76,7 @@ testCompareOutputLit(const char *expectData,
result = 0;
cleanup:
- free(actualData);
+ VIR_FREE(actualData);
return result;
}
@@ -388,7 +388,7 @@ mymain(void)
# undef DO_TEST
- free(custom_uri);
+ VIR_FREE(custom_uri);
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/tests/xencapstest.c b/tests/xencapstest.c
index ca9385751..321f38a83 100644
--- a/tests/xencapstest.c
+++ b/tests/xencapstest.c
@@ -54,11 +54,11 @@ testCompareFiles(const char *hostmachine, const char *xml_rel,
ret = 0;
fail:
- free(expectxml);
- free(actualxml);
- free(xml);
- free(cpuinfo);
- free(capabilities);
+ VIR_FREE(expectxml);
+ VIR_FREE(actualxml);
+ VIR_FREE(xml);
+ VIR_FREE(cpuinfo);
+ VIR_FREE(capabilities);
VIR_FORCE_FCLOSE(fp1);
VIR_FORCE_FCLOSE(fp2);
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index c184b8df0..f1e028af3 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -87,9 +87,9 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
ret = 0;
fail:
- free(xmlData);
- free(xmcfgData);
- free(gotxmcfgData);
+ VIR_FREE(xmlData);
+ VIR_FREE(xmcfgData);
+ VIR_FREE(gotxmcfgData);
if (conf)
virConfFree(conf);
virDomainDefFree(def);
@@ -179,8 +179,8 @@ testCompareHelper(const void *data)
result = testCompareFormatXML(cfg, xml, info->version);
cleanup:
- free(xml);
- free(cfg);
+ VIR_FREE(xml);
+ VIR_FREE(cfg);
return result;
}
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
index 41712d39a..12d63b6ff 100644
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -46,9 +46,9 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
ret = 0;
fail:
- free(xmlData);
- free(sexprData);
- free(gotsexpr);
+ VIR_FREE(xmlData);
+ VIR_FREE(sexprData);
+ VIR_FREE(gotsexpr);
virDomainDefFree(def);
return ret;
@@ -79,8 +79,8 @@ testCompareHelper(const void *data)
result = testCompareFiles(xml, args, info->version);
cleanup:
- free(xml);
- free(args);
+ VIR_FREE(xml);
+ VIR_FREE(args);
return result;
}