111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto backing quick 37d900301SMax Reitz# 47d900301SMax Reitz# Test qcow2's bdrv_make_empty for images without internal snapshots 57d900301SMax Reitz# 67d900301SMax Reitz# Copyright (C) 2014 Red Hat, Inc. 77d900301SMax Reitz# 87d900301SMax Reitz# This program is free software; you can redistribute it and/or modify 97d900301SMax Reitz# it under the terms of the GNU General Public License as published by 107d900301SMax Reitz# the Free Software Foundation; either version 2 of the License, or 117d900301SMax Reitz# (at your option) any later version. 127d900301SMax Reitz# 137d900301SMax Reitz# This program is distributed in the hope that it will be useful, 147d900301SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 157d900301SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 167d900301SMax Reitz# GNU General Public License for more details. 177d900301SMax Reitz# 187d900301SMax Reitz# You should have received a copy of the GNU General Public License 197d900301SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 207d900301SMax Reitz# 217d900301SMax Reitz 227d900301SMax Reitz# creator 23*42a5009dSJohn Snowowner=hreitz@redhat.com 247d900301SMax Reitz 257d900301SMax Reitzseq="$(basename $0)" 267d900301SMax Reitzecho "QA output created by $seq" 277d900301SMax Reitz 287d900301SMax Reitzstatus=1 # failure is the default! 297d900301SMax Reitz 307d900301SMax Reitz_cleanup() 317d900301SMax Reitz{ 327d900301SMax Reitz _cleanup_test_img 337d900301SMax Reitz rm -f "$TEST_DIR/blkdebug.conf" 347d900301SMax Reitz} 357d900301SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 367d900301SMax Reitz 377d900301SMax Reitz# get standard environment, filters and checks 387d900301SMax Reitz. ./common.rc 397d900301SMax Reitz. ./common.filter 407d900301SMax Reitz. ./common.pattern 417d900301SMax Reitz 427d900301SMax Reitz_supported_fmt qcow2 4357284d2aSMax Reitz_supported_proto file fuse 443be2024aSMax Reitz# The code path we want to test here only works for compat=1.1 images; 453be2024aSMax Reitz# blkdebug can only inject errors on bs->file, so external data files 463be2024aSMax Reitz# do not work with this test 473be2024aSMax Reitz_unsupported_imgopts 'compat=0.10' data_file 487d900301SMax Reitz 497d900301SMax Reitzfor event in l1_update empty_image_prepare reftable_update refblock_alloc; do 507d900301SMax Reitz 517d900301SMax Reitzecho 527d900301SMax Reitzecho "=== $event ===" 537d900301SMax Reitzecho 547d900301SMax Reitz 557d900301SMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img 64M 56b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 64M 577d900301SMax Reitz 587d900301SMax Reitz# Some data that can be leaked when emptying the top image 597d900301SMax Reitz$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io 607d900301SMax Reitz 617d900301SMax Reitzcat > "$TEST_DIR/blkdebug.conf" <<EOF 627d900301SMax Reitz[inject-error] 637d900301SMax Reitzevent = "$event" 647d900301SMax ReitzEOF 657d900301SMax Reitz 667d900301SMax Reitz$QEMU_IMG commit "blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" 2>&1 \ 677d900301SMax Reitz | _filter_testdir | _filter_imgfmt 687d900301SMax Reitz 697d900301SMax Reitz# There may be errors, but they should be fixed by opening the image 707d900301SMax Reitz$QEMU_IO -c close "$TEST_IMG" 717d900301SMax Reitz 727d900301SMax Reitz_check_test_img 737d900301SMax Reitz 747d900301SMax Reitzdone 757d900301SMax Reitz 767d900301SMax Reitz 777d900301SMax Reitzrm -f "$TEST_DIR/blkdebug.conf" 787d900301SMax Reitz 797d900301SMax Reitz# success, all done 807d900301SMax Reitzecho "*** done" 817d900301SMax Reitzrm -f $seq.full 827d900301SMax Reitzstatus=0 83