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