mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: nwfilter: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
@@ -101,7 +101,7 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
|
||||
"ebtables --concurrent -t nat -X libvirt-I-vnet0\n"
|
||||
"ebtables --concurrent -t nat -F libvirt-O-vnet0\n"
|
||||
"ebtables --concurrent -t nat -X libvirt-O-vnet0\n";
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||
|
||||
@@ -119,7 +119,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -167,7 +166,7 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED)
|
||||
"ebtables --concurrent -t nat -L libvirt-P-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||
|
||||
@@ -185,7 +184,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -211,7 +209,7 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED)
|
||||
"ebtables --concurrent -t nat -X libvirt-J-vnet0\n"
|
||||
"ebtables --concurrent -t nat -F libvirt-P-vnet0\n"
|
||||
"ebtables --concurrent -t nat -X libvirt-P-vnet0\n";
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||
|
||||
@@ -229,7 +227,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -240,7 +237,7 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED)
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
const char *expected =
|
||||
VIR_NWFILTER_NEW_RULES_TEARDOWN;
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||
|
||||
@@ -258,7 +255,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -306,7 +302,7 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED)
|
||||
"ebtables --concurrent -t nat -A libvirt-J-vnet0 -j DROP\n"
|
||||
"ebtables --concurrent -t nat -A PREROUTING -i vnet0 -j libvirt-J-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n";
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
virMacAddr mac = { .addr = { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } };
|
||||
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||
@@ -325,7 +321,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -381,7 +376,7 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED)
|
||||
"ebtables --concurrent -t nat -A POSTROUTING -o vnet0 -j libvirt-P-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
virMacAddr mac = { .addr = { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } };
|
||||
const char *servers[] = { "192.168.122.1", "10.0.0.1", "10.0.0.2" };
|
||||
@@ -410,7 +405,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -460,7 +454,7 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED)
|
||||
"ebtables --concurrent -t nat -A POSTROUTING -o vnet0 -j libvirt-P-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-J-vnet0 libvirt-I-vnet0\n"
|
||||
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||
|
||||
@@ -478,7 +472,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(actual);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterIncludeDef *inc,
|
||||
{
|
||||
GHashTable *tmpvars = NULL;
|
||||
int ret = -1;
|
||||
char *xml;
|
||||
g_autofree char *xml = NULL;
|
||||
|
||||
xml = g_strdup_printf("%s/nwfilterxml2firewalldata/%s.xml", abs_srcdir,
|
||||
inc->filterref);
|
||||
@@ -249,7 +249,6 @@ virNWFilterIncludeDefToRuleInst(virNWFilterIncludeDef *inc,
|
||||
if (ret < 0)
|
||||
virNWFilterInstReset(inst);
|
||||
virHashFree(tmpvars);
|
||||
VIR_FREE(xml);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -350,7 +349,7 @@ static int testSetDefaultParameters(GHashTable *vars)
|
||||
static int testCompareXMLToArgvFiles(const char *xml,
|
||||
const char *cmdline)
|
||||
{
|
||||
char *actualargv = NULL;
|
||||
g_autofree char *actualargv = NULL;
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
GHashTable *vars = virHashNew(virNWFilterVarValueHashFree);
|
||||
virNWFilterInst inst;
|
||||
@@ -382,7 +381,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(actualargv);
|
||||
virNWFilterInstReset(&inst);
|
||||
virHashFree(vars);
|
||||
return ret;
|
||||
@@ -398,8 +396,8 @@ testCompareXMLToIPTablesHelper(const void *data)
|
||||
{
|
||||
int result = -1;
|
||||
const struct testInfo *info = data;
|
||||
char *xml = NULL;
|
||||
char *args = NULL;
|
||||
g_autofree char *xml = NULL;
|
||||
g_autofree char *args = NULL;
|
||||
|
||||
xml = g_strdup_printf("%s/nwfilterxml2firewalldata/%s.xml",
|
||||
abs_srcdir, info->name);
|
||||
@@ -408,8 +406,6 @@ testCompareXMLToIPTablesHelper(const void *data)
|
||||
|
||||
result = testCompareXMLToArgvFiles(xml, args);
|
||||
|
||||
VIR_FREE(xml);
|
||||
VIR_FREE(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ static int
|
||||
testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
|
||||
bool expect_error)
|
||||
{
|
||||
char *actual = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
int ret = -1;
|
||||
virNWFilterDef *dev = NULL;
|
||||
|
||||
@@ -44,7 +44,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
|
||||
ret = 0;
|
||||
|
||||
fail:
|
||||
VIR_FREE(actual);
|
||||
virNWFilterDefFree(dev);
|
||||
return ret;
|
||||
}
|
||||
@@ -59,17 +58,14 @@ testCompareXMLToXMLHelper(const void *data)
|
||||
{
|
||||
int result = -1;
|
||||
const test_parms *tp = data;
|
||||
char *inxml = NULL;
|
||||
char *outxml = NULL;
|
||||
g_autofree char *inxml = NULL;
|
||||
g_autofree char *outxml = NULL;
|
||||
|
||||
inxml = g_strdup_printf("%s/nwfilterxml2xmlin/%s.xml", abs_srcdir, tp->name);
|
||||
outxml = g_strdup_printf("%s/nwfilterxml2xmlout/%s.xml", abs_srcdir, tp->name);
|
||||
|
||||
result = testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning);
|
||||
|
||||
VIR_FREE(inxml);
|
||||
VIR_FREE(outxml);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user