6 #include "storage/storage_util.h"
7 #include "testutilsqemu.h"
10 #define VIR_FROM_THIS VIR_FROM_NONE
13 # define MOUNT "/usr/bin/mount"
17 # define VGCHANGE "/usr/sbin/vgchange"
21 testCompareXMLToArgvFiles(bool shouldFail
,
26 virStoragePoolDefPtr def
= NULL
;
27 virStoragePoolObjPtr pool
= NULL
;
28 const char *defTypeStr
;
29 VIR_AUTOFREE(char *) actualCmdline
= NULL
;
30 VIR_AUTOFREE(char *) src
= NULL
;
31 VIR_AUTOPTR(virCommand
) cmd
= NULL
;
33 if (!(def
= virStoragePoolDefParseFile(poolxml
)))
35 defTypeStr
= virStoragePoolTypeToString(def
->type
);
37 switch ((virStoragePoolType
)def
->type
) {
38 case VIR_STORAGE_POOL_FS
:
39 case VIR_STORAGE_POOL_NETFS
:
40 if (!(pool
= virStoragePoolObjNew())) {
41 VIR_TEST_DEBUG("pool type '%s' alloc pool obj fails\n", defTypeStr
);
44 virStoragePoolObjSetDef(pool
, def
);
46 if (!(src
= virStorageBackendFileSystemGetPoolSource(pool
))) {
47 VIR_TEST_DEBUG("pool type '%s' has no pool source\n", defTypeStr
);
52 cmd
= virStorageBackendFileSystemMountCmd(MOUNT
, def
, src
);
56 case VIR_STORAGE_POOL_LOGICAL
:
57 cmd
= virStorageBackendLogicalChangeCmd(VGCHANGE
, def
, true);
60 case VIR_STORAGE_POOL_DIR
:
61 case VIR_STORAGE_POOL_DISK
:
62 case VIR_STORAGE_POOL_ISCSI
:
63 case VIR_STORAGE_POOL_ISCSI_DIRECT
:
64 case VIR_STORAGE_POOL_SCSI
:
65 case VIR_STORAGE_POOL_MPATH
:
66 case VIR_STORAGE_POOL_RBD
:
67 case VIR_STORAGE_POOL_SHEEPDOG
:
68 case VIR_STORAGE_POOL_GLUSTER
:
69 case VIR_STORAGE_POOL_ZFS
:
70 case VIR_STORAGE_POOL_VSTORAGE
:
71 case VIR_STORAGE_POOL_LAST
:
73 VIR_TEST_DEBUG("pool type '%s' has no xml2argv test\n", defTypeStr
);
77 if (!(actualCmdline
= virCommandToString(cmd
, false))) {
78 VIR_TEST_DEBUG("pool type '%s' failed to get commandline\n", defTypeStr
);
82 virTestClearCommandPath(actualCmdline
);
83 if (virTestCompareToFile(actualCmdline
, cmdline
) < 0)
89 virStoragePoolDefFree(def
);
90 virStoragePoolObjEndAPI(&pool
);
101 const char *platformSuffix
;
105 testCompareXMLToArgvHelper(const void *data
)
107 const struct testInfo
*info
= data
;
108 VIR_AUTOFREE(char *) poolxml
= NULL
;
109 VIR_AUTOFREE(char *) cmdline
= NULL
;
111 if (virAsprintf(&poolxml
, "%s/storagepoolxml2xmlin/%s.xml",
112 abs_srcdir
, info
->pool
) < 0)
115 if (virAsprintf(&cmdline
, "%s/storagepoolxml2argvdata/%s%s.argv",
116 abs_srcdir
, info
->pool
, info
->platformSuffix
) < 0 &&
120 return testCompareXMLToArgvFiles(info
->shouldFail
, poolxml
, cmdline
);
129 const char *platform
= "-linux";
130 #elif defined(__FreeBSD__)
131 const char *platform
= "-freebsd";
133 const char *platform
= "";
136 #define DO_TEST_FULL(shouldFail, pool, platformSuffix) \
138 struct testInfo info = { shouldFail, pool, platformSuffix }; \
139 if (virTestRun("Storage Pool XML-2-argv " pool, \
140 testCompareXMLToArgvHelper, &info) < 0) \
145 #define DO_TEST(pool, ...) \
146 DO_TEST_FULL(false, pool, "")
148 #define DO_TEST_FAIL(pool, ...) \
149 DO_TEST_FULL(true, pool, "")
151 #define DO_TEST_PLATFORM(pool, ...) \
152 DO_TEST_FULL(false, pool, platform)
154 if (storageRegisterAll() < 0)
157 DO_TEST_FAIL("pool-dir");
158 DO_TEST_FAIL("pool-dir-naming");
159 DO_TEST("pool-logical");
160 DO_TEST("pool-logical-nopath");
161 DO_TEST("pool-logical-create");
162 DO_TEST("pool-logical-noname");
163 DO_TEST_FAIL("pool-disk");
164 DO_TEST_FAIL("pool-disk-device-nopartsep");
165 DO_TEST_FAIL("pool-iscsi");
166 DO_TEST_FAIL("pool-iscsi-auth");
168 DO_TEST_PLATFORM("pool-fs");
169 DO_TEST_PLATFORM("pool-netfs");
170 DO_TEST_PLATFORM("pool-netfs-auto");
171 DO_TEST_PLATFORM("pool-netfs-protocol-ver");
173 DO_TEST_PLATFORM("pool-netfs-ns-mountopts");
175 DO_TEST_PLATFORM("pool-netfs-gluster");
176 DO_TEST_PLATFORM("pool-netfs-cifs");
178 DO_TEST_FAIL("pool-scsi");
179 DO_TEST_FAIL("pool-scsi-type-scsi-host");
180 DO_TEST_FAIL("pool-scsi-type-fc-host");
181 DO_TEST_FAIL("pool-scsi-type-fc-host-managed");
182 DO_TEST_FAIL("pool-mpath");
183 DO_TEST_FAIL("pool-iscsi-multiiqn");
184 DO_TEST_FAIL("pool-iscsi-vendor-product");
185 DO_TEST_FAIL("pool-sheepdog");
186 DO_TEST_FAIL("pool-gluster");
187 DO_TEST_FAIL("pool-gluster-sub");
188 DO_TEST_FAIL("pool-scsi-type-scsi-host-stable");
189 DO_TEST_FAIL("pool-zfs");
190 DO_TEST_FAIL("pool-zfs-sourcedev");
191 DO_TEST_FAIL("pool-rbd");
192 DO_TEST_FAIL("pool-vstorage");
193 DO_TEST_FAIL("pool-iscsi-direct-auth");
194 DO_TEST_FAIL("pool-iscsi-direct");
196 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
199 VIR_TEST_MAIN(mymain
)