#!/usr/bin/env bash
#
# Test preallocated resize of raw images
#
# Copyright (C) 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# creator
owner=mreitz@redhat.com

seq=$(basename $0)
echo "QA output created by $seq"

status=1	# failure is the default!

_cleanup()
{
	_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15

# get standard environment and filters
. ./common.rc
. ./common.filter

_supported_fmt raw
_supported_proto file
_supported_os Linux

# in kB
CREATION_SIZE=128
GROWTH_SIZE=256

echo '=== Testing image growth ==='

for create_mode in off falloc full; do
    for growth_mode in off falloc full; do
        echo
        echo "--- create_mode=$create_mode growth_mode=$growth_mode ---"

        # Our calculation below assumes kilobytes as unit for the actual size.
        # Disable the extent size hint because it would give us a result in
        # megabytes.
        _make_test_img -o "preallocation=$create_mode,extent_size_hint=0" ${CREATION_SIZE}K
        $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K

        expected_size=0
        if [ $create_mode != off ]; then
            expected_size=$CREATION_SIZE
        fi
        if [ $growth_mode != off ]; then
            expected_size=$((expected_size + $GROWTH_SIZE))
        fi

        actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
        actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/')

        # The actual size may exceed the expected size, depending on the file
        # system. Therefore we just test that the actual size is at least what
        # we expect.
        if [ $actual_size -lt $expected_size ]; then
            echo "ERROR: Image should have at least ${expected_size}K, but has ${actual_size}K"
        fi
    done
done

echo
echo '=== Testing image shrinking ==='

# None of this should work except for "off", because other modes cannot be used
# for shrinking
for growth_mode in falloc full off; do
    echo
    echo "--- growth_mode=$growth_mode ---"
    $QEMU_IMG resize -f "$IMGFMT" --shrink --preallocation=$growth_mode "$TEST_IMG" -${GROWTH_SIZE}K
done

echo
echo '=== Testing image growth on 2G empty image ==='

for growth_mode in falloc full; do
    echo
    echo "--- growth_mode=$growth_mode ---"

    # Maybe we want to do an lseek() to the end of the file before the
    # preallocation; if the file has a length of 2 GB, that would
    # return an integer that overflows to negative when put into a
    # plain int.  We should use the correct type for the result, and
    # this tests we do.

    _make_test_img -o "extent_size_hint=0" 2G
    $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K

    actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size')
    actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/')

    if [ $actual_size -lt $GROWTH_SIZE ]; then
        echo "ERROR: Image should have at least ${GROWTH_SIZE}K, but has ${actual_size}K"
    fi
done

# success, all done
echo '*** done'
rm -f $seq.full
status=0
