backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / nwfilterxml2xmltest.c
blob5fc9d19d4763db8bff6bcfa2394f9c7486c08aba
1 #include <config.h>
3 #include <unistd.h>
5 #include <sys/types.h>
6 #include <fcntl.h>
8 #include "internal.h"
9 #include "testutils.h"
10 #include "virxml.h"
11 #include "virthread.h"
12 #include "nwfilter_params.h"
13 #include "nwfilter_conf.h"
14 #include "testutilsqemu.h"
15 #include "virstring.h"
17 #define VIR_FROM_THIS VIR_FROM_NONE
19 static int
20 testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
21 bool expect_error)
23 char *actual = NULL;
24 int ret = -1;
25 virNWFilterDefPtr dev = NULL;
27 virResetLastError();
29 if (!(dev = virNWFilterDefParseFile(inxml))) {
30 if (expect_error) {
31 virResetLastError();
32 goto done;
34 goto fail;
37 if (!(actual = virNWFilterDefFormat(dev)))
38 goto fail;
40 if (virTestCompareToFile(actual, outxml) < 0)
41 goto fail;
43 done:
44 ret = 0;
46 fail:
47 VIR_FREE(actual);
48 virNWFilterDefFree(dev);
49 return ret;
52 typedef struct test_parms {
53 const char *name;
54 bool expect_warning;
55 } test_parms;
57 static int
58 testCompareXMLToXMLHelper(const void *data)
60 int result = -1;
61 const test_parms *tp = data;
62 char *inxml = NULL;
63 char *outxml = NULL;
65 if (virAsprintf(&inxml, "%s/nwfilterxml2xmlin/%s.xml",
66 abs_srcdir, tp->name) < 0 ||
67 virAsprintf(&outxml, "%s/nwfilterxml2xmlout/%s.xml",
68 abs_srcdir, tp->name) < 0) {
69 goto cleanup;
72 result = testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning);
74 cleanup:
75 VIR_FREE(inxml);
76 VIR_FREE(outxml);
78 return result;
81 static int
82 mymain(void)
84 int ret = 0;
86 #define DO_TEST(NAME, EXPECT_WARN) \
87 do { \
88 test_parms tp = { \
89 .name = NAME, \
90 .expect_warning = EXPECT_WARN, \
91 }; \
92 if (virTestRun("NWFilter XML-2-XML " NAME, \
93 testCompareXMLToXMLHelper, (&tp)) < 0) \
94 ret = -1; \
95 } while (0)
97 DO_TEST("mac-test", true);
98 DO_TEST("vlan-test", true);
99 DO_TEST("stp-test", false);
100 DO_TEST("arp-test", true);
101 DO_TEST("rarp-test", true);
102 DO_TEST("ip-test", true);
103 DO_TEST("ipv6-test", true);
105 DO_TEST("tcp-test", true);
106 DO_TEST("udp-test", true);
107 DO_TEST("icmp-test", true);
108 DO_TEST("igmp-test", false);
109 DO_TEST("sctp-test", true);
110 DO_TEST("udplite-test", false);
111 DO_TEST("esp-test", false);
112 DO_TEST("ah-test", false);
113 DO_TEST("all-test", false);
115 DO_TEST("tcp-ipv6-test", true);
116 DO_TEST("udp-ipv6-test", true);
117 DO_TEST("icmpv6-test", true);
118 DO_TEST("sctp-ipv6-test", true);
119 DO_TEST("udplite-ipv6-test", true);
120 DO_TEST("esp-ipv6-test", true);
121 DO_TEST("ah-ipv6-test", true);
122 DO_TEST("all-ipv6-test", true);
124 DO_TEST("ref-test", false);
125 DO_TEST("ref-rule-test", false);
126 DO_TEST("ipt-no-macspoof-test", false);
127 DO_TEST("icmp-direction-test", false);
128 DO_TEST("icmp-direction2-test", false);
129 DO_TEST("icmp-direction3-test", false);
131 DO_TEST("conntrack-test", false);
133 DO_TEST("hex-data-test", true);
135 DO_TEST("comment-test", true);
137 DO_TEST("example-1", false);
138 DO_TEST("example-2", false);
140 DO_TEST("chain_prefixtest1", true); /* derived from arp-test */
142 DO_TEST("attr-value-test", false);
143 DO_TEST("iter-test1", false);
144 DO_TEST("iter-test2", false);
145 DO_TEST("iter-test3", false);
147 DO_TEST("ipset-test", false);
149 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
152 VIR_TEST_MAIN(mymain)