Philippe Mathieu-Daudé | 11a82d1 | 2019-03-07 15:58:38 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 2 | # |
Eric Blake | f464906 | 2020-04-28 16:38:07 -0500 | [diff] [blame] | 3 | # Test bdrv_pread/bdrv_pwrite using BDRV_O_SNAPSHOT |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 4 | # |
| 5 | # Copyright (C) 2013 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=stefanha@redhat.com |
| 23 | |
| 24 | seq=`basename $0` |
| 25 | echo "QA output created by $seq" |
| 26 | |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 27 | status=1 # failure is the default! |
| 28 | |
| 29 | _cleanup() |
| 30 | { |
| 31 | _cleanup_test_img |
| 32 | } |
| 33 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
| 34 | |
| 35 | # get standard environment, filters and checks |
| 36 | . ./common.rc |
| 37 | . ./common.filter |
| 38 | |
| 39 | _supported_fmt generic |
Peter Lieven | 1f7bf7d | 2014-02-03 10:26:14 +0100 | [diff] [blame] | 40 | _supported_proto file |
Kevin Wolf | cf77b2d | 2014-09-30 13:27:10 +0200 | [diff] [blame] | 41 | |
| 42 | # Don't do O_DIRECT on tmpfs |
Nir Soffer | 755c5fe | 2019-08-27 20:34:32 +0300 | [diff] [blame] | 43 | _supported_cache_modes writeback writethrough unsafe |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 44 | |
| 45 | size=128M |
| 46 | _make_test_img $size |
| 47 | |
| 48 | echo |
Daniel P. Berrange | 4e9b25f | 2016-05-10 17:11:29 +0100 | [diff] [blame] | 49 | echo "== initializing whole image ==" |
| 50 | $QEMU_IO -c "write -z 0 $size" "$TEST_IMG" | _filter_qemu_io |
| 51 | |
| 52 | echo |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 53 | echo "== reading whole image ==" |
Jeff Cody | fef9c19 | 2013-09-25 08:12:22 -0400 | [diff] [blame] | 54 | $QEMU_IO -s -c "read 0 $size" "$TEST_IMG" | _filter_qemu_io |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 55 | |
| 56 | echo |
| 57 | echo "== writing whole image does not modify image ==" |
Jeff Cody | fef9c19 | 2013-09-25 08:12:22 -0400 | [diff] [blame] | 58 | $QEMU_IO -s -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io |
| 59 | $QEMU_IO -c "read -P 0 0 $size" "$TEST_IMG" | _filter_qemu_io |
Stefan Hajnoczi | f95e26d | 2013-03-18 17:58:54 +0100 | [diff] [blame] | 60 | |
| 61 | # success, all done |
| 62 | echo "*** done" |
| 63 | rm -f $seq.full |
| 64 | status=0 |