10 #include "storage_conf.h"
11 #include "testutilsqemu.h"
12 #include "virstring.h"
14 #define VIR_FROM_THIS VIR_FROM_NONE
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
)))
27 if (!(dev
= virStorageVolDefParseFile(pool
, inxml
, flags
)))
30 if (!(actual
= virStorageVolDefFormat(pool
, dev
)))
33 if (virTestCompareToFile(actual
, outxml
) < 0)
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)
61 return testCompareXMLToXMLFiles(poolxml
, inxml
, outxml
, info
->flags
);
70 #define DO_TEST_FULL(pool, name, flags) \
72 struct testInfo info = { pool, name, flags }; \
73 if (virTestRun("Storage Vol XML-2-XML " name, \
74 testCompareXMLToXMLHelper, &info) < 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
)