backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / storagevolxml2xmltest.c
blob7c5d8e7e38988add0bce2da2469963ab33cb5e0f
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 "storage_conf.h"
11 #include "testutilsqemu.h"
12 #include "virstring.h"
14 #define VIR_FROM_THIS VIR_FROM_NONE
16 static int
17 testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
18 const char *outxml, unsigned int flags)
20 VIR_AUTOFREE(char *) actual = NULL;
21 VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
22 VIR_AUTOPTR(virStorageVolDef) dev = NULL;
24 if (!(pool = virStoragePoolDefParseFile(poolxml)))
25 return -1;
27 if (!(dev = virStorageVolDefParseFile(pool, inxml, flags)))
28 return -1;
30 if (!(actual = virStorageVolDefFormat(pool, dev)))
31 return -1;
33 if (virTestCompareToFile(actual, outxml) < 0)
34 return -1;
36 return 0;
39 struct testInfo {
40 const char *pool;
41 const char *name;
42 unsigned int flags;
45 static int
46 testCompareXMLToXMLHelper(const void *data)
48 const struct testInfo *info = data;
49 VIR_AUTOFREE(char *) poolxml = NULL;
50 VIR_AUTOFREE(char *) inxml = NULL;
51 VIR_AUTOFREE(char *) outxml = NULL;
53 if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
54 abs_srcdir, info->pool) < 0 ||
55 virAsprintf(&inxml, "%s/storagevolxml2xmlin/%s.xml",
56 abs_srcdir, info->name) < 0 ||
57 virAsprintf(&outxml, "%s/storagevolxml2xmlout/%s.xml",
58 abs_srcdir, info->name) < 0)
59 return -1;
61 return testCompareXMLToXMLFiles(poolxml, inxml, outxml, info->flags);
65 static int
66 mymain(void)
68 int ret = 0;
70 #define DO_TEST_FULL(pool, name, flags) \
71 do { \
72 struct testInfo info = { pool, name, flags }; \
73 if (virTestRun("Storage Vol XML-2-XML " name, \
74 testCompareXMLToXMLHelper, &info) < 0) \
75 ret = -1; \
76 } \
77 while (0);
79 #define DO_TEST(pool, name) DO_TEST_FULL(pool, name, 0)
81 DO_TEST("pool-dir", "vol-file");
82 DO_TEST("pool-dir", "vol-file-naming");
83 DO_TEST("pool-dir", "vol-file-backing");
84 DO_TEST("pool-dir", "vol-file-iso");
85 DO_TEST("pool-dir", "vol-qcow2");
86 DO_TEST("pool-dir", "vol-qcow2-1.1");
87 DO_TEST("pool-dir", "vol-qcow2-lazy");
88 DO_TEST("pool-dir", "vol-qcow2-0.10-lazy");
89 DO_TEST("pool-dir", "vol-qcow2-nobacking");
90 DO_TEST("pool-dir", "vol-qcow2-encryption");
91 DO_TEST("pool-dir", "vol-luks");
92 DO_TEST("pool-dir", "vol-luks-cipher");
93 DO_TEST("pool-disk", "vol-partition");
94 DO_TEST("pool-logical", "vol-logical");
95 DO_TEST("pool-logical", "vol-logical-backing");
96 DO_TEST("pool-sheepdog", "vol-sheepdog");
97 DO_TEST("pool-gluster", "vol-gluster-dir");
98 DO_TEST("pool-gluster", "vol-gluster-dir-neg-uid");
99 DO_TEST_FULL("pool-dir", "vol-qcow2-nocapacity",
100 VIR_VOL_XML_PARSE_NO_CAPACITY);
102 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
105 VIR_TEST_MAIN(mymain)