From 6a2712262e362204d79a2d098b9e22efa11eca76 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 18 Mar 2024 15:38:39 +0100 Subject: [PATCH] virshtest: Adapt 'snapshot-create-as' arg handling 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 snapshot-create-as' from 'virsh-optparse' to 'virshtest'. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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 - - 1<2 - - - - - - - - - -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 - - name - vda - - - - - -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 - - name - desc - - - - - - -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 @@ + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + vda + + + + + + + 1<2 + + + + + + + + +