backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / virnwfilterbindingxml2xmltest.c
blobbba63e95647fe9a36269cab4e344357ee5e52f40
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 "virxml.h"
32 #include "virnwfilterbindingdef.h"
33 #include "testutilsqemu.h"
34 #include "virstring.h"
36 #define VIR_FROM_THIS VIR_FROM_NONE
38 static int
39 testCompareXMLToXMLFiles(const char *xml)
41 char *actual = NULL;
42 int ret = -1;
43 virNWFilterBindingDefPtr dev = NULL;
45 virResetLastError();
47 if (!(dev = virNWFilterBindingDefParseFile(xml)))
48 goto fail;
50 if (!(actual = virNWFilterBindingDefFormat(dev)))
51 goto fail;
53 if (virTestCompareToFile(actual, xml) < 0)
54 goto fail;
56 ret = 0;
58 fail:
59 VIR_FREE(actual);
60 virNWFilterBindingDefFree(dev);
61 return ret;
64 typedef struct test_parms {
65 const char *name;
66 } test_parms;
68 static int
69 testCompareXMLToXMLHelper(const void *data)
71 int result = -1;
72 const test_parms *tp = data;
73 char *xml = NULL;
75 if (virAsprintf(&xml, "%s/virnwfilterbindingxml2xmldata/%s.xml",
76 abs_srcdir, tp->name) < 0) {
77 goto cleanup;
80 result = testCompareXMLToXMLFiles(xml);
82 cleanup:
83 VIR_FREE(xml);
85 return result;
88 static int
89 mymain(void)
91 int ret = 0;
93 #define DO_TEST(NAME) \
94 do { \
95 test_parms tp = { \
96 .name = NAME, \
97 }; \
98 if (virTestRun("NWFilter XML-2-XML " NAME, \
99 testCompareXMLToXMLHelper, (&tp)) < 0) \
100 ret = -1; \
101 } while (0)
103 DO_TEST("simple");
104 DO_TEST("filter-vars");
106 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
109 VIR_TEST_MAIN(mymain)