Philippe Mathieu-Daudé | 11a82d1 | 2019-03-07 15:58:38 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 2 | # |
| 3 | # qcow2 pattern test, complex patterns including compression and snapshots |
Kevin Wolf | 8fc1024 | 2009-10-01 14:29:59 -0300 | [diff] [blame] | 4 | # Using patterns for 4k cluster size. |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 5 | # |
| 6 | # |
| 7 | # Copyright (C) 2009 Red Hat, Inc. |
| 8 | # |
| 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. |
| 13 | # |
| 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. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License |
Christoph Hellwig | e8c212d | 2009-07-16 19:26:54 +0200 | [diff] [blame] | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 21 | # |
| 22 | |
| 23 | # creator |
| 24 | owner=kwolf@redhat.com |
| 25 | |
| 26 | seq=`basename $0` |
| 27 | echo "QA output created by $seq" |
| 28 | |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 29 | status=1 # failure is the default! |
| 30 | |
| 31 | _cleanup() |
| 32 | { |
| 33 | _cleanup_test_img |
| 34 | } |
| 35 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
| 36 | |
| 37 | # get standard environment, filters and checks |
| 38 | . ./common.rc |
| 39 | . ./common.filter |
| 40 | . ./common.pattern |
| 41 | |
Christoph Hellwig | e76a8e8 | 2009-07-09 15:26:11 +0200 | [diff] [blame] | 42 | # much of this could be generic for any format supporting snapshots |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 43 | _supported_fmt qcow2 |
Peter Lieven | 1f7bf7d | 2014-02-03 10:26:14 +0100 | [diff] [blame] | 44 | _supported_proto file |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 45 | _supported_os Linux |
Max Reitz | 3be2024 | 2019-11-07 17:37:07 +0100 | [diff] [blame] | 46 | # Compression and snapshots do not work with external data files |
| 47 | _unsupported_imgopts data_file |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 48 | |
| 49 | TEST_OFFSETS="0 4294967296" |
| 50 | TEST_OPS="writev read write readv" |
Kevin Wolf | 8fc1024 | 2009-10-01 14:29:59 -0300 | [diff] [blame] | 51 | CLUSTER_SIZE=4096 |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 52 | |
| 53 | _make_test_img 6G |
| 54 | |
| 55 | echo "Testing empty image:" |
| 56 | for offset in $TEST_OFFSETS; do |
| 57 | echo test2: With offset $offset |
Kevin Wolf | 8fc1024 | 2009-10-01 14:29:59 -0300 | [diff] [blame] | 58 | io_test2 $offset $CLUSTER_SIZE 256 |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 59 | _check_test_img |
| 60 | done |
| 61 | |
| 62 | # With snapshots |
| 63 | for i in `seq 1 3`; do |
Jeff Cody | fef9c19 | 2013-09-25 08:12:22 -0400 | [diff] [blame] | 64 | $QEMU_IMG snapshot -c test$i "$TEST_IMG" |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 65 | for offset in $TEST_OFFSETS; do |
| 66 | echo With snapshot test$i, offset $offset |
| 67 | for op in $TEST_OPS; do |
Kevin Wolf | 8fc1024 | 2009-10-01 14:29:59 -0300 | [diff] [blame] | 68 | io_test $op $offset $CLUSTER_SIZE 8 |
Christoph Hellwig | 6bf19c9 | 2009-06-22 18:29:05 +0200 | [diff] [blame] | 69 | done |
| 70 | _check_test_img |
| 71 | done |
| 72 | done |
| 73 | |
| 74 | # success, all done |
| 75 | echo "*** done" |
| 76 | rm -f $seq.full |
| 77 | status=0 |