[PATCH 17/35] virshtest: Adapt 'snapshot-create-as' arg handling tests from 'virsh-optparse'

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

 



Move the argument parsing tests excercising 'virsh snapshot-create-as'
from 'virsh-optparse' to 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/virsh-optparse                         | 60 --------------
 tests/virshtest.c                            |  1 +
 tests/virshtestdata/snapshot-create-args.in  |  9 +++
 tests/virshtestdata/snapshot-create-args.out | 82 ++++++++++++++++++++
 4 files changed, 92 insertions(+), 60 deletions(-)
 create mode 100644 tests/virshtestdata/snapshot-create-args.in
 create mode 100644 tests/virshtestdata/snapshot-create-args.out

diff --git a/tests/virsh-optparse b/tests/virsh-optparse
index 77e754d73a..10fdf7727e 100755
--- a/tests/virsh-optparse
+++ b/tests/virsh-optparse
@@ -32,66 +32,6 @@ fail=0

 test_url=test:///default

-# Another complex parsing example
-cat <<\EOF > exp-out || framework_failure
-<domainsnapshot>
-  <description>1&lt;2</description>
-  <memory file='d,e'/>
-  <disks>
-    <disk name='vda' snapshot='external'>
-      <source file='a&amp;b,c'/>
-    </disk>
-    <disk name='vdb'/>
-  </disks>
-</domainsnapshot>
-
-EOF
-$VIRSH -q -c $test_url snapshot-create-as --print-xml test \
-  --diskspec 'vda,file=a&b,,c,snapshot=external' --description '1<2' \
-  --diskspec vdb --memspec file=d,,e >out 2>>err || fail=1
-compare exp-out out || fail=1
-
-cat <<\EOF > exp-out || framework_failure
-<domainsnapshot>
-  <name>name</name>
-  <description>vda</description>
-  <disks>
-    <disk name='vdb'/>
-  </disks>
-</domainsnapshot>
-
-EOF
-$VIRSH -q -c $test_url snapshot-create-as  --print-xml test name vda vdb \
-  >out 2>>err || fail=1
-compare exp-out out || fail=1
-
-cat <<\EOF > exp-out || framework_failure
-<domainsnapshot>
-  <name>name</name>
-  <description>desc</description>
-  <disks>
-    <disk name='vda'/>
-    <disk name='vdb'/>
-  </disks>
-</domainsnapshot>
-
-EOF
-for args in \
-    'test name desc vda vdb' \
-    'test name desc --diskspec vda vdb' \
-    'test name desc --diskspec vda --diskspec vdb' \
-    'test name desc vda vdb' \
-    'test --diskspec vda name --diskspec vdb desc' \
-    '--description desc --name name --domain test vda vdb' \
-    '--description desc --diskspec vda --name name --domain test vdb' \
-; do
-  $VIRSH -q -c $test_url snapshot-create-as --print-xml $args \
-    >out 2>>err || fail=1
-  compare exp-out out || fail=1
-done
-
-test -s err && fail=1
-
 # Test a required argv
 cat <<\EOF > exp-err || framework_failure
 error: this function is not supported by the connection driver: virDomainQemuMonitorCommand
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 1baa402648..453b1d7a9e 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -200,6 +200,7 @@ mymain(void)

     /* comprehensive coverage of argument assignment */
     DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0");
+    DO_TEST_SCRIPT("snapshot-create-args", NULL, VIRSH_DEFAULT, "-q");

     VIR_FREE(custom_uri);
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/virshtestdata/snapshot-create-args.in b/tests/virshtestdata/snapshot-create-args.in
new file mode 100644
index 0000000000..195b7d62f2
--- /dev/null
+++ b/tests/virshtestdata/snapshot-create-args.in
@@ -0,0 +1,9 @@
+snapshot-create-as --print-xml test name desc vda vdb
+snapshot-create-as --print-xml test name desc --diskspec vda vdb
+snapshot-create-as --print-xml test name desc --diskspec vda --diskspec vdb
+snapshot-create-as --print-xml test name desc vda vdb
+snapshot-create-as --print-xml test --diskspec vda name --diskspec vdb desc
+snapshot-create-as --print-xml --description desc --name name --domain test vda vdb
+snapshot-create-as --print-xml --description desc --diskspec vda --name name --domain test vdb
+snapshot-create-as --print-xml test name vda vdb
+snapshot-create-as --print-xml test --diskspec vda,file=a&b,,c,snapshot=external --description 1<2 --diskspec vdb --memspec file=d,,e
diff --git a/tests/virshtestdata/snapshot-create-args.out b/tests/virshtestdata/snapshot-create-args.out
new file mode 100644
index 0000000000..1a87b97dab
--- /dev/null
+++ b/tests/virshtestdata/snapshot-create-args.out
@@ -0,0 +1,82 @@
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>desc</description>
+  <disks>
+    <disk name='vda'/>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <name>name</name>
+  <description>vda</description>
+  <disks>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
+<domainsnapshot>
+  <description>1&lt;2</description>
+  <memory file='d,e'/>
+  <disks>
+    <disk name='vda' snapshot='external'>
+      <source file='a&amp;b,c'/>
+    </disk>
+    <disk name='vdb'/>
+  </disks>
+</domainsnapshot>
+
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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]

  Powered by Linux