[libvirt] [PATCH 06/10] tests: Add XML 2 XML tests for storage pools.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move existing schema data to an input directory. Add extra files for more
thorough XML testing.

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 tests/.gitignore                                   |    1 +
 tests/Makefile.am                                  |   12 ++-
 tests/storagepoolschemadata/pool-dir.xml           |   17 ----
 tests/storagepoolschemadata/pool-disk.xml          |   22 ----
 tests/storagepoolschemadata/pool-fs.xml            |   19 ----
 tests/storagepoolschemadata/pool-iscsi.xml         |   10 --
 tests/storagepoolschemadata/pool-logical.xml       |   19 ----
 tests/storagepoolschemadata/pool-netfs.xml         |   20 ----
 tests/storagepoolschematest                        |    2 +-
 tests/storagepoolxml2xmlin/pool-dir.xml            |   18 ++++
 tests/storagepoolxml2xmlin/pool-disk.xml           |   22 ++++
 tests/storagepoolxml2xmlin/pool-fs.xml             |   19 ++++
 tests/storagepoolxml2xmlin/pool-iscsi-auth.xml     |   17 ++++
 tests/storagepoolxml2xmlin/pool-iscsi.xml          |   16 +++
 tests/storagepoolxml2xmlin/pool-logical-create.xml |   20 ++++
 tests/storagepoolxml2xmlin/pool-logical.xml        |   19 ++++
 tests/storagepoolxml2xmlin/pool-mpath.xml          |   12 +++
 tests/storagepoolxml2xmlin/pool-netfs.xml          |   20 ++++
 tests/storagepoolxml2xmlin/pool-scsi.xml           |   15 +++
 tests/storagepoolxml2xmlout/pool-dir.xml           |   18 ++++
 tests/storagepoolxml2xmlout/pool-disk.xml          |   19 ++++
 tests/storagepoolxml2xmlout/pool-fs.xml            |   19 ++++
 tests/storagepoolxml2xmlout/pool-iscsi-auth.xml    |   20 ++++
 tests/storagepoolxml2xmlout/pool-iscsi.xml         |   19 ++++
 .../storagepoolxml2xmlout/pool-logical-create.xml  |   22 ++++
 tests/storagepoolxml2xmlout/pool-logical.xml       |   19 ++++
 tests/storagepoolxml2xmlout/pool-mpath.xml         |   17 ++++
 tests/storagepoolxml2xmlout/pool-netfs.xml         |   20 ++++
 tests/storagepoolxml2xmlout/pool-scsi.xml          |   18 ++++
 tests/storagepoolxml2xmltest.c                     |  102 ++++++++++++++++++++
 30 files changed, 484 insertions(+), 109 deletions(-)
 delete mode 100644 tests/storagepoolschemadata/pool-dir.xml
 delete mode 100644 tests/storagepoolschemadata/pool-disk.xml
 delete mode 100644 tests/storagepoolschemadata/pool-fs.xml
 delete mode 100644 tests/storagepoolschemadata/pool-iscsi.xml
 delete mode 100644 tests/storagepoolschemadata/pool-logical.xml
 delete mode 100644 tests/storagepoolschemadata/pool-netfs.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-dir.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-disk.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-fs.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-logical-create.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-logical.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-mpath.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-netfs.xml
 create mode 100644 tests/storagepoolxml2xmlin/pool-scsi.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-dir.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-disk.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-fs.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi-auth.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-logical-create.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-logical.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-mpath.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-netfs.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-scsi.xml
 create mode 100644 tests/storagepoolxml2xmltest.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 6d67c2a..41f8454 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 b67df5d..a62c01b 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/storagepoolschemadata/pool-dir.xml b/tests/storagepoolschemadata/pool-dir.xml
