docs: Reword virDomainGetEmulatorPinInfo description
[libvirt.git] / tests / virnwfilterbindingxml2xmltest.c
blobbde21968fe376b05eb50abcd432248871774d75c
1 /*
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/>.
22 #include <config.h>
24 #include <unistd.h>
26 #include <sys/types.h>
27 #include <fcntl.h>
29 #include "internal.h"
30 #include "testutils.h"
31 #include "virnwfilterbindingdef.h"
33 #define VIR_FROM_THIS VIR_FROM_NONE
35 static int
36 testCompareXMLToXMLFiles(const char *xml)
38 g_autofree char *actual = NULL;
39 int ret = -1;
40 virNWFilterBindingDef *dev = NULL;
42 virResetLastError();
44 if (!(dev = virNWFilterBindingDefParse(NULL, xml, 0)))
45 goto fail;
47 if (!(actual = virNWFilterBindingDefFormat(dev)))
48 goto fail;
50 if (virTestCompareToFile(actual, xml) < 0)
51 goto fail;
53 ret = 0;
55 fail:
56 virNWFilterBindingDefFree(dev);
57 return ret;
60 typedef struct test_parms {
61 const char *name;
62 } test_parms;
64 static int
65 testCompareXMLToXMLHelper(const void *data)
67 int result = -1;
68 const test_parms *tp = data;
69 g_autofree char *xml = NULL;
71 xml = g_strdup_printf("%s/virnwfilterbindingxml2xmldata/%s.xml", abs_srcdir,
72 tp->name);
74 result = testCompareXMLToXMLFiles(xml);
76 return result;
79 static int
80 mymain(void)
82 int ret = 0;
84 #define DO_TEST(NAME) \
85 do { \
86 test_parms tp = { \
87 .name = NAME, \
88 }; \
89 if (virTestRun("NWFilter XML-2-XML " NAME, \
90 testCompareXMLToXMLHelper, (&tp)) < 0) \
91 ret = -1; \
92 } while (0)
94 DO_TEST("simple");
95 DO_TEST("filter-vars");
97 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
100 VIR_TEST_MAIN(mymain)