]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virshtest: Adapt 'snapshot-create-as' arg handling tests from 'virsh-optparse'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 18 Mar 2024 14:38:39 +0000 (15:38 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:30 +0000 (14:24 +0200)
Move the argument parsing tests excercising 'virsh snapshot-create-as'
from 'virsh-optparse' to 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virsh-optparse
tests/virshtest.c
tests/virshtestdata/snapshot-create-args.in [new file with mode: 0644]
tests/virshtestdata/snapshot-create-args.out [new file with mode: 0644]

index 77e754d73a1260d7879af39c99107083150893db..10fdf7727ea68a545c499067aca08c098efe31e4 100755 (executable)
@@ -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
index 1baa4026487cc4daa1cd126066847fccb1e6a3fc..453b1d7a9e138b006bbeacda87bc1b4476ac5264 100644 (file)
@@ -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 (file)
index 0000000..195b7d6
--- /dev/null
@@ -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 (file)
index 0000000..1a87b97
--- /dev/null
@@ -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>
+