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