#!/usr/bin/env bash
#
# Copyright (C) 2009 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/>.
#

do_is_allocated() {
    local start=$1
    local size=$2
    local step=$3
    local count=$4

    for i in `seq 1 $count`; do
        echo alloc $(( start + (i - 1) * step )) $size
    done
}

is_allocated() {
    do_is_allocated "$@" | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
}

do_io() {
    local op=$1
    local start=$2
    local size=$3
    local step=$4
    local count=$5
    local pattern=$6

    echo === IO: pattern $pattern >&2
    for i in `seq 1 $count`; do
        echo $op -P $pattern $(( start + (i - 1) * step )) $size
    done
}

io_pattern() {
    do_io "$@" | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
}

io() {
    local start=$2
    local pattern=$(( (start >> 9) % 256 ))

    do_io "$@" $pattern | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
}

io_zero() {
    do_io "$@" 0 | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
}

io_test() {
    local op=$1
    local offset=$2
    local cluster_size=$3

    local num_large=$4
    local num_medium=$((num_large * num_large))
    local num_small=$((4 * num_medium))

    local half_cluster=$((cluster_size / 2))
    local quarter_cluster=$((cluster_size / 4))
    local l2_size=$((cluster_size * cluster_size / 8))

    # Complete clusters
    io "$op" $offset $cluster_size $cluster_size $num_small
    offset=$((offset + num_small * $cluster_size))

    # From somewhere in the middle to the end of a cluster
    io "$op" $((offset + $half_cluster)) $half_cluster $cluster_size $num_small
    offset=$((offset + num_small * $cluster_size))

    # From the start to somewhere in the middle of a cluster
    io "$op" $offset $half_cluster $cluster_size $num_small
    offset=$((offset + num_small * $cluster_size))

    # Completely misaligned (and small)
    io "$op" $((offset + $quarter_cluster)) $half_cluster $cluster_size $num_small
    offset=$((offset + num_small * $cluster_size))

    # Spanning multiple clusters
    io "$op" $((offset + $half_cluster)) $((cluster_size * 2)) $((cluster_size * 3)) $num_medium
    offset=$((offset + num_medium * 3 * $cluster_size))

    # Spanning multiple L2 tables
    # L2 table size: 512 clusters of 4k = 2M
    offset=$(( ((offset + l2_size - 1) & ~(l2_size - 1)) - (3 * half_cluster) ))
    io "$op" $offset $((6 * half_cluster)) $(( l2_size + half_cluster )) $num_large
    offset=$((offset + num_large * ( l2_size + half_cluster )))
}

io_test2() {
    local orig_offset=$1
    local cluster_size=$2
    local num=$3

    # Pattern (repeat after 9 clusters):
    #        used - used - free - used - compressed - compressed -
    #        free - free - compressed

    # Write the clusters to be compressed
    echo === Clusters to be compressed [1]
    io_pattern writev $((offset + 4 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
    echo === Clusters to be compressed [2]
    io_pattern writev $((offset + 5 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
    echo === Clusters to be compressed [3]
    io_pattern writev $((offset + 8 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165

    mv "$TEST_IMG" "$TEST_IMG.orig"
    $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c "$TEST_IMG.orig" "$TEST_IMG"

    # Write the used clusters
    echo === Used clusters [1]
    io_pattern writev $((offset + 0 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
    echo === Used clusters [2]
    io_pattern writev $((offset + 1 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165
    echo === Used clusters [3]
    io_pattern writev $((offset + 3 * $cluster_size)) $cluster_size $((9 * $cluster_size)) $num 165

    # Read them
    echo === Read used/compressed clusters
    io_pattern readv $((offset + 0 * $cluster_size)) $((2 * $cluster_size)) $((9 * $cluster_size)) $num 165
    io_pattern readv $((offset + 3 * $cluster_size)) $((3 * $cluster_size)) $((9 * $cluster_size)) $num 165
    io_pattern readv $((offset + 8 * $cluster_size)) $((1 * $cluster_size)) $((9 * $cluster_size)) $num 165

    echo === Read zeros
    io_zero readv $((offset + 2 * $cluster_size)) $((1 * $cluster_size)) $((9 * $cluster_size)) $num
    io_zero readv $((offset + 6 * $cluster_size)) $((2 * $cluster_size)) $((9 * $cluster_size)) $num
}
