2 * virnwfilterbindingxml2xmltest.c: network filter binding XML testing
4 * Copyright (C) 2018 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
26 #include <sys/types.h>
30 #include "testutils.h"
31 #include "virnwfilterbindingdef.h"
33 #define VIR_FROM_THIS VIR_FROM_NONE
36 testCompareXMLToXMLFiles(const char *xml
)
38 g_autofree
char *actual
= NULL
;
40 virNWFilterBindingDef
*dev
= NULL
;
44 if (!(dev
= virNWFilterBindingDefParse(NULL
, xml
, 0)))
47 if (!(actual
= virNWFilterBindingDefFormat(dev
)))
50 if (virTestCompareToFile(actual
, xml
) < 0)
56 virNWFilterBindingDefFree(dev
);
60 typedef struct test_parms
{
65 testCompareXMLToXMLHelper(const void *data
)
68 const test_parms
*tp
= data
;
69 g_autofree
char *xml
= NULL
;
71 xml
= g_strdup_printf("%s/virnwfilterbindingxml2xmldata/%s.xml", abs_srcdir
,
74 result
= testCompareXMLToXMLFiles(xml
);
84 #define DO_TEST(NAME) \
89 if (virTestRun("NWFilter XML-2-XML " NAME, \
90 testCompareXMLToXMLHelper, (&tp)) < 0) \
95 DO_TEST("filter-vars");
97 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
100 VIR_TEST_MAIN(mymain
)