Files
libvirt/tests/lxcxml2xmltest.c
T

107 lines
2.5 KiB
C
Raw Normal View History

2012-03-26 18:09:31 +01:00
#include <config.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
2013-04-16 21:41:44 +08:00
#include "testutils.h"
2012-03-26 18:09:31 +01:00
#ifdef WITH_LXC
# include "internal.h"
# include "lxc/lxc_conf.h"
# include "testutilslxc.h"
2013-06-07 17:10:28 +02:00
# define VIR_FROM_THIS VIR_FROM_NONE
2021-03-11 08:16:13 +01:00
static virLXCDriver *driver;
2012-03-26 18:09:31 +01:00
struct testInfo {
const char *name;
int different;
bool active_only;
unsigned int parse_flags;
2012-03-26 18:09:31 +01:00
};
static int
testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
2021-09-04 22:37:44 +02:00
g_autofree char *xml_in = NULL;
g_autofree char *xml_out = NULL;
2012-03-26 18:09:31 +01:00
int ret = -1;
xml_in = g_strdup_printf("%s/lxcxml2xmldata/lxc-%s.xml",
abs_srcdir, info->name);
xml_out = g_strdup_printf("%s/lxcxml2xmloutdata/lxc-%s.xml",
abs_srcdir, info->name);
2012-03-26 18:09:31 +01:00
ret = testCompareDomXML2XMLFiles(driver->caps, driver->xmlopt, xml_in,
2016-01-08 15:55:44 -05:00
info->different ? xml_out : xml_in,
info->active_only,
info->parse_flags,
TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
2012-03-26 18:09:31 +01:00
return ret;
}
static int
mymain(void)
{
int ret = 0;
if (!(driver = testLXCDriverInit()))
return EXIT_FAILURE;
# define DO_TEST_FULL(name, is_different, active, parse_flags) \
2017-11-03 13:09:47 +01:00
do { \
const struct testInfo info = {name, is_different, active, \
2017-11-03 13:09:47 +01:00
parse_flags}; \
if (virTestRun("LXC XML-2-XML " name, \
testCompareXMLToXMLHelper, &info) < 0) \
ret = -1; \
2012-03-26 18:09:31 +01:00
} while (0)
# define DO_TEST(name) \
DO_TEST_FULL(name, 0, true, 0)
2012-03-26 18:09:31 +01:00
# define DO_TEST_DIFFERENT(name) \
DO_TEST_FULL(name, 1, true, 0)
2012-03-26 18:09:31 +01:00
/* Unset or set all envvars here that are copied in lxcdBuildCommandLine
* using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
* values for these envvars */
2019-12-18 17:16:19 +00:00
g_setenv("PATH", "/bin", TRUE);
2012-03-26 18:09:31 +01:00
DO_TEST("systemd");
DO_TEST("hostdev");
DO_TEST("disk-formats");
DO_TEST_DIFFERENT("filesystem-ram");
DO_TEST("filesystem-root");
2014-01-10 10:40:01 -07:00
DO_TEST("idmap");
DO_TEST("capabilities");
2015-08-20 19:16:17 +05:30
DO_TEST("sharenet");
2016-05-13 13:20:54 -04:00
DO_TEST("ethernet");
DO_TEST("ethernet-hostip");
2017-05-30 17:03:58 +02:00
DO_TEST("initenv");
DO_TEST("initdir");
2017-06-06 10:54:16 +02:00
DO_TEST("inituser");
2012-03-26 18:09:31 +01:00
testLXCDriverFree(driver);
2012-03-26 18:09:31 +01:00
2014-03-17 10:38:38 +01:00
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
2012-03-26 18:09:31 +01:00
}
VIR_TEST_MAIN(mymain)
2012-03-26 18:09:31 +01:00
#else
int
main(void)
{
return EXIT_AM_SKIP;
}
#endif /* WITH_LXC */