From 1b3f148866e0561ee3876c5e42abab7c8a069905 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 18 Mar 2024 15:19:34 +0100 Subject: [PATCH] virshtest: Adapt argument parsing tests from 'virsh-optparse' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the argument parsing tests excercising 'virsh setvcpus' from 'virsh-optparse' to 'virshtest'. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/virsh-optparse | 29 ------- tests/virshtest.c | 3 + tests/virshtestdata/argument-assignment.in | 15 ++++ tests/virshtestdata/argument-assignment.out | 91 +++++++++++++++++++++ 4 files changed, 109 insertions(+), 29 deletions(-) create mode 100644 tests/virshtestdata/argument-assignment.in create mode 100644 tests/virshtestdata/argument-assignment.out diff --git a/tests/virsh-optparse b/tests/virsh-optparse index 3fe38b2931..77e754d73a 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -28,39 +28,10 @@ if test "$VERBOSE" = yes; then $VIRSH --version fi -cat <<\EOF > exp-out || framework_failure - -setvcpus: trying as domain NAME -setvcpus: count(optdata): 2 -setvcpus: domain(optdata): test -setvcpus: found option : 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 diff --git a/tests/virshtest.c b/tests/virshtest.c index 926f919d8d..1baa402648 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -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 index 0000000000..283f521b1c --- /dev/null +++ b/tests/virshtestdata/argument-assignment.in @@ -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 index 0000000000..501f0add33 --- /dev/null +++ b/tests/virshtestdata/argument-assignment.out @@ -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 : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME +