docs/devel/qapi-code-gen: Normalize version refs x.y.0 to just x.y
[qemu/kevin.git] / tests / qemu-iotests / 288
blob47aca6592a642d6c29afb26e8c4e523198e2a2e0
1 #!/usr/bin/env bash
2 # group: quick
4 # qemu-img measure tests for LUKS images
6 # Copyright (C) 2020 Red Hat, Inc.
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.
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.
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/>.
22 # creator
23 owner=stefanha@redhat.com
25 seq=`basename $0`
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
33 rm -f "$TEST_IMG.converted"
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40 . ./common.pattern
42 _supported_fmt luks
43 _supported_proto file
44 _supported_os Linux
46 SECRET=secret,id=sec0,data=passphrase
48 echo "== measure 1G image file =="
49 echo
51 $QEMU_IMG measure --object "$SECRET" \
52 -O "$IMGFMT" \
53 -o key-secret=sec0,iter-time=10 \
54 --size 1G
56 echo
57 echo "== create 1G image file (size should be no greater than measured) =="
58 echo
60 _make_test_img 1G
61 stat -c "image file size in bytes: %s" "$TEST_IMG_FILE"
63 echo
64 echo "== modified 1G image file (size should be no greater than measured) =="
65 echo
67 $QEMU_IO --object "$SECRET" --image-opts "$TEST_IMG" -c "write -P 0x51 0x10000 0x400" | _filter_qemu_io | _filter_testdir
68 stat -c "image file size in bytes: %s" "$TEST_IMG_FILE"
70 echo
71 echo "== measure preallocation=falloc 1G image file =="
72 echo
74 $QEMU_IMG measure --object "$SECRET" \
75 -O "$IMGFMT" \
76 -o key-secret=sec0,iter-time=10,preallocation=falloc \
77 --size 1G
79 echo
80 echo "== measure with input image file =="
81 echo
83 IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img 1G | _filter_imgfmt
84 QEMU_IO_OPTIONS= IMGOPTSSYNTAX= $QEMU_IO -f raw -c "write -P 0x51 0x10000 0x400" "$TEST_IMG_FILE" | _filter_qemu_io | _filter_testdir
85 $QEMU_IMG measure --object "$SECRET" \
86 -O "$IMGFMT" \
87 -o key-secret=sec0,iter-time=10 \
88 -f raw \
89 "$TEST_IMG_FILE"
91 # success, all done
92 echo "*** done"
93 rm -f $seq.full
94 status=0