deleted file mode 100644
index 2b8735c..0000000
--- a/tests/storagepoolschemadata/pool-dir.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<pool type='dir'>
-  <name>virtimages</name>
-  <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
-  <capacity>0</capacity>
-  <allocation>0</allocation>
-  <available>0</available>
-  <source>
-  </source>
-  <target>
-    <path>/var/lib/libvirt/images</path>
-    <permissions>
-      <mode>0700</mode>
-      <owner>0</owner>
-      <group>0</group>
-    </permissions>
-  </target>
-</pool>
diff --git a/tests/storagepoolschemadata/pool-disk.xml b/tests/storagepoolschemadata/pool-disk.xml
deleted file mode 100644
index 4c27c54..0000000
--- a/tests/storagepoolschemadata/pool-disk.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<pool type='disk'>
-  <name>sda</name>
-  <uuid>e3509a62-1b4c-e20b-94bd-9168963f9b97</uuid>
-  <capacity>100027630080</capacity>
-  <allocation>100027597824</allocation>
-  <available>0</available>
-  <source>
-    <device path='/dev/sda'>
-      <freeExtent start='370137600' end='567544320'/>
-      <freeExtent start='987033600' end='1044610560'/>
-    </device>
-    <format type='dos'/>
-  </source>
-  <target>
-    <path>/dev</path>
-    <permissions>
-      <mode>0700</mode>
-      <owner>0</owner>
-      <group>0</group>
-    </permissions>
-  </target>
-</pool>
diff --git a/tests/storagepoolschemadata/pool-fs.xml b/tests/storagepoolschemadata/pool-fs.xml
deleted file mode 100644
index ee2bb55..0000000
--- a/tests/storagepoolschemadata/pool-fs.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<pool type='fs'>
-  <name>images</name>
-  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
-  <capacity>0</capacity>
-  <allocation>0</allocation>
-  <available>0</available>
-  <source>
-    <device path='/dev/sda6'/>
-    <format type='ext3'/>
-  </source>
-  <target>
-    <path>/mnt</path>
-    <permissions>
-      <mode>0700</mode>
-      <owner>0</owner>
-      <group>0</group>
-    </permissions>
-  </target>
-</pool>
diff --git a/tests/storagepoolschemadata/pool-iscsi.xml b/tests/storagepoolschemadata/pool-iscsi.xml
deleted file mode 100644
index 8d60f38..0000000
--- a/tests/storagepoolschemadata/pool-iscsi.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<pool type='iscsi'>
-  <name>virtimages</name>
-  <source>
-    <host name="iscsi.example.com"/>
-    <device path="demo-target"/>
-  </source>
-  <target>
-    <path>/dev/disk/by-path</path>
-  </target>
-</pool>
diff --git a/tests/storagepoolschemadata/pool-logical.xml b/tests/storagepoolschemadata/pool-logical.xml
deleted file mode 100644
index c4bfa07..0000000
--- a/tests/storagepoolschemadata/pool-logical.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<pool type='logical'>
-  <name>HostVG</name>
-  <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid>
-  <capacity>99891544064</capacity>
-  <allocation>99220455424</allocation>
-  <available>671088640</available>
-  <source>
-    <name>HostVG</name>
-    <format type='lvm2'/>
-  </source>
-  <target>
-    <path>/dev/HostVG</path>
-    <permissions>
-      <mode>0700</mode>
-      <owner>0</owner>
-      <group>0</group>
-    </permissions>
-  </target>
-</pool>
diff --git a/tests/storagepoolschemadata/pool-netfs.xml b/tests/storagepoolschemadata/pool-netfs.xml
deleted file mode 100644
index 4bd18c5..0000000
--- a/tests/storagepoolschemadata/pool-netfs.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<pool type='netfs'>
-  <name>nfsimages</name>
-  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
-  <capacity>0</capacity>
-  <allocation>0</allocation>
-  <available>0</available>
-  <source>
-    <host name='localhost'/>
-    <dir path='/var/lib/libvirt/images'/>
-    <format type='nfs'/>
-  </source>
-  <target>
-    <path>/mnt</path>
-    <permissions>
-      <mode>0700</mode>
-      <owner>0</owner>
-      <group>0</group>
-    </permissions>
-  </target>
-</pool>
diff --git a/tests/storagepoolschematest b/tests/storagepoolschematest
index d04b83b..be4767d 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/storagepoolxml2xmlin/pool-dir.xml b/tests/storagepoolxml2xmlin/pool-dir.xml
new file mode 100644
index 0000000..361e383
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-dir.xml
@@ -0,0 +1,18 @@
+<pool type='dir'>
+  <name>virtimages</name>
+  <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+  </source>
+  <target>
+    <path>/var/lib/libvirt/images</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+      <label>some_label_t</label>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-disk.xml b/tests/storagepoolxml2xmlin/pool-disk.xml
new file mode 100644
index 0000000..4c27c54
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-disk.xml
@@ -0,0 +1,22 @@
+<pool type='disk'>
+  <name>sda</name>
+  <uuid>e3509a62-1b4c-e20b-94bd-9168963f9b97</uuid>
+  <capacity>100027630080</capacity>
+  <allocation>100027597824</allocation>
+  <available>0</available>
+  <source>
+    <device path='/dev/sda'>
+      <freeExtent start='370137600' end='567544320'/>
+      <freeExtent start='987033600' end='1044610560'/>
+    </device>
+    <format type='dos'/>
+  </source>
+  <target>
+    <path>/dev</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-fs.xml b/tests/storagepoolxml2xmlin/pool-fs.xml
new file mode 100644
index 0000000..ee2bb55
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-fs.xml
@@ -0,0 +1,19 @@
+<pool type='fs'>
+  <name>images</name>
+  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <device path='/dev/sda6'/>
+    <format type='ext3'/>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
new file mode 100644
index 0000000..f7d4d52
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
@@ -0,0 +1,17 @@
+<pool type='iscsi'>
+  <name>virtimages</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <source>
+    <host name="iscsi.example.com"/>
+    <device path="demo-target"/>
+    <auth type='chap' login='foobar' passwd='frobbar'/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi.xml b/tests/storagepoolxml2xmlin/pool-iscsi.xml
new file mode 100644
index 0000000..37a16f7
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-iscsi.xml
@@ -0,0 +1,16 @@
+<pool type='iscsi'>
+  <name>virtimages</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <source>
+    <host name="iscsi.example.com"/>
+    <device path="demo-target"/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-logical-create.xml b/tests/storagepoolxml2xmlin/pool-logical-create.xml
new file mode 100644
index 0000000..4c67089
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-logical-create.xml
@@ -0,0 +1,20 @@
+<pool type='logical'>
+  <name>HostVG</name>
+  <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid>
+  <capacity>99891544064</capacity>
+  <allocation>99220455424</allocation>
+  <available>671088640</available>
+  <source>
+    <device path="/dev/sdb1"/>
+    <device path="/dev/sdb2"/>
+    <device path="/dev/sdb3"/>
+  </source>
+  <target>
+    <path>/dev/HostVG</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-logical.xml b/tests/storagepoolxml2xmlin/pool-logical.xml
new file mode 100644
index 0000000..c4bfa07
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-logical.xml
@@ -0,0 +1,19 @@
+<pool type='logical'>
+  <name>HostVG</name>
+  <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid>
+  <capacity>99891544064</capacity>
+  <allocation>99220455424</allocation>
+  <available>671088640</available>
+  <source>
+    <name>HostVG</name>
+    <format type='lvm2'/>
+  </source>
+  <target>
+    <path>/dev/HostVG</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-mpath.xml b/tests/storagepoolxml2xmlin/pool-mpath.xml
new file mode 100644
index 0000000..a5fbbcb
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-mpath.xml
@@ -0,0 +1,12 @@
+<pool type="mpath">
+  <name>mpath</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <target>
+    <path>/dev/mapper</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-netfs.xml b/tests/storagepoolxml2xmlin/pool-netfs.xml
new file mode 100644
index 0000000..4bd18c5
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-netfs.xml
@@ -0,0 +1,20 @@
+<pool type='netfs'>
+  <name>nfsimages</name>
+  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <host name='localhost'/>
+    <dir path='/var/lib/libvirt/images'/>
+    <format type='nfs'/>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-scsi.xml b/tests/storagepoolxml2xmlin/pool-scsi.xml
new file mode 100644
index 0000000..3650e43
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-scsi.xml
@@ -0,0 +1,15 @@
+<pool type="scsi">
+  <name>hba0</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <source>
+    <adapter name="host0"/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-dir.xml b/tests/storagepoolxml2xmlout/pool-dir.xml
new file mode 100644
index 0000000..361e383
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-dir.xml
@@ -0,0 +1,18 @@
+<pool type='dir'>
+  <name>virtimages</name>
+  <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+  </source>
+  <target>
+    <path>/var/lib/libvirt/images</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+      <label>some_label_t</label>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-disk.xml b/tests/storagepoolxml2xmlout/pool-disk.xml
new file mode 100644
index 0000000..d6c595f
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-disk.xml
@@ -0,0 +1,19 @@
+<pool type='disk'>
+  <name>sda</name>
+  <uuid>e3509a62-1b4c-e20b-94bd-9168963f9b97</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <device path='/dev/sda'/>
+    <format type='dos'/>
+  </source>
+  <target>
+    <path>/dev</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-fs.xml b/tests/storagepoolxml2xmlout/pool-fs.xml
new file mode 100644
index 0000000..ee2bb55
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-fs.xml
@@ -0,0 +1,19 @@
+<pool type='fs'>
+  <name>images</name>
+  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <device path='/dev/sda6'/>
+    <format type='ext3'/>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml
new file mode 100644
index 0000000..557295d
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml
@@ -0,0 +1,20 @@
+<pool type='iscsi'>
+  <name>virtimages</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <host name='iscsi.example.com'/>
+    <device path='demo-target'/>
+    <auth type='chap' login='foobar' passwd='frobbar'/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-iscsi.xml b/tests/storagepoolxml2xmlout/pool-iscsi.xml
new file mode 100644
index 0000000..774bdd3
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-iscsi.xml
@@ -0,0 +1,19 @@
+<pool type='iscsi'>
+  <name>virtimages</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <host name='iscsi.example.com'/>
+    <device path='demo-target'/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-logical-create.xml b/tests/storagepoolxml2xmlout/pool-logical-create.xml
new file mode 100644
index 0000000..c30359b
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-logical-create.xml
@@ -0,0 +1,22 @@
+<pool type='logical'>
+  <name>HostVG</name>
+  <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <device path='/dev/sdb1'/>
+    <device path='/dev/sdb2'/>
+    <device path='/dev/sdb3'/>
+    <name>HostVG</name>
+    <format type='lvm2'/>
+  </source>
+  <target>
+    <path>/dev/HostVG</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-logical.xml b/tests/storagepoolxml2xmlout/pool-logical.xml
new file mode 100644
index 0000000..6ce41e1
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-logical.xml
@@ -0,0 +1,19 @@
+<pool type='logical'>
+  <name>HostVG</name>
+  <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <name>HostVG</name>
+    <format type='lvm2'/>
+  </source>
+  <target>
+    <path>/dev/HostVG</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-mpath.xml b/tests/storagepoolxml2xmlout/pool-mpath.xml
new file mode 100644
index 0000000..8f5d2c7
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-mpath.xml
@@ -0,0 +1,17 @@
+<pool type='mpath'>
+  <name>mpath</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+  </source>
+  <target>
+    <path>/dev/mapper</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-netfs.xml b/tests/storagepoolxml2xmlout/pool-netfs.xml
new file mode 100644
index 0000000..4bd18c5
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-netfs.xml
@@ -0,0 +1,20 @@
+<pool type='netfs'>
+  <name>nfsimages</name>
+  <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <host name='localhost'/>
+    <dir path='/var/lib/libvirt/images'/>
+    <format type='nfs'/>
+  </source>
+  <target>
+    <path>/mnt</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-scsi.xml b/tests/storagepoolxml2xmlout/pool-scsi.xml
new file mode 100644
index 0000000..b24a9f2
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-scsi.xml
@@ -0,0 +1,18 @@
+<pool type='scsi'>
+  <name>hba0</name>
+  <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+    <adapter name='host0'/>
+  </source>
+  <target>
+    <path>/dev/disk/by-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>0</owner>
+      <group>0</group>
+    </permissions>
+  </target>
+</pool>
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
new file mode 100644
index 0000000..a7370c7
--- /dev/null
+++ b/tests/storagepoolxml2xmltest.c
@@ -0,0 +1,102 @@
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#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)
-- 
1.6.5.rc2

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]