2018-12-04 11:16:23 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "testutils.h"
|
|
|
|
#include "storage/storage_util.h"
|
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2018-12-13 16:11:18 +00:00
|
|
|
#ifndef MOUNT
|
|
|
|
# define MOUNT "/usr/bin/mount"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VGCHANGE
|
|
|
|
# define VGCHANGE "/usr/sbin/vgchange"
|
|
|
|
#endif
|
2018-12-04 11:16:23 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
testCompareXMLToArgvFiles(bool shouldFail,
|
|
|
|
const char *poolxml,
|
|
|
|
const char *cmdline)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virStoragePoolDef *def = NULL;
|
|
|
|
virStoragePoolObj *pool = NULL;
|
2019-02-08 15:43:23 +00:00
|
|
|
const char *defTypeStr;
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *actualCmdline = NULL;
|
|
|
|
g_autofree char *src = NULL;
|
2019-10-15 12:47:50 +00:00
|
|
|
g_autoptr(virCommand) cmd = NULL;
|
2018-12-04 11:16:23 +00:00
|
|
|
|
2022-09-22 15:08:16 +00:00
|
|
|
if (!(def = virStoragePoolDefParse(NULL, poolxml, 0)))
|
2018-12-04 11:16:23 +00:00
|
|
|
goto cleanup;
|
2019-02-08 15:43:23 +00:00
|
|
|
defTypeStr = virStoragePoolTypeToString(def->type);
|
2018-12-04 11:16:23 +00:00
|
|
|
|
|
|
|
switch ((virStoragePoolType)def->type) {
|
|
|
|
case VIR_STORAGE_POOL_FS:
|
|
|
|
case VIR_STORAGE_POOL_NETFS:
|
|
|
|
if (!(pool = virStoragePoolObjNew())) {
|
2019-05-03 08:31:02 +00:00
|
|
|
VIR_TEST_DEBUG("pool type '%s' alloc pool obj fails", defTypeStr);
|
2018-12-04 11:16:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
virStoragePoolObjSetDef(pool, def);
|
|
|
|
|
|
|
|
if (!(src = virStorageBackendFileSystemGetPoolSource(pool))) {
|
2019-05-03 08:31:02 +00:00
|
|
|
VIR_TEST_DEBUG("pool type '%s' has no pool source", defTypeStr);
|
2019-02-08 15:43:23 +00:00
|
|
|
def = NULL;
|
2018-12-04 11:16:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2018-12-13 16:11:18 +00:00
|
|
|
cmd = virStorageBackendFileSystemMountCmd(MOUNT, def, src);
|
2019-02-08 15:43:23 +00:00
|
|
|
def = NULL;
|
2018-12-04 11:16:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_STORAGE_POOL_LOGICAL:
|
2018-12-13 16:11:18 +00:00
|
|
|
cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, true);
|
2018-12-04 16:12:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_STORAGE_POOL_DIR:
|
2018-12-04 11:16:23 +00:00
|
|
|
case VIR_STORAGE_POOL_DISK:
|
|
|
|
case VIR_STORAGE_POOL_ISCSI:
|
|
|
|
case VIR_STORAGE_POOL_ISCSI_DIRECT:
|
|
|
|
case VIR_STORAGE_POOL_SCSI:
|
|
|
|
case VIR_STORAGE_POOL_MPATH:
|
|
|
|
case VIR_STORAGE_POOL_RBD:
|
|
|
|
case VIR_STORAGE_POOL_SHEEPDOG:
|
|
|
|
case VIR_STORAGE_POOL_GLUSTER:
|
|
|
|
case VIR_STORAGE_POOL_ZFS:
|
|
|
|
case VIR_STORAGE_POOL_VSTORAGE:
|
|
|
|
case VIR_STORAGE_POOL_LAST:
|
|
|
|
default:
|
2019-05-03 08:31:02 +00:00
|
|
|
VIR_TEST_DEBUG("pool type '%s' has no xml2argv test", defTypeStr);
|
2018-12-04 11:16:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
};
|
|
|
|
|
2021-03-31 08:46:36 +00:00
|
|
|
if (!(actualCmdline = virCommandToStringFull(cmd, true, true))) {
|
2019-05-03 08:31:02 +00:00
|
|
|
VIR_TEST_DEBUG("pool type '%s' failed to get commandline", defTypeStr);
|
2018-12-04 11:16:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2021-03-31 08:46:36 +00:00
|
|
|
if (virTestCompareToFileFull(actualCmdline, cmdline, false) < 0)
|
2018-12-04 11:16:23 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2019-02-08 15:43:23 +00:00
|
|
|
virStoragePoolDefFree(def);
|
2018-12-04 11:16:23 +00:00
|
|
|
virStoragePoolObjEndAPI(&pool);
|
|
|
|
if (shouldFail) {
|
|
|
|
virResetLastError();
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct testInfo {
|
|
|
|
bool shouldFail;
|
|
|
|
const char *pool;
|
2019-01-31 14:10:58 +00:00
|
|
|
const char *platformSuffix;
|
2018-12-04 11:16:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
testCompareXMLToArgvHelper(const void *data)
|
|
|
|
{
|
|
|
|
const struct testInfo *info = data;
|
2019-10-15 13:16:31 +00:00
|
|
|
g_autofree char *poolxml = NULL;
|
|
|
|
g_autofree char *cmdline = NULL;
|
2018-12-04 11:16:23 +00:00
|
|
|
|
2019-10-22 13:26:14 +00:00
|
|
|
poolxml = g_strdup_printf("%s/storagepoolxml2xmlin/%s.xml", abs_srcdir,
|
|
|
|
info->pool);
|
|
|
|
|
|
|
|
cmdline = g_strdup_printf("%s/storagepoolxml2argvdata/%s%s.argv",
|
|
|
|
abs_srcdir, info->pool, info->platformSuffix);
|
2018-12-04 11:16:23 +00:00
|
|
|
|
2019-02-01 17:03:16 +00:00
|
|
|
return testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdline);
|
2018-12-04 11:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2019-01-31 14:40:22 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
const char *platform = "-linux";
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
const char *platform = "-freebsd";
|
|
|
|
#else
|
|
|
|
const char *platform = "";
|
|
|
|
#endif
|
2018-12-04 11:16:23 +00:00
|
|
|
|
2019-01-31 14:10:58 +00:00
|
|
|
#define DO_TEST_FULL(shouldFail, pool, platformSuffix) \
|
2018-12-04 11:16:23 +00:00
|
|
|
do { \
|
2019-01-31 14:10:58 +00:00
|
|
|
struct testInfo info = { shouldFail, pool, platformSuffix }; \
|
2018-12-04 11:16:23 +00:00
|
|
|
if (virTestRun("Storage Pool XML-2-argv " pool, \
|
|
|
|
testCompareXMLToArgvHelper, &info) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} \
|
|
|
|
while (0);
|
|
|
|
|
|
|
|
#define DO_TEST(pool, ...) \
|
2019-01-31 14:10:58 +00:00
|
|
|
DO_TEST_FULL(false, pool, "")
|
2018-12-04 11:16:23 +00:00
|
|
|
|
|
|
|
#define DO_TEST_FAIL(pool, ...) \
|
2019-01-31 14:10:58 +00:00
|
|
|
DO_TEST_FULL(true, pool, "")
|
2019-01-11 15:53:35 +00:00
|
|
|
|
2019-01-31 14:40:22 +00:00
|
|
|
#define DO_TEST_PLATFORM(pool, ...) \
|
|
|
|
DO_TEST_FULL(false, pool, platform)
|
2018-12-04 11:16:23 +00:00
|
|
|
|
2018-12-12 22:41:14 +00:00
|
|
|
if (storageRegisterAll() < 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2018-12-04 11:16:23 +00:00
|
|
|
DO_TEST_FAIL("pool-dir");
|
|
|
|
DO_TEST_FAIL("pool-dir-naming");
|
2018-12-04 16:12:37 +00:00
|
|
|
DO_TEST("pool-logical");
|
|
|
|
DO_TEST("pool-logical-nopath");
|
|
|
|
DO_TEST("pool-logical-create");
|
|
|
|
DO_TEST("pool-logical-noname");
|
2018-12-04 11:16:23 +00:00
|
|
|
DO_TEST_FAIL("pool-disk");
|
|
|
|
DO_TEST_FAIL("pool-disk-device-nopartsep");
|
|
|
|
DO_TEST_FAIL("pool-iscsi");
|
|
|
|
DO_TEST_FAIL("pool-iscsi-auth");
|
2019-01-31 14:40:22 +00:00
|
|
|
|
|
|
|
DO_TEST_PLATFORM("pool-fs");
|
|
|
|
DO_TEST_PLATFORM("pool-netfs");
|
|
|
|
DO_TEST_PLATFORM("pool-netfs-auto");
|
|
|
|
DO_TEST_PLATFORM("pool-netfs-protocol-ver");
|
2019-01-31 14:43:40 +00:00
|
|
|
#if WITH_STORAGE_FS
|
2019-01-31 14:40:22 +00:00
|
|
|
DO_TEST_PLATFORM("pool-netfs-ns-mountopts");
|
2019-01-31 14:43:40 +00:00
|
|
|
#endif
|
2019-01-31 14:40:22 +00:00
|
|
|
DO_TEST_PLATFORM("pool-netfs-gluster");
|
|
|
|
DO_TEST_PLATFORM("pool-netfs-cifs");
|
|
|
|
|
2018-12-04 11:16:23 +00:00
|
|
|
DO_TEST_FAIL("pool-scsi");
|
|
|
|
DO_TEST_FAIL("pool-scsi-type-scsi-host");
|
|
|
|
DO_TEST_FAIL("pool-scsi-type-fc-host");
|
|
|
|
DO_TEST_FAIL("pool-scsi-type-fc-host-managed");
|
|
|
|
DO_TEST_FAIL("pool-mpath");
|
|
|
|
DO_TEST_FAIL("pool-iscsi-multiiqn");
|
|
|
|
DO_TEST_FAIL("pool-iscsi-vendor-product");
|
|
|
|
DO_TEST_FAIL("pool-gluster");
|
|
|
|
DO_TEST_FAIL("pool-gluster-sub");
|
|
|
|
DO_TEST_FAIL("pool-scsi-type-scsi-host-stable");
|
|
|
|
DO_TEST_FAIL("pool-zfs");
|
|
|
|
DO_TEST_FAIL("pool-zfs-sourcedev");
|
|
|
|
DO_TEST_FAIL("pool-rbd");
|
|
|
|
DO_TEST_FAIL("pool-vstorage");
|
|
|
|
DO_TEST_FAIL("pool-iscsi-direct-auth");
|
|
|
|
DO_TEST_FAIL("pool-iscsi-direct");
|
|
|
|
|
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_TEST_MAIN(mymain)
|