target-arm: A64: fix unallocated test of scalar SQXTUN
[qemu/ar7.git] / tests / qemu-iotests / 058
blob14584cdea2efc09b6aa137169917faa64de78a83
1 #!/bin/bash
3 # Test export internal snapshot by qemu-nbd, convert it by qemu-img.
5 # Copyright (C) 2013 IBM, Inc.
7 # Based on 029.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # creator
24 owner=xiawenc@linux.vnet.ibm.com
26 seq=`basename $0`
27 echo "QA output created by $seq"
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1 # failure is the default!
33 nbd_unix_socket=$TEST_DIR/test_qemu_nbd_socket
34 nbd_snapshot_img="nbd:unix:$nbd_unix_socket"
36 _cleanup_nbd()
38 if [ -n "$NBD_SNAPSHOT_PID" ]; then
39 kill "$NBD_SNAPSHOT_PID"
41 rm -f "$nbd_unix_socket"
44 _wait_for_nbd()
46 for ((i = 0; i < 300; i++))
48 if [ -r "$nbd_unix_socket" ]; then
49 return
51 sleep 0.1
52 done
53 echo "Failed in check of unix socket created by qemu-nbd"
54 exit 1
57 converted_image=$TEST_IMG.converted
59 _export_nbd_snapshot()
61 _cleanup_nbd
62 $QEMU_NBD -v -t -k "$nbd_unix_socket" "$TEST_IMG" -l $1 &
63 NBD_SNAPSHOT_PID=$!
64 _wait_for_nbd
67 _export_nbd_snapshot1()
69 _cleanup_nbd
70 $QEMU_NBD -v -t -k "$nbd_unix_socket" "$TEST_IMG" -l snapshot.name=$1 &
71 NBD_SNAPSHOT_PID=$!
72 _wait_for_nbd
75 _cleanup()
77 _cleanup_nbd
78 _cleanup_test_img
79 rm -f "$converted_image"
81 trap "_cleanup; exit \$status" 0 1 2 3 15
83 # get standard environment, filters and checks
84 . ./common.rc
85 . ./common.filter
86 . ./common.pattern
88 _supported_fmt qcow2
89 _supported_proto file
90 _require_command QEMU_NBD
92 echo
93 echo "== preparing image =="
94 _make_test_img 64M
95 $QEMU_IO -c 'write -P 0xa 0x1000 0x1000' "$TEST_IMG" | _filter_qemu_io
96 $QEMU_IO -c 'write -P 0xb 0x2000 0x1000' "$TEST_IMG" | _filter_qemu_io
97 $QEMU_IMG snapshot -c sn1 "$TEST_IMG"
98 $QEMU_IO -c 'write -P 0xc 0x1000 0x1000' "$TEST_IMG" | _filter_qemu_io
99 $QEMU_IO -c 'write -P 0xd 0x2000 0x1000' "$TEST_IMG" | _filter_qemu_io
100 _check_test_img
102 echo
103 echo "== verifying the image file with patterns =="
104 $QEMU_IO -c 'read -P 0xc 0x1000 0x1000' "$TEST_IMG" | _filter_qemu_io
105 $QEMU_IO -c 'read -P 0xd 0x2000 0x1000' "$TEST_IMG" | _filter_qemu_io
107 _export_nbd_snapshot sn1
109 echo
110 echo "== verifying the exported snapshot with patterns, method 1 =="
111 $QEMU_IO -c 'read -P 0xa 0x1000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io
112 $QEMU_IO -c 'read -P 0xb 0x2000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io
114 _export_nbd_snapshot1 sn1
116 echo
117 echo "== verifying the exported snapshot with patterns, method 2 =="
118 $QEMU_IO -c 'read -P 0xa 0x1000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io
119 $QEMU_IO -c 'read -P 0xb 0x2000 0x1000' "$nbd_snapshot_img" | _filter_qemu_io
121 $QEMU_IMG convert "$TEST_IMG" -l sn1 -O qcow2 "$converted_image"
123 echo
124 echo "== verifying the converted snapshot with patterns, method 1 =="
125 $QEMU_IO -c 'read -P 0xa 0x1000 0x1000' "$converted_image" | _filter_qemu_io
126 $QEMU_IO -c 'read -P 0xb 0x2000 0x1000' "$converted_image" | _filter_qemu_io
128 $QEMU_IMG convert "$TEST_IMG" -l snapshot.name=sn1 -O qcow2 "$converted_image"
130 echo
131 echo "== verifying the converted snapshot with patterns, method 2 =="
132 $QEMU_IO -c 'read -P 0xa 0x1000 0x1000' "$converted_image" | _filter_qemu_io
133 $QEMU_IO -c 'read -P 0xb 0x2000 0x1000' "$converted_image" | _filter_qemu_io
135 # success, all done
136 echo "*** done"
137 rm -f $seq.full
138 status=0