2 # Ensure that virsh option parsing doesn't regress
4 # Copyright (C) 2011-2012, 2014 Red Hat, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see
18 # <http://www.gnu.org/licenses/>.
21 : ${abs_top_srcdir=$(pwd)/..}
22 : ${abs_top_builddir=$(pwd)/..}
24 # If $abs_top_builddir/tools is not early in $PATH, put it there,
25 # so that we can safely invoke "virsh" simply with its name.
27 $abs_top_builddir/tools/src:$abs_top_builddir/tools:*) ;;
28 $abs_top_builddir/tools:*) ;;
29 *) PATH=$abs_top_builddir/tools:$PATH; export PATH ;;
32 if test "$VERBOSE" = yes; then
37 . "$srcdir/test-lib.sh"
39 cat <<\EOF > exp-out || framework_failure
41 setvcpus: <domain> trying as domain NAME
42 setvcpus: count(optdata): 2
43 setvcpus: domain(optdata): test
44 setvcpus: found option <domain>: test
49 test_url=test:///default
57 '--domain test --count 2' \
58 '--domain=test --count 2' \
59 '--domain test --count=2' \
60 '--domain=test --count=2' \
61 '--count 2 --domain test' \
62 '--count 2 --domain=test' \
63 '--count=2 --domain test' \
64 '--count=2 --domain=test' \
68 virsh -k0 -d0 -c $test_url setvcpus $args >out 2>>err || fail=1
69 LC_ALL=C sort out | compare exp-out - || fail=1
72 # Another complex parsing example
73 cat <<\EOF > exp-out || framework_failure
75 <description>1<2</description>
78 <disk name='vda' snapshot='external'>
79 <source file='a&b,c'/>
86 virsh -q -c $test_url snapshot-create-as --print-xml test \
87 --diskspec 'vda,file=a&b,,c,snapshot=external' --description '1<2' \
88 --diskspec vdb --memspec file=d,,e >out 2>>err || fail=1
89 compare exp-out out || fail=1
91 cat <<\EOF > exp-out || framework_failure
94 <description>vda</description>
101 virsh -q -c $test_url snapshot-create-as --print-xml test name vda vdb \
102 >out 2>>err || fail=1
103 compare exp-out out || fail=1
105 cat <<\EOF > exp-out || framework_failure
108 <description>desc</description>
117 'test name desc vda vdb' \
118 'test name desc --diskspec vda vdb' \
119 'test name desc --diskspec vda --diskspec vdb' \
120 'test name desc vda vdb' \
121 'test --diskspec vda name --diskspec vdb desc' \
122 '--description desc --name name --domain test vda vdb' \
123 '--description desc --diskspec vda --name name --domain test vdb' \
125 virsh -q -c $test_url snapshot-create-as --print-xml $args \
126 >out 2>>err || fail=1
127 compare exp-out out || fail=1
130 test -s err && fail=1
132 # Test a required argv
133 cat <<\EOF > exp-err || framework_failure
134 error: this function is not supported by the connection driver: virDomainQemuMonitorCommand
136 virsh -q -c $test_url qemu-monitor-command test a >out 2>err && fail=1
137 test -s out && fail=1
138 compare exp-err err || fail=1
140 (exit $fail); exit $fail