virshtest: Adapt argument parsing tests from 'virsh-optparse'

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>
This commit is contained in:
Peter Krempa 2024-03-18 15:19:34 +01:00
parent 52fc03ef21
commit 1b3f148866
4 changed files with 109 additions and 29 deletions

View File

@ -28,39 +28,10 @@ if test "$VERBOSE" = yes; then
$VIRSH --version $VIRSH --version
fi 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 fail=0
test_url=test:///default 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 # Another complex parsing example
cat <<\EOF > exp-out || framework_failure cat <<\EOF > exp-out || framework_failure
<domainsnapshot> <domainsnapshot>

View File

@ -198,6 +198,9 @@ mymain(void)
DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q"); DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q");
# undef DO_TEST # undef DO_TEST
/* comprehensive coverage of argument assignment */
DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0");
VIR_FREE(custom_uri); VIR_FREE(custom_uri);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
} }

View File

@ -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

View File

@ -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