qemu: Validate spapr-vio addresses
[libvirt/ericb.git] / tests / secretxml2xmltest.c
blobfd937034248a9cd263b994b3e3ac3fad2086bd7b
1 #include <config.h>
4 #include "internal.h"
5 #include "testutils.h"
6 #include "secret_conf.h"
8 #define VIR_FROM_THIS VIR_FROM_NONE
10 static int
11 testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
13 char *actual = NULL;
14 int ret = -1;
15 virSecretDefPtr secret = NULL;
17 if (!(secret = virSecretDefParseFile(inxml)))
18 goto fail;
20 if (!(actual = virSecretDefFormat(secret)))
21 goto fail;
23 if (virTestCompareToFile(actual, outxml) < 0)
24 goto fail;
26 ret = 0;
28 fail:
29 VIR_FREE(actual);
30 virSecretDefFree(secret);
31 return ret;
34 struct testInfo {
35 const char *name;
36 bool different;
39 static int
40 testCompareXMLToXMLHelper(const void *data)
42 int result = -1;
43 char *inxml = NULL;
44 char *outxml = NULL;
45 const struct testInfo *info = data;
47 if (virAsprintf(&inxml, "%s/secretxml2xmlin/%s.xml",
48 abs_srcdir, info->name) < 0 ||
49 virAsprintf(&outxml, "%s/secretxml2xml%s/%s.xml",
50 abs_srcdir,
51 info->different ? "out" : "in",
52 info->name) < 0) {
53 goto cleanup;
56 result = testCompareXMLToXMLFiles(inxml, outxml);
58 cleanup:
59 VIR_FREE(inxml);
60 VIR_FREE(outxml);
62 return result;
65 static int
66 mymain(void)
68 int ret = 0;
70 #define DO_TEST(name) \
71 do { \
72 const struct testInfo info = {name, false}; \
73 if (virTestRun("Secret XML->XML " name, \
74 testCompareXMLToXMLHelper, &info) < 0) \
75 ret = -1; \
76 } while (0)
78 DO_TEST("ephemeral-usage-volume");
79 DO_TEST("usage-volume");
80 DO_TEST("usage-ceph");
81 DO_TEST("usage-iscsi");
82 DO_TEST("usage-tls");
84 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
87 VIR_TEST_MAIN(mymain)