1*97f94cb4SKevin Wolf#!/bin/bash 2*97f94cb4SKevin Wolf# 3*97f94cb4SKevin Wolf# Test qcow2 preallocation 4*97f94cb4SKevin Wolf# 5*97f94cb4SKevin Wolf# Copyright (C) 2019 Red Hat, Inc. 6*97f94cb4SKevin Wolf# 7*97f94cb4SKevin Wolf# This program is free software; you can redistribute it and/or modify 8*97f94cb4SKevin Wolf# it under the terms of the GNU General Public License as published by 9*97f94cb4SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*97f94cb4SKevin Wolf# (at your option) any later version. 11*97f94cb4SKevin Wolf# 12*97f94cb4SKevin Wolf# This program is distributed in the hope that it will be useful, 13*97f94cb4SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*97f94cb4SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*97f94cb4SKevin Wolf# GNU General Public License for more details. 16*97f94cb4SKevin Wolf# 17*97f94cb4SKevin Wolf# You should have received a copy of the GNU General Public License 18*97f94cb4SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*97f94cb4SKevin Wolf# 20*97f94cb4SKevin Wolf 21*97f94cb4SKevin Wolf# creator 22*97f94cb4SKevin Wolfowner=kwolf@redhat.com 23*97f94cb4SKevin Wolf 24*97f94cb4SKevin Wolfseq=$(basename $0) 25*97f94cb4SKevin Wolfecho "QA output created by $seq" 26*97f94cb4SKevin Wolf 27*97f94cb4SKevin Wolfstatus=1 # failure is the default! 28*97f94cb4SKevin Wolf 29*97f94cb4SKevin Wolf_cleanup() 30*97f94cb4SKevin Wolf{ 31*97f94cb4SKevin Wolf _cleanup_test_img 32*97f94cb4SKevin Wolf} 33*97f94cb4SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 34*97f94cb4SKevin Wolf 35*97f94cb4SKevin Wolf# get standard environment, filters and checks 36*97f94cb4SKevin Wolf. ./common.rc 37*97f94cb4SKevin Wolf. ./common.filter 38*97f94cb4SKevin Wolf 39*97f94cb4SKevin Wolf_supported_fmt qcow2 40*97f94cb4SKevin Wolf_supported_proto file 41*97f94cb4SKevin Wolf_supported_os Linux 42*97f94cb4SKevin Wolf 43*97f94cb4SKevin Wolffor mode in off metadata falloc full; do 44*97f94cb4SKevin Wolf 45*97f94cb4SKevin Wolf echo 46*97f94cb4SKevin Wolf echo "=== preallocation=$mode ===" 47*97f94cb4SKevin Wolf echo 48*97f94cb4SKevin Wolf 49*97f94cb4SKevin Wolf IMGOPTS="preallocation=$mode" _make_test_img 64M 50*97f94cb4SKevin Wolf 51*97f94cb4SKevin Wolf printf "File size: " 52*97f94cb4SKevin Wolf du -b $TEST_IMG | cut -f1 53*97f94cb4SKevin Wolf 54*97f94cb4SKevin Wolf # Can't use precise numbers here because they differ between filesystems 55*97f94cb4SKevin Wolf printf "Disk usage: " 56*97f94cb4SKevin Wolf [ $(du -B1 $TEST_IMG | cut -f1) -lt 1048576 ] && echo "low" || echo "high" 57*97f94cb4SKevin Wolf 58*97f94cb4SKevin Wolfdone 59*97f94cb4SKevin Wolf 60*97f94cb4SKevin Wolf# success, all done 61*97f94cb4SKevin Wolfecho "*** done" 62*97f94cb4SKevin Wolfrm -f $seq.full 63*97f94cb4SKevin Wolfstatus=0 64