2 * virnetworkportxml2xmltest.c: network port XML processing test suite
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/>.
25 #include <sys/types.h>
29 #include "testutils.h"
30 #include "virnetworkportdef.h"
31 #include "virstring.h"
33 #define VIR_FROM_THIS VIR_FROM_NONE
37 testCompareXMLToXMLFiles(const char *expected
)
41 virNetworkPortDefPtr dev
= NULL
;
43 if (!(dev
= virNetworkPortDefParseFile(expected
)))
46 if (!(actual
= virNetworkPortDefFormat(dev
)))
49 if (virTestCompareToFile(actual
, expected
) < 0)
55 virNetworkPortDefFree(dev
);
64 testCompareXMLToXMLHelper(const void *data
)
66 const struct testInfo
*info
= data
;
70 if (virAsprintf(&xml
, "%s/virnetworkportxml2xmldata/%s.xml",
71 abs_srcdir
, info
->name
) < 0)
74 ret
= testCompareXMLToXMLFiles(xml
);
87 #define DO_TEST(name) \
89 const struct testInfo info = {name}; \
90 if (virTestRun("virnetworkportdeftest " name, \
91 testCompareXMLToXMLHelper, &info) < 0) \
96 DO_TEST("plug-bridge");
97 DO_TEST("plug-bridge-mactbl");
98 DO_TEST("plug-direct");
99 DO_TEST("plug-hostdev-pci");
101 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
104 VIR_TEST_MAIN(mymain
)