]> git.proxmox.com Git - mirror_qemu.git/blob - tests/qemu-iotests/162
iotests: Remove raciness from 162
[mirror_qemu.git] / tests / qemu-iotests / 162
1 #!/bin/bash
2 #
3 # Test case for specifying runtime options of the wrong type to some
4 # block drivers
5 #
6 # Copyright (C) 2016 Red Hat, Inc.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
21
22 # creator
23 owner=mreitz@redhat.com
24
25 seq="$(basename $0)"
26 echo "QA output created by $seq"
27
28 here="$PWD"
29 status=1 # failure is the default!
30
31 # get standard environment, filters and checks
32 . ./common.rc
33 . ./common.filter
34
35 _supported_fmt generic
36 _supported_os Linux
37
38 echo
39 echo '=== NBD ==='
40 # NBD expects all of its arguments to be strings
41
42 # So this should not crash
43 $QEMU_IMG info 'json:{"driver": "nbd", "host": 42}'
44
45 # And this should not treat @port as if it had not been specified
46 # (We cannot use localhost with an invalid port here, but we need to use a
47 # non-existing domain, because otherwise the error message will not contain
48 # the port)
49 $QEMU_IMG info 'json:{"driver": "nbd", "host": "does.not.exist.example.com", "port": 42}'
50
51 # This is a test for NBD's bdrv_refresh_filename() implementation: It expects
52 # either host or path to be set, but it must not assume that they are set to
53 # strings in the options QDict
54 $QEMU_NBD -k "$PWD/42" -f raw --fork null-co://
55 $QEMU_IMG info 'json:{"driver": "nbd", "path": 42}' | grep '^image'
56 rm -f 42
57
58
59 echo
60 echo '=== SSH ==='
61 # SSH expects all of its arguments to be strings, except for @port, which is
62 # expected to be an integer
63
64 # So "0" should be converted to an integer here (instead of crashing)
65 $QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": "0", "path": "/foo"}'
66 # The same, basically (all values for --image-opts are seen as strings in qemu)
67 $QEMU_IMG info --image-opts \
68 driver=ssh,host=localhost,port=0,path=/foo
69
70 # This, however, should fail because of the wrong type
71 $QEMU_IMG info 'json:{"driver": "ssh", "host": "localhost", "port": 0.42, "path": "/foo"}'
72 # Not really the same: Here, "0.42" will be passed instead of 0.42, but still,
73 # qemu should not try to convert "0.42" to an integer
74 $QEMU_IMG info --image-opts \
75 driver=ssh,host=localhost,port=0.42,path=/foo
76
77
78 echo
79 echo '=== blkdebug ==='
80 # blkdebug expects all of its arguments to be strings, but its
81 # bdrv_refresh_filename() implementation should not assume that they have been
82 # passed as strings in the original options QDict.
83 # So this should emit blkdebug:42:null-co:// as the filename:
84 touch 42
85 $QEMU_IMG info 'json:{"driver": "blkdebug", "config": 42,
86 "image.driver": "null-co"}' \
87 | grep '^image'
88 rm -f 42
89
90
91 # success, all done
92 echo
93 echo '*** done'
94 rm -f $seq.full
95 status=0