|
|
0a7476 |
From c549a110d3705473ab4435bd164a8e48d5da64a1 Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <c549a110d3705473ab4435bd164a8e48d5da64a1@dist-git>
|
|
|
0a7476 |
From: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
Date: Wed, 3 Apr 2019 09:12:16 -0400
|
|
|
0a7476 |
Subject: [PATCH] tests: Introduce tests for storage pool xml to argv checks
|
|
|
0a7476 |
MIME-Version: 1.0
|
|
|
0a7476 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0a7476 |
Content-Transfer-Encoding: 8bit
|
|
|
0a7476 |
|
|
|
0a7476 |
https://bugzilla.redhat.com/show_bug.cgi?id=1584663
|
|
|
0a7476 |
|
|
|
0a7476 |
Similar to qemuxml2argv and storagevolxml2argv, let's create some
|
|
|
0a7476 |
tests to ensure that the XML generates a consistent command line.
|
|
|
0a7476 |
|
|
|
0a7476 |
Using the same list of pools as storagepoolxml2xmltest, start with
|
|
|
0a7476 |
the file system tests (fs, netfs, netfs-cifs, netfs-gluster).
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit f2f84b4d4ab289e736e367d2867cf945d17d0b20)
|
|
|
0a7476 |
|
|
|
0a7476 |
Resolved some build issues:
|
|
|
0a7476 |
|
|
|
0a7476 |
* Removed the VIR_FREE defs and used the VIR_FREE for @src. Turns out
|
|
|
0a7476 |
it was unnecessary for @actualCmdline and was removed in commit
|
|
|
0a7476 |
5f02df444beea79ef7c94f923c0c36135102d562
|
|
|
0a7476 |
|
|
|
0a7476 |
* Removed VIR_STORAGE_POOL_ISCSI_DIRECT from switch since it's not
|
|
|
0a7476 |
a downstream symbol/option
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
Message-Id: <20190403131219.16385-5-jferlan@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
tests/Makefile.am | 12 ++
|
|
|
0a7476 |
tests/storagepoolxml2argvdata/pool-fs.argv | 1 +
|
|
|
0a7476 |
.../pool-netfs-cifs.argv | 1 +
|
|
|
0a7476 |
.../pool-netfs-gluster.argv | 1 +
|
|
|
0a7476 |
tests/storagepoolxml2argvdata/pool-netfs.argv | 1 +
|
|
|
0a7476 |
tests/storagepoolxml2argvtest.c | 172 ++++++++++++++++++
|
|
|
0a7476 |
6 files changed, 188 insertions(+)
|
|
|
0a7476 |
create mode 100644 tests/storagepoolxml2argvdata/pool-fs.argv
|
|
|
0a7476 |
create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-cifs.argv
|
|
|
0a7476 |
create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-gluster.argv
|
|
|
0a7476 |
create mode 100644 tests/storagepoolxml2argvdata/pool-netfs.argv
|
|
|
0a7476 |
create mode 100644 tests/storagepoolxml2argvtest.c
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
0a7476 |
index a4ebed489a..858076df7b 100644
|
|
|
0a7476 |
--- a/tests/Makefile.am
|
|
|
0a7476 |
+++ b/tests/Makefile.am
|
|
|
0a7476 |
@@ -141,6 +141,7 @@ EXTRA_DIST = \
|
|
|
0a7476 |
storagepoolschemadata \
|
|
|
0a7476 |
storagepoolxml2xmlin \
|
|
|
0a7476 |
storagepoolxml2xmlout \
|
|
|
0a7476 |
+ storagepoolxml2argvdata \
|
|
|
0a7476 |
storagevolschemadata \
|
|
|
0a7476 |
storagevolxml2argvdata \
|
|
|
0a7476 |
storagevolxml2xmlin \
|
|
|
0a7476 |
@@ -363,6 +364,7 @@ endif WITH_NWFILTER
|
|
|
0a7476 |
|
|
|
0a7476 |
if WITH_STORAGE
|
|
|
0a7476 |
test_programs += storagevolxml2argvtest
|
|
|
0a7476 |
+test_programs += storagepoolxml2argvtest
|
|
|
0a7476 |
test_programs += virstorageutiltest
|
|
|
0a7476 |
endif WITH_STORAGE
|
|
|
0a7476 |
|
|
|
0a7476 |
@@ -901,6 +903,16 @@ storagevolxml2argvtest_LDADD = \
|
|
|
0a7476 |
../src/libvirt_util.la \
|
|
|
0a7476 |
$(LDADDS)
|
|
|
0a7476 |
|
|
|
0a7476 |
+storagepoolxml2argvtest_SOURCES = \
|
|
|
0a7476 |
+ storagepoolxml2argvtest.c \
|
|
|
0a7476 |
+ testutils.c testutils.h
|
|
|
0a7476 |
+storagepoolxml2argvtest_LDADD = \
|
|
|
0a7476 |
+ $(LIBXML_LIBS) \
|
|
|
0a7476 |
+ ../src/libvirt_driver_storage_impl.la \
|
|
|
0a7476 |
+ ../src/libvirt_conf.la \
|
|
|
0a7476 |
+ ../src/libvirt_util.la \
|
|
|
0a7476 |
+ $(LDADDS)
|
|
|
0a7476 |
+
|
|
|
0a7476 |
else ! WITH_STORAGE
|
|
|
0a7476 |
EXTRA_DIST += storagevolxml2argvtest.c
|
|
|
0a7476 |
EXTRA_DIST += virstorageutiltest.c
|
|
|
0a7476 |
diff --git a/tests/storagepoolxml2argvdata/pool-fs.argv b/tests/storagepoolxml2argvdata/pool-fs.argv
|
|
|
0a7476 |
new file mode 100644
|
|
|
0a7476 |
index 0000000000..537ce4cee5
|
|
|
0a7476 |
--- /dev/null
|
|
|
0a7476 |
+++ b/tests/storagepoolxml2argvdata/pool-fs.argv
|
|
|
0a7476 |
@@ -0,0 +1 @@
|
|
|
0a7476 |
+mount -t ext3 /dev/sda6 /mnt
|
|
|
0a7476 |
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-cifs.argv b/tests/storagepoolxml2argvdata/pool-netfs-cifs.argv
|
|
|
0a7476 |
new file mode 100644
|
|
|
0a7476 |
index 0000000000..2fef6f5782
|
|
|
0a7476 |
--- /dev/null
|
|
|
0a7476 |
+++ b/tests/storagepoolxml2argvdata/pool-netfs-cifs.argv
|
|
|
0a7476 |
@@ -0,0 +1 @@
|
|
|
0a7476 |
+mount -t cifs //example.com/samba_share /mnt/cifs -o guest
|
|
|
0a7476 |
diff --git a/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv b/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv
|
|
|
0a7476 |
new file mode 100644
|
|
|
0a7476 |
index 0000000000..4303d514ef
|
|
|
0a7476 |
--- /dev/null
|
|
|
0a7476 |
+++ b/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv
|
|
|
0a7476 |
@@ -0,0 +1 @@
|
|
|
0a7476 |
+mount -t glusterfs example.com:/volume -o direct-io-mode=1 /mnt/gluster
|
|
|
0a7476 |
diff --git a/tests/storagepoolxml2argvdata/pool-netfs.argv b/tests/storagepoolxml2argvdata/pool-netfs.argv
|
|
|
0a7476 |
new file mode 100644
|
|
|
0a7476 |
index 0000000000..04127c5087
|
|
|
0a7476 |
--- /dev/null
|
|
|
0a7476 |
+++ b/tests/storagepoolxml2argvdata/pool-netfs.argv
|
|
|
0a7476 |
@@ -0,0 +1 @@
|
|
|
0a7476 |
+mount -t nfs localhost:/var/lib/libvirt/images /mnt
|
|
|
0a7476 |
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
|
|
|
0a7476 |
new file mode 100644
|
|
|
0a7476 |
index 0000000000..54bc07b4e1
|
|
|
0a7476 |
--- /dev/null
|
|
|
0a7476 |
+++ b/tests/storagepoolxml2argvtest.c
|
|
|
0a7476 |
@@ -0,0 +1,172 @@
|
|
|
0a7476 |
+#include <config.h>
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+#include "internal.h"
|
|
|
0a7476 |
+#include "testutils.h"
|
|
|
0a7476 |
+#include "datatypes.h"
|
|
|
0a7476 |
+#include "storage/storage_util.h"
|
|
|
0a7476 |
+#include "testutilsqemu.h"
|
|
|
0a7476 |
+#include "virstring.h"
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+static int
|
|
|
0a7476 |
+testCompareXMLToArgvFiles(bool shouldFail,
|
|
|
0a7476 |
+ const char *poolxml,
|
|
|
0a7476 |
+ const char *cmdline)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ char *actualCmdline = NULL;
|
|
|
0a7476 |
+ char *src = NULL;
|
|
|
0a7476 |
+ int ret = -1;
|
|
|
0a7476 |
+ virCommandPtr cmd = NULL;
|
|
|
0a7476 |
+ virStoragePoolDefPtr def = NULL;
|
|
|
0a7476 |
+ virStoragePoolObjPtr pool = NULL;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (!(def = virStoragePoolDefParseFile(poolxml)))
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ switch ((virStoragePoolType)def->type) {
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_FS:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_NETFS:
|
|
|
0a7476 |
+ if (!(pool = virStoragePoolObjNew())) {
|
|
|
0a7476 |
+ VIR_TEST_DEBUG("pool type %d alloc pool obj fails\n", def->type);
|
|
|
0a7476 |
+ virStoragePoolDefFree(def);
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+ virStoragePoolObjSetDef(pool, def);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (!(src = virStorageBackendFileSystemGetPoolSource(pool))) {
|
|
|
0a7476 |
+ VIR_TEST_DEBUG("pool type %d has no pool source\n", def->type);
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ cmd = virStorageBackendFileSystemMountCmd(def, src);
|
|
|
0a7476 |
+ break;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_DIR:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_LOGICAL:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_DISK:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_ISCSI:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_SCSI:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_MPATH:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_RBD:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_SHEEPDOG:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_GLUSTER:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_ZFS:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_VSTORAGE:
|
|
|
0a7476 |
+ case VIR_STORAGE_POOL_LAST:
|
|
|
0a7476 |
+ default:
|
|
|
0a7476 |
+ VIR_TEST_DEBUG("pool type %d has no xml2argv test\n", def->type);
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ };
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (!(actualCmdline = virCommandToString(cmd))) {
|
|
|
0a7476 |
+ VIR_TEST_DEBUG("pool type %d failed to get commandline\n", def->type);
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ virTestClearCommandPath(actualCmdline);
|
|
|
0a7476 |
+ if (virTestCompareToFile(actualCmdline, cmdline) < 0)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ ret = 0;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ cleanup:
|
|
|
0a7476 |
+ virCommandFree(cmd);
|
|
|
0a7476 |
+ VIR_FREE(src);
|
|
|
0a7476 |
+ VIR_FREE(actualCmdline);
|
|
|
0a7476 |
+ virStoragePoolObjEndAPI(&pool);
|
|
|
0a7476 |
+ if (shouldFail) {
|
|
|
0a7476 |
+ virResetLastError();
|
|
|
0a7476 |
+ ret = 0;
|
|
|
0a7476 |
+ }
|
|
|
0a7476 |
+ return ret;
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+struct testInfo {
|
|
|
0a7476 |
+ bool shouldFail;
|
|
|
0a7476 |
+ const char *pool;
|
|
|
0a7476 |
+};
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+static int
|
|
|
0a7476 |
+testCompareXMLToArgvHelper(const void *data)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ int result = -1;
|
|
|
0a7476 |
+ const struct testInfo *info = data;
|
|
|
0a7476 |
+ char *poolxml = NULL;
|
|
|
0a7476 |
+ char *cmdline = NULL;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
|
|
0a7476 |
+ abs_srcdir, info->pool) < 0)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s.argv",
|
|
|
0a7476 |
+ abs_srcdir, info->pool) < 0 && !info->shouldFail)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ result = testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdline);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ cleanup:
|
|
|
0a7476 |
+ VIR_FREE(poolxml);
|
|
|
0a7476 |
+ VIR_FREE(cmdline);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ return result;
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+static int
|
|
|
0a7476 |
+mymain(void)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ int ret = 0;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+#define DO_TEST_FULL(shouldFail, pool) \
|
|
|
0a7476 |
+ do { \
|
|
|
0a7476 |
+ struct testInfo info = { shouldFail, pool }; \
|
|
|
0a7476 |
+ if (virTestRun("Storage Pool XML-2-argv " pool, \
|
|
|
0a7476 |
+ testCompareXMLToArgvHelper, &info) < 0) \
|
|
|
0a7476 |
+ ret = -1; \
|
|
|
0a7476 |
+ } \
|
|
|
0a7476 |
+ while (0);
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+#define DO_TEST(pool, ...) \
|
|
|
0a7476 |
+ DO_TEST_FULL(false, pool)
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+#define DO_TEST_FAIL(pool, ...) \
|
|
|
0a7476 |
+ DO_TEST_FULL(true, pool)
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-dir");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-dir-naming");
|
|
|
0a7476 |
+ DO_TEST("pool-fs");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-logical");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-logical-nopath");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-logical-create");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-logical-noname");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-disk");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-disk-device-nopartsep");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-iscsi");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-iscsi-auth");
|
|
|
0a7476 |
+ DO_TEST("pool-netfs");
|
|
|
0a7476 |
+ DO_TEST("pool-netfs-gluster");
|
|
|
0a7476 |
+ DO_TEST("pool-netfs-cifs");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-scsi");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-scsi-type-scsi-host");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-scsi-type-fc-host");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-scsi-type-fc-host-managed");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-mpath");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-iscsi-multiiqn");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-iscsi-vendor-product");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-sheepdog");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-gluster");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-gluster-sub");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-scsi-type-scsi-host-stable");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-zfs");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-zfs-sourcedev");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-rbd");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-vstorage");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-iscsi-direct-auth");
|
|
|
0a7476 |
+ DO_TEST_FAIL("pool-iscsi-direct");
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+VIR_TEST_MAIN(mymain)
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|