2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library. If not, see
14 * <http://www.gnu.org/licenses/>.
20 #include "testutils.h"
24 #include "virstring.h"
26 #include "storage/storage_util.h"
28 #define VIR_FROM_THIS VIR_FROM_NONE
30 VIR_LOG_INIT("tests.storageutiltest");
33 struct testGlusterExtractPoolSourcesData
{
36 virStoragePoolType type
;
40 testGlusterExtractPoolSources(const void *opaque
)
42 const struct testGlusterExtractPoolSourcesData
*data
= opaque
;
43 virStoragePoolSourceList list
= { .type
= data
->type
,
49 VIR_AUTOFREE(char *) srcxmldata
= NULL
;
50 VIR_AUTOFREE(char *) actual
= NULL
;
52 if (virTestLoadFile(data
->srcxml
, &srcxmldata
) < 0)
55 if (virStorageUtilGlusterExtractPoolSources("testhost", srcxmldata
,
56 &list
, data
->type
) < 0)
59 if (!(actual
= virStoragePoolSourceListFormat(&list
)))
62 ret
= virTestCompareToFile(actual
, data
->dstxml
);
65 for (i
= 0; i
< list
.nsources
; i
++)
66 virStoragePoolSourceClear(&list
.sources
[i
]);
67 VIR_FREE(list
.sources
);
78 #define DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL(testname, sffx, pooltype) \
80 struct testGlusterExtractPoolSourcesData data; \
81 data.srcxml = abs_srcdir "/virstorageutildata/" \
82 "gluster-parse-" testname "-src.xml"; \
83 data.dstxml = abs_srcdir "/virstorageutildata/" \
84 "gluster-parse-" testname "-" sffx ".xml"; \
85 data.type = pooltype; \
86 if (virTestRun("gluster-parse-" testname "-" sffx, \
87 testGlusterExtractPoolSources, &data) < 0) \
91 #define DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE(testname) \
92 DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL(testname, "native", \
93 VIR_STORAGE_POOL_GLUSTER)
94 #define DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS(testname) \
95 DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL(testname, "netfs", \
96 VIR_STORAGE_POOL_NETFS)
98 DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("basic");
99 DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("basic");
100 DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE("multivol");
101 DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS("multivol");
103 #undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NATIVE
104 #undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_NETFS
105 #undef DO_TEST_GLUSTER_EXTRACT_POOL_SOURCES_FULL
107 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
110 VIR_TEST_MAIN(mymain
)