2014-02-14 14:44:59 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "secret_conf.h"
|
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
|
|
|
static int
|
|
|
|
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
|
|
|
|
{
|
2021-09-04 18:34:55 +00:00
|
|
|
g_autofree char *actual = NULL;
|
|
|
|
g_autoptr(virSecretDef) secret = NULL;
|
2014-02-14 14:44:59 +00:00
|
|
|
|
2022-09-22 15:42:00 +00:00
|
|
|
if (!(secret = virSecretDefParse(NULL, inxml, 0)))
|
2021-09-04 18:34:55 +00:00
|
|
|
return -1;
|
2014-02-14 14:44:59 +00:00
|
|
|
|
|
|
|
if (!(actual = virSecretDefFormat(secret)))
|
2021-09-04 18:34:55 +00:00
|
|
|
return -1;
|
2014-02-14 14:44:59 +00:00
|
|
|
|
2016-05-26 15:01:53 +00:00
|
|
|
if (virTestCompareToFile(actual, outxml) < 0)
|
2021-09-04 18:34:55 +00:00
|
|
|
return -1;
|
2014-02-14 14:44:59 +00:00
|
|
|
|
2021-09-04 18:34:55 +00:00
|
|
|
return 0;
|
2014-02-14 14:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct testInfo {
|
|
|
|
const char *name;
|
|
|
|
bool different;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testCompareXMLToXMLHelper(const void *data)
|
|
|
|
{
|
|
|
|
int result = -1;
|
2021-09-04 20:37:44 +00:00
|
|
|
g_autofree char *inxml = NULL;
|
|
|
|
g_autofree char *outxml = NULL;
|
2014-02-14 14:44:59 +00:00
|
|
|
const struct testInfo *info = data;
|
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
inxml = g_strdup_printf("%s/secretxml2xmlin/%s.xml", abs_srcdir, info->name);
|
|
|
|
outxml = g_strdup_printf("%s/secretxml2xml%s/%s.xml",
|
|
|
|
abs_srcdir,
|
|
|
|
info->different ? "out" : "in",
|
|
|
|
info->name);
|
2014-02-14 14:44:59 +00:00
|
|
|
|
|
|
|
result = testCompareXMLToXMLFiles(inxml, outxml);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define DO_TEST(name) \
|
|
|
|
do { \
|
|
|
|
const struct testInfo info = {name, false}; \
|
|
|
|
if (virTestRun("Secret XML->XML " name, \
|
|
|
|
testCompareXMLToXMLHelper, &info) < 0) \
|
|
|
|
ret = -1; \
|
2014-02-14 14:44:59 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
DO_TEST("ephemeral-usage-volume");
|
|
|
|
DO_TEST("usage-volume");
|
|
|
|
DO_TEST("usage-ceph");
|
2021-01-06 16:19:03 +00:00
|
|
|
DO_TEST("usage-ceph-space");
|
2014-02-14 14:44:59 +00:00
|
|
|
DO_TEST("usage-iscsi");
|
2016-07-14 19:09:08 +00:00
|
|
|
DO_TEST("usage-tls");
|
2019-07-25 18:21:57 +00:00
|
|
|
DO_TEST("usage-vtpm");
|
2014-02-14 14:44:59 +00:00
|
|
|
|
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2017-03-29 14:45:42 +00:00
|
|
|
VIR_TEST_MAIN(mymain)
|