diff --git a/tests/.gitignore b/tests/.gitignore
index 6d67c2adab..41f84543f4 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -15,6 +15,7 @@ qemuargv2xmltest
qemuhelptest
nodedevxml2xmltest
interfacexml2xmltest
+storagepoolxml2xmltest
nodeinfotest
statstest
qparamtest
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b67df5dc32..a62c01bb42 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -61,7 +61,8 @@ EXTRA_DIST = \
domainschemadata \
interfaceschemadata \
storagepoolschematest \
- storagepoolschemadata \
+ storagepoolxml2xmlout \
+ storagepoolxml2xmlin \
storagevolschematest \
storagevolschemadata \
nodedevschematest \
@@ -95,6 +96,8 @@ if WITH_CIL
noinst_PROGRAMS += object-locking
endif
+noinst_PROGRAMS += storagepoolxml2xmltest
+
noinst_PROGRAMS += nodedevxml2xmltest
noinst_PROGRAMS += interfacexml2xmltest
@@ -168,6 +171,8 @@ noinst_PROGRAMS += eventtest
TESTS += eventtest
endif
+TESTS += storagepoolxml2xmltest
+
TESTS += nodedevxml2xmltest
TESTS += interfacexml2xmltest
@@ -264,6 +269,11 @@ else
EXTRA_DIST += esxutilstest.c vmx2xmltest.c xml2vmxtest.c
endif
+storagepoolxml2xmltest_SOURCES = \
+ storagepoolxml2xmltest.c \
+ testutils.c testutils.h
+storagepoolxml2xmltest_LDADD = $(LDADDS)
+
nodedevxml2xmltest_SOURCES = \
nodedevxml2xmltest.c \
testutils.c testutils.h
diff --git a/tests/storagepoolschematest b/tests/storagepoolschematest
index d04b83b96d..be4767d5e6 100755
--- a/tests/storagepoolschematest
+++ b/tests/storagepoolschematest
@@ -2,7 +2,7 @@
source ./schematestutils.sh
-DIRS="storagepoolschemadata"
+DIRS="storagepoolxml2xmlin storagepoolxml2xmlout"
SCHEMA="storagepool.rng"
check_schema "$DIRS" "$SCHEMA"
diff --git a/tests/storagepoolschemadata/pool-dir.xml b/tests/storagepoolxml2xmlin/pool-dir.xml
similarity index 91%
rename from tests/storagepoolschemadata/pool-dir.xml
rename to tests/storagepoolxml2xmlin/pool-dir.xml
index 2b8735c215..361e383103 100644
--- a/tests/storagepoolschemadata/pool-dir.xml
+++ b/tests/storagepoolxml2xmlin/pool-dir.xml
@@ -12,6 +12,7 @@
0700
0
0
+
diff --git a/tests/storagepoolschemadata/pool-disk.xml b/tests/storagepoolxml2xmlin/pool-disk.xml
similarity index 100%
rename from tests/storagepoolschemadata/pool-disk.xml
rename to tests/storagepoolxml2xmlin/pool-disk.xml
diff --git a/tests/storagepoolschemadata/pool-fs.xml b/tests/storagepoolxml2xmlin/pool-fs.xml
similarity index 100%
rename from tests/storagepoolschemadata/pool-fs.xml
rename to tests/storagepoolxml2xmlin/pool-fs.xml
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
new file mode 100644
index 0000000000..f7d4d52aa4
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
@@ -0,0 +1,17 @@
+
+ virtimages
+ e9392370-2917-565e-692b-d057f46512d6
+
+
+
+
+
+
+ /dev/disk/by-path
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolschemadata/pool-iscsi.xml b/tests/storagepoolxml2xmlin/pool-iscsi.xml
similarity index 56%
rename from tests/storagepoolschemadata/pool-iscsi.xml
rename to tests/storagepoolxml2xmlin/pool-iscsi.xml
index 8d60f38b88..37a16f734b 100644
--- a/tests/storagepoolschemadata/pool-iscsi.xml
+++ b/tests/storagepoolxml2xmlin/pool-iscsi.xml
@@ -1,10 +1,16 @@
virtimages
+ e9392370-2917-565e-692b-d057f46512d6
/dev/disk/by-path
+
+ 0700
+ 0
+ 0
+
diff --git a/tests/storagepoolxml2xmlin/pool-logical-create.xml b/tests/storagepoolxml2xmlin/pool-logical-create.xml
new file mode 100644
index 0000000000..4c670899da
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-logical-create.xml
@@ -0,0 +1,20 @@
+
+ HostVG
+ 1c13165a-d0f4-3aee-b447-30fb38789091
+ 99891544064
+ 99220455424
+ 671088640
+
+
+
+
+
+
+ /dev/HostVG
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolschemadata/pool-logical.xml b/tests/storagepoolxml2xmlin/pool-logical.xml
similarity index 100%
rename from tests/storagepoolschemadata/pool-logical.xml
rename to tests/storagepoolxml2xmlin/pool-logical.xml
diff --git a/tests/storagepoolxml2xmlin/pool-mpath.xml b/tests/storagepoolxml2xmlin/pool-mpath.xml
new file mode 100644
index 0000000000..a5fbbcbb9c
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-mpath.xml
@@ -0,0 +1,12 @@
+
+ mpath
+ e9392370-2917-565e-692b-d057f46512d6
+
+ /dev/mapper
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolschemadata/pool-netfs.xml b/tests/storagepoolxml2xmlin/pool-netfs.xml
similarity index 100%
rename from tests/storagepoolschemadata/pool-netfs.xml
rename to tests/storagepoolxml2xmlin/pool-netfs.xml
diff --git a/tests/storagepoolxml2xmlin/pool-scsi.xml b/tests/storagepoolxml2xmlin/pool-scsi.xml
new file mode 100644
index 0000000000..3650e434fa
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-scsi.xml
@@ -0,0 +1,15 @@
+
+ hba0
+ e9392370-2917-565e-692b-d057f46512d6
+
+
+
+
+ /dev/disk/by-path
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-dir.xml b/tests/storagepoolxml2xmlout/pool-dir.xml
new file mode 100644
index 0000000000..361e383103
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-dir.xml
@@ -0,0 +1,18 @@
+
+ virtimages
+ 70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2
+ 0
+ 0
+ 0
+
+
+
+ /var/lib/libvirt/images
+
+ 0700
+ 0
+ 0
+
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-disk.xml b/tests/storagepoolxml2xmlout/pool-disk.xml
new file mode 100644
index 0000000000..d6c595ff20
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-disk.xml
@@ -0,0 +1,19 @@
+
+ sda
+ e3509a62-1b4c-e20b-94bd-9168963f9b97
+ 0
+ 0
+ 0
+
+
+
+
+
+ /dev
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-fs.xml b/tests/storagepoolxml2xmlout/pool-fs.xml
new file mode 100644
index 0000000000..ee2bb552f6
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-fs.xml
@@ -0,0 +1,19 @@
+
+ images
+ 7641d5a8-af11-f730-a34e-0a7dfcede71f
+ 0
+ 0
+ 0
+
+
+
+
+
+ /mnt
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml
new file mode 100644
index 0000000000..557295d7f6
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml
@@ -0,0 +1,20 @@
+
+ virtimages
+ e9392370-2917-565e-692b-d057f46512d6
+ 0
+ 0
+ 0
+
+
+
+
+
+
+ /dev/disk/by-path
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-iscsi.xml b/tests/storagepoolxml2xmlout/pool-iscsi.xml
new file mode 100644
index 0000000000..774bdd3c59
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-iscsi.xml
@@ -0,0 +1,19 @@
+
+ virtimages
+ e9392370-2917-565e-692b-d057f46512d6
+ 0
+ 0
+ 0
+
+
+
+
+
+ /dev/disk/by-path
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-logical-create.xml b/tests/storagepoolxml2xmlout/pool-logical-create.xml
new file mode 100644
index 0000000000..c30359b0e2
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-logical-create.xml
@@ -0,0 +1,22 @@
+
+ HostVG
+ 1c13165a-d0f4-3aee-b447-30fb38789091
+ 0
+ 0
+ 0
+
+
+
+
+ HostVG
+
+
+
+ /dev/HostVG
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-logical.xml b/tests/storagepoolxml2xmlout/pool-logical.xml
new file mode 100644
index 0000000000..6ce41e171f
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-logical.xml
@@ -0,0 +1,19 @@
+
+ HostVG
+ 1c13165a-d0f4-3aee-b447-30fb38789091
+ 0
+ 0
+ 0
+
+ HostVG
+
+
+
+ /dev/HostVG
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-mpath.xml b/tests/storagepoolxml2xmlout/pool-mpath.xml
new file mode 100644
index 0000000000..8f5d2c70fc
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-mpath.xml
@@ -0,0 +1,17 @@
+
+ mpath
+ e9392370-2917-565e-692b-d057f46512d6
+ 0
+ 0
+ 0
+
+
+
+ /dev/mapper
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-netfs.xml b/tests/storagepoolxml2xmlout/pool-netfs.xml
new file mode 100644
index 0000000000..4bd18c5852
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-netfs.xml
@@ -0,0 +1,20 @@
+
+ nfsimages
+ 7641d5a8-af11-f730-a34e-0a7dfcede71f
+ 0
+ 0
+ 0
+
+
+
+
+
+
+ /mnt
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmlout/pool-scsi.xml b/tests/storagepoolxml2xmlout/pool-scsi.xml
new file mode 100644
index 0000000000..b24a9f27e3
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-scsi.xml
@@ -0,0 +1,18 @@
+
+ hba0
+ e9392370-2917-565e-692b-d057f46512d6
+ 0
+ 0
+ 0
+
+
+
+
+ /dev/disk/by-path
+
+ 0700
+ 0
+ 0
+
+
+
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
new file mode 100644
index 0000000000..a7370c7542
--- /dev/null
+++ b/tests/storagepoolxml2xmltest.c
@@ -0,0 +1,102 @@
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include "internal.h"
+#include "testutils.h"
+#include "storage_conf.h"
+#include "testutilsqemu.h"
+
+static char *progname;
+static char *abs_srcdir;
+
+#define MAX_FILE 4096
+
+
+static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) {
+ char inXmlData[MAX_FILE];
+ char *inXmlPtr = &(inXmlData[0]);
+ char outXmlData[MAX_FILE];
+ char *outXmlPtr = &(outXmlData[0]);
+ char *actual = NULL;
+ int ret = -1;
+ virStoragePoolDefPtr dev = NULL;
+
+ if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0)
+ goto fail;
+ if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0)
+ goto fail;
+
+ if (!(dev = virStoragePoolDefParseString(NULL, inXmlData)))
+ goto fail;
+
+ if (!(actual = virStoragePoolDefFormat(NULL, dev)))
+ goto fail;
+
+ if (STRNEQ(outXmlData, actual)) {
+ virtTestDifference(stderr, outXmlData, actual);
+ goto fail;
+ }
+
+ ret = 0;
+
+ fail:
+ free(actual);
+ virStoragePoolDefFree(dev);
+ return ret;
+}
+
+static int testCompareXMLToXMLHelper(const void *data) {
+ char inxml[PATH_MAX];
+ char outxml[PATH_MAX];
+ snprintf(inxml, PATH_MAX, "%s/storagepoolxml2xmlin/%s.xml",
+ abs_srcdir, (const char*)data);
+ snprintf(outxml, PATH_MAX, "%s/storagepoolxml2xmlout/%s.xml",
+ abs_srcdir, (const char*)data);
+ return testCompareXMLToXMLFiles(inxml, outxml);
+}
+
+
+static int
+mymain(int argc, char **argv)
+{
+ int ret = 0;
+ char cwd[PATH_MAX];
+
+ progname = argv[0];
+
+ if (argc > 1) {
+ fprintf(stderr, "Usage: %s\n", progname);
+ return (EXIT_FAILURE);
+ }
+
+ abs_srcdir = getenv("abs_srcdir");
+ if (!abs_srcdir)
+ abs_srcdir = getcwd(cwd, sizeof(cwd));
+
+#define DO_TEST(name) \
+ if (virtTestRun("Storage Pool XML-2-XML " name, \
+ 1, testCompareXMLToXMLHelper, (name)) < 0) \
+ ret = -1
+
+ DO_TEST("pool-dir");
+ DO_TEST("pool-fs");
+ DO_TEST("pool-logical");
+ DO_TEST("pool-logical-create");
+ DO_TEST("pool-disk");
+ DO_TEST("pool-iscsi");
+ DO_TEST("pool-iscsi-auth");
+ DO_TEST("pool-netfs");
+ DO_TEST("pool-scsi");
+ DO_TEST("pool-mpath");
+
+ return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+VIRT_TEST_MAIN(mymain)