]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
36f808fa KW |
2 | # |
3 | # Test for auto-read-only | |
4 | # | |
5 | # Copyright (C) 2018 Red Hat, Inc. | |
6 | # | |
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. | |
11 | # | |
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. | |
16 | # | |
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/>. | |
19 | # | |
20 | ||
21 | # creator | |
22 | owner=kwolf@redhat.com | |
23 | ||
24 | seq=`basename $0` | |
25 | echo "QA output created by $seq" | |
26 | ||
36f808fa KW |
27 | status=1 # failure is the default! |
28 | ||
29 | _cleanup() | |
30 | { | |
31 | _cleanup_test_img | |
12efe428 | 32 | rm -f $TEST_IMG.[01234] |
36f808fa KW |
33 | } |
34 | trap "_cleanup; exit \$status" 0 1 2 3 15 | |
35 | ||
36 | # get standard environment, filters and checks | |
37 | . ./common.rc | |
38 | . ./common.filter | |
39 | ||
40 | _supported_fmt generic | |
41 | _supported_proto file | |
42 | _supported_os Linux | |
43 | ||
8cedcffd | 44 | do_run_qemu() |
36f808fa KW |
45 | { |
46 | echo Testing: "$@" | |
47 | ( | |
48 | if ! test -t 0; then | |
49 | while read cmd; do | |
50 | echo $cmd | |
51 | done | |
52 | fi | |
53 | echo quit | |
54 | ) | $QEMU -nographic -monitor stdio -nodefaults "$@" | |
55 | echo | |
56 | } | |
57 | ||
8cedcffd | 58 | run_qemu() |
36f808fa KW |
59 | { |
60 | do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp | | |
61 | _filter_generated_node_ids | _filter_imgfmt | |
62 | } | |
63 | ||
8cedcffd | 64 | run_qemu_info_block() |
36f808fa KW |
65 | { |
66 | echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG" | |
67 | } | |
68 | ||
69 | size=128M | |
70 | ||
71 | _make_test_img $size | |
72 | ||
c48221aa HR |
73 | if [ -n "$TEST_IMG_FILE" ]; then |
74 | TEST_IMG=$TEST_IMG_FILE | |
75 | fi | |
76 | ||
36f808fa KW |
77 | echo |
78 | echo "=== -drive with read-write image: read-only/auto-read-only combinations ===" | |
79 | echo | |
80 | ||
81 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off | |
82 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on | |
83 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on | |
84 | echo | |
85 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off | |
86 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on | |
87 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off | |
88 | echo | |
89 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off | |
90 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on | |
91 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none | |
92 | ||
93 | echo | |
94 | echo "=== -drive with read-only image: read-only/auto-read-only combinations ===" | |
95 | echo | |
96 | ||
97 | chmod a-w $TEST_IMG | |
98 | ||
99 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off | |
100 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on | |
101 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on | |
102 | echo | |
103 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off | |
104 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on | |
105 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off | |
106 | echo | |
107 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off | |
108 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on | |
109 | run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none | |
110 | ||
111 | echo | |
112 | echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ===" | |
113 | echo | |
114 | ||
115 | chmod a+w $TEST_IMG | |
116 | ||
117 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off | |
118 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on | |
119 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on | |
120 | echo | |
121 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off | |
122 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on | |
123 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off | |
124 | echo | |
125 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off | |
126 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on | |
127 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 | |
128 | ||
129 | echo | |
130 | echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ===" | |
131 | echo | |
132 | ||
133 | chmod a-w $TEST_IMG | |
134 | ||
135 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off | |
136 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on | |
137 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on | |
138 | echo | |
139 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off | |
140 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on | |
141 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off | |
142 | echo | |
143 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off | |
144 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on | |
145 | run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0 | |
146 | ||
147 | # success, all done | |
148 | echo "*** done" | |
149 | rm -f $seq.full | |
150 | status=0 |