]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virshtest: Adapt argument parsing tests from 'virsh-optparse'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 18 Mar 2024 14:19:34 +0000 (15:19 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:30 +0000 (14:24 +0200)
Move the argument parsing tests excercising 'virsh setvcpus' 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/argument-assignment.in [new file with mode: 0644]
tests/virshtestdata/argument-assignment.out [new file with mode: 0644]

index 3fe38b293162b4722b176bfb6c6358d7ca42132f..77e754d73a1260d7879af39c99107083150893db 100755 (executable)
@@ -28,39 +28,10 @@ if test "$VERBOSE" = yes; then
   $VIRSH --version
 fi
 
-cat <<\EOF > exp-out || framework_failure
-
-setvcpus: <domain> trying as domain NAME
-setvcpus: count(optdata): 2
-setvcpus: domain(optdata): test
-setvcpus: found option <domain>: test
-EOF
-
 fail=0
 
 test_url=test:///default
 
-for args in \
-    'test 2' \
-    '--domain test 2' \
-    '--domain=test 2' \
-    'test --count 2' \
-    'test --count=2' \
-    '--domain test --count 2' \
-    '--domain=test --count 2' \
-    '--domain test --count=2' \
-    '--domain=test --count=2' \
-    '--count 2 --domain test' \
-    '--count 2 --domain=test' \
-    '--count=2 --domain test' \
-    '--count=2 --domain=test' \
-    '--count 2 test' \
-    '--count=2 test' \
-; do
-  $VIRSH -k0 -d0 -c $test_url setvcpus $args >out 2>>err || fail=1
-  LC_ALL=C sort out | compare exp-out - || fail=1
-done
-
 # Another complex parsing example
 cat <<\EOF > exp-out || framework_failure
 <domainsnapshot>
index 926f919d8dc14fa2a8216b02915514e855099e06..1baa4026487cc4daa1cd126066847fccb1e6a3fc 100644 (file)
@@ -198,6 +198,9 @@ mymain(void)
     DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q");
 # undef DO_TEST
 
+    /* comprehensive coverage of argument assignment */
+    DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0");
+
     VIR_FREE(custom_uri);
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/virshtestdata/argument-assignment.in b/tests/virshtestdata/argument-assignment.in
new file mode 100644 (file)
index 0000000..283f521
--- /dev/null
@@ -0,0 +1,15 @@
+setvcpus test 2
+setvcpus --domain test 2
+setvcpus --domain=test 2
+setvcpus test --count 2
+setvcpus test --count=2
+setvcpus --domain test --count 2
+setvcpus --domain=test --count 2
+setvcpus --domain test --count=2
+setvcpus --domain=test --count=2
+setvcpus --count 2 --domain test
+setvcpus --count 2 --domain=test
+setvcpus --count=2 --domain test
+setvcpus --count=2 --domain=test
+setvcpus --count 2 test
+setvcpus --count=2 test
diff --git a/tests/virshtestdata/argument-assignment.out b/tests/virshtestdata/argument-assignment.out
new file mode 100644 (file)
index 0000000..501f0ad
--- /dev/null
@@ -0,0 +1,91 @@
+commands: "setvcpus test 2
+setvcpus --domain test 2
+setvcpus --domain=test 2
+setvcpus test --count 2
+setvcpus test --count=2
+setvcpus --domain test --count 2
+setvcpus --domain=test --count 2
+setvcpus --domain test --count=2
+setvcpus --domain=test --count=2
+setvcpus --count 2 --domain test
+setvcpus --count 2 --domain=test
+setvcpus --count=2 --domain test
+setvcpus --count=2 --domain=test
+setvcpus --count 2 test
+setvcpus --count=2 test
+"
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: count(optdata): 2
+setvcpus: domain(optdata): test
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+
+setvcpus: found option <domain>: test
+setvcpus: <domain> trying as domain NAME
+