111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2c6a9d2f6SEric Blake# 3c6a9d2f6SEric Blake# Test qemu-img vs. unaligned images 4c6a9d2f6SEric Blake# 5*d3192de7SEric Blake# Copyright (C) 2018-2019 Red Hat, Inc. 6c6a9d2f6SEric Blake# 7c6a9d2f6SEric Blake# This program is free software; you can redistribute it and/or modify 8c6a9d2f6SEric Blake# it under the terms of the GNU General Public License as published by 9c6a9d2f6SEric Blake# the Free Software Foundation; either version 2 of the License, or 10c6a9d2f6SEric Blake# (at your option) any later version. 11c6a9d2f6SEric Blake# 12c6a9d2f6SEric Blake# This program is distributed in the hope that it will be useful, 13c6a9d2f6SEric Blake# but WITHOUT ANY WARRANTY; without even the implied warranty of 14c6a9d2f6SEric Blake# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15c6a9d2f6SEric Blake# GNU General Public License for more details. 16c6a9d2f6SEric Blake# 17c6a9d2f6SEric Blake# You should have received a copy of the GNU General Public License 18c6a9d2f6SEric Blake# along with this program. If not, see <http://www.gnu.org/licenses/>. 19c6a9d2f6SEric Blake# 20c6a9d2f6SEric Blake 21c6a9d2f6SEric Blakeseq="$(basename $0)" 22c6a9d2f6SEric Blakeecho "QA output created by $seq" 23c6a9d2f6SEric Blake 24c6a9d2f6SEric Blakestatus=1 # failure is the default! 25c6a9d2f6SEric Blake 26c6a9d2f6SEric Blake_cleanup() 27c6a9d2f6SEric Blake{ 28c6a9d2f6SEric Blake _cleanup_test_img 29c6a9d2f6SEric Blake} 30c6a9d2f6SEric Blaketrap "_cleanup; exit \$status" 0 1 2 3 15 31c6a9d2f6SEric Blake 32c6a9d2f6SEric Blake# get standard environment, filters and checks 33c6a9d2f6SEric Blake. ./common.rc 34c6a9d2f6SEric Blake. ./common.filter 35c6a9d2f6SEric Blake 36c6a9d2f6SEric Blake_supported_fmt raw 37c6a9d2f6SEric Blake_supported_proto file 38c6a9d2f6SEric Blake_supported_os Linux 39c6a9d2f6SEric Blake 40c6a9d2f6SEric Blakeecho 41c6a9d2f6SEric Blakeecho "=== Check mapping of unaligned raw image ===" 42c6a9d2f6SEric Blakeecho 43c6a9d2f6SEric Blake 44*d3192de7SEric Blake_make_test_img 65537 # qemu-img create rounds size up 45c6a9d2f6SEric Blake$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map 46c6a9d2f6SEric Blake 47*d3192de7SEric Blaketruncate --size=65537 "$TEST_IMG" # so we resize it and check again 48c6a9d2f6SEric Blake$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map 49c6a9d2f6SEric Blake 50*d3192de7SEric Blake$QEMU_IO -c 'w 65536 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up 51c6a9d2f6SEric Blake$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map 52c6a9d2f6SEric Blake 53*d3192de7SEric Blaketruncate --size=65537 "$TEST_IMG" # so we resize it and check again 54c6a9d2f6SEric Blake$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map 55c6a9d2f6SEric Blake 56c6a9d2f6SEric Blake# success, all done 57c6a9d2f6SEric Blakeecho '*** done' 58c6a9d2f6SEric Blakerm -f $seq.full 59c6a9d2f6SEric Blakestatus=0 60