Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180309' into...
[qemu/ar7.git] / tests / qemu-iotests / 207
blobf5c77852d1f714c9fdaa5a2c65f26eaaa4973ec1
1 #!/bin/bash
3 # Test ssh image creation
5 # Copyright (C) 2018 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 here=`pwd`
28 status=1 # failure is the default!
30 # get standard environment, filters and checks
31 . ./common.rc
32 . ./common.filter
34 _supported_fmt raw
35 _supported_proto ssh
36 _supported_os Linux
38 function do_run_qemu()
40 echo Testing: "$@"
41 $QEMU -nographic -qmp stdio -serial none "$@"
42 echo
45 function run_qemu()
47 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
48 | _filter_qemu | _filter_imgfmt \
49 | _filter_actual_image_size
52 echo
53 echo "=== Successful image creation (defaults) ==="
54 echo
56 run_qemu <<EOF
57 { "execute": "qmp_capabilities" }
58 { "execute": "x-blockdev-create",
59 "arguments": {
60 "driver": "ssh",
61 "location": {
62 "path": "$TEST_IMG_FILE",
63 "server": {
64 "host": "127.0.0.1",
65 "port": "22"
68 "size": 4194304
71 { "execute": "quit" }
72 EOF
74 _img_info | _filter_img_info
75 echo
76 TEST_IMG=$TEST_IMG_FILE _img_info | _filter_img_info
78 echo
79 echo "=== Test host-key-check options ==="
80 echo
82 run_qemu <<EOF
83 { "execute": "qmp_capabilities" }
84 { "execute": "x-blockdev-create",
85 "arguments": {
86 "driver": "ssh",
87 "location": {
88 "path": "$TEST_IMG_FILE",
89 "server": {
90 "host": "127.0.0.1",
91 "port": "22"
93 "host-key-check": {
94 "mode": "none"
97 "size": 8388608
100 { "execute": "quit" }
103 _img_info | _filter_img_info
105 run_qemu <<EOF
106 { "execute": "qmp_capabilities" }
107 { "execute": "x-blockdev-create",
108 "arguments": {
109 "driver": "ssh",
110 "location": {
111 "path": "$TEST_IMG_FILE",
112 "server": {
113 "host": "127.0.0.1",
114 "port": "22"
116 "host-key-check": {
117 "mode": "known_hosts"
120 "size": 4194304
123 { "execute": "quit" }
126 _img_info | _filter_img_info
129 key=$(ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" |
130 cut -d" " -f3 | base64 -d | md5sum -b | cut -d" " -f1)
132 run_qemu <<EOF
133 { "execute": "qmp_capabilities" }
134 { "execute": "x-blockdev-create",
135 "arguments": {
136 "driver": "ssh",
137 "location": {
138 "path": "$TEST_IMG_FILE",
139 "server": {
140 "host": "127.0.0.1",
141 "port": "22"
143 "host-key-check": {
144 "mode": "hash",
145 "type": "md5",
146 "hash": "wrong"
149 "size": 8388608
152 { "execute": "x-blockdev-create",
153 "arguments": {
154 "driver": "ssh",
155 "location": {
156 "path": "$TEST_IMG_FILE",
157 "server": {
158 "host": "127.0.0.1",
159 "port": "22"
161 "host-key-check": {
162 "mode": "hash",
163 "type": "md5",
164 "hash": "$key"
167 "size": 8388608
170 { "execute": "quit" }
173 _img_info | _filter_img_info
176 key=$(ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" |
177 cut -d" " -f3 | base64 -d | sha1sum -b | cut -d" " -f1)
179 run_qemu <<EOF
180 { "execute": "qmp_capabilities" }
181 { "execute": "x-blockdev-create",
182 "arguments": {
183 "driver": "ssh",
184 "location": {
185 "path": "$TEST_IMG_FILE",
186 "server": {
187 "host": "127.0.0.1",
188 "port": "22"
190 "host-key-check": {
191 "mode": "hash",
192 "type": "sha1",
193 "hash": "wrong"
196 "size": 4194304
199 { "execute": "x-blockdev-create",
200 "arguments": {
201 "driver": "ssh",
202 "location": {
203 "path": "$TEST_IMG_FILE",
204 "server": {
205 "host": "127.0.0.1",
206 "port": "22"
208 "host-key-check": {
209 "mode": "hash",
210 "type": "sha1",
211 "hash": "$key"
214 "size": 4194304
217 { "execute": "quit" }
220 _img_info | _filter_img_info
222 echo
223 echo "=== Invalid path and user ==="
224 echo
226 run_qemu <<EOF
227 { "execute": "qmp_capabilities" }
228 { "execute": "x-blockdev-create",
229 "arguments": {
230 "driver": "ssh",
231 "location": {
232 "path": "/this/is/not/an/existing/path",
233 "server": {
234 "host": "127.0.0.1",
235 "port": "22"
238 "size": 4194304
241 { "execute": "x-blockdev-create",
242 "arguments": {
243 "driver": "ssh",
244 "location": {
245 "path": "$TEST_IMG_FILE",
246 "user": "invalid user",
247 "server": {
248 "host": "127.0.0.1",
249 "port": "22"
252 "size": 4194304
255 { "execute": "quit" }
258 # success, all done
259 echo "*** done"
260 rm -f $seq.full
261 status=0