#!/bin/bash
#
# Copyright (C) 2009 Red Hat, Inc.
# Copyright (c) 2000-2006 Silicon Graphics, Inc.  All Rights Reserved.
#
# 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/>.
#

dd()
{
   if [ "$HOSTOS" == "Linux" ]
   then
        command dd --help | grep noxfer > /dev/null 2>&1

        if [ "$?" -eq 0 ]
            then
                command dd status=noxfer $@
            else
                command dd $@
            fi
   else
        command dd $@
   fi
}

# poke_file 'test.img' 512 '\xff\xfe'
poke_file()
{
    printf "$3" | dd "of=$1" bs=1 "seek=$2" conv=notrunc &>/dev/null
}

# we need common.config
if [ "$iam" != "check" ]
then
    if ! . ./common.config
        then
        echo "$iam: failed to source common.config"
        exit 1
    fi
fi

# make sure we have a standard umask
umask 022

if [ "$IMGPROTO" = "file" ]; then
    TEST_IMG=$TEST_DIR/t.$IMGFMT
elif [ "$IMGPROTO" = "nbd" ]; then
    TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
    TEST_IMG="nbd:127.0.0.1:10810"
elif [ "$IMGPROTO" = "ssh" ]; then
    TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
    TEST_IMG="ssh://127.0.0.1$TEST_IMG_FILE"
else
    TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
fi

function valgrind_qemu_io()
{
    valgrind --log-file=/tmp/$$.valgrind --error-exitcode=99 $REAL_QEMU_IO "$@"
    if [ $? != 0 ]; then
        cat /tmp/$$.valgrind
    fi
    rm -f /tmp/$$.valgrind
}


_optstr_add()
{
    if [ -n "$1" ]; then
        echo "$1,$2"
    else
        echo "$2"
    fi
}

_set_default_imgopts()
{
    if [ "$IMGFMT" == "qcow2" ] && ! (echo "$IMGOPTS" | grep "compat=" > /dev/null); then
        IMGOPTS=$(_optstr_add "$IMGOPTS" "compat=1.1")
    fi
}

_make_test_img()
{
    # extra qemu-img options can be added by tests
    # at least one argument (the image size) needs to be added
    local extra_img_options=""
    local image_size=$*
    local optstr=""
    local img_name=""

    if [ -n "$TEST_IMG_FILE" ]; then
        img_name=$TEST_IMG_FILE
    else
        img_name=$TEST_IMG
    fi

    if [ -n "$IMGOPTS" ]; then
        optstr=$(_optstr_add "$optstr" "$IMGOPTS")
    fi

    if [ "$1" = "-b" ]; then
        extra_img_options="$1 $2"
        image_size=$3
    fi
    if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then
        optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE")
    fi

    if [ -n "$optstr" ]; then
        extra_img_options="-o $optstr $extra_img_options"
    fi

    # XXX(hch): have global image options?
    $QEMU_IMG create -f $IMGFMT $extra_img_options $img_name $image_size 2>&1 | \
        sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
            -e "s#$TEST_DIR#TEST_DIR#g" \
            -e "s#$IMGFMT#IMGFMT#g" \
            -e "s# encryption=off##g" \
            -e "s# cluster_size=[0-9]\\+##g" \
            -e "s# table_size=[0-9]\\+##g" \
            -e "s# compat='[^']*'##g" \
            -e "s# compat6=\\(on\\|off\\)##g" \
            -e "s# static=\\(on\\|off\\)##g" \
            -e "s# zeroed_grain=\\(on\\|off\\)##g" \
            -e "s# subformat='[^']*'##g" \
            -e "s# adapter_type='[^']*'##g" \
            -e "s# lazy_refcounts=\\(on\\|off\\)##g"

    # Start an NBD server on the image file, which is what we'll be talking to
    if [ $IMGPROTO = "nbd" ]; then
        eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810  $TEST_IMG_FILE &"
        QEMU_NBD_PID=$!
        sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
    fi
}

_cleanup_test_img()
{
    case "$IMGPROTO" in

        nbd)
            kill $QEMU_NBD_PID
            rm -f $TEST_IMG_FILE
            ;;
        file)
            rm -f $TEST_DIR/t.$IMGFMT
            rm -f $TEST_DIR/t.$IMGFMT.orig
            rm -f $TEST_DIR/t.$IMGFMT.base
            ;;

        rbd)
            rbd rm $TEST_DIR/t.$IMGFMT > /dev/null
            ;;

        sheepdog)
            collie vdi delete $TEST_DIR/t.$IMGFMT
            ;;

    esac
}

_check_test_img()
{
    $QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | _filter_testdir | \
        sed -e '/allocated.*fragmented.*compressed clusters/d' \
            -e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
            -e '/Image end offset: [0-9]\+/d'
}

_img_info()
{
    $QEMU_IMG info "$@" $TEST_IMG 2>&1 | \
        sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
            -e "s#$TEST_DIR#TEST_DIR#g" \
            -e "s#$IMGFMT#IMGFMT#g" \
            -e "/^disk size:/ D" \
            -e "/actual-size/ D"
}

_get_pids_by_name()
{
    if [ $# -ne 1 ]
    then
        echo "Usage: _get_pids_by_name process-name" 1>&2
        exit 1
    fi

    # Algorithm ... all ps(1) variants have a time of the form MM:SS or
    # HH:MM:SS before the psargs field, use this as the search anchor.
    #
    # Matches with $1 (process-name) occur if the first psarg is $1
    # or ends in /$1 ... the matching uses sed's regular expressions,
    # so passing a regex into $1 will work.

    ps $PS_ALL_FLAGS \
    | sed -n \
        -e 's/$/ /' \
        -e 's/[         ][         ]*/ /g' \
        -e 's/^ //' \
        -e 's/^[^ ]* //' \
        -e "/[0-9]:[0-9][0-9]  *[^ ]*\/$1 /s/ .*//p" \
        -e "/[0-9]:[0-9][0-9]  *$1 /s/ .*//p"
}

# fqdn for localhost
#
_get_fqdn()
{
    host=`hostname`
    $NSLOOKUP_PROG $host | $AWK_PROG '{ if ($1 == "Name:") print $2 }'
}

# check if run as root
#
_need_to_be_root()
{
    id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
    if [ "$id" -ne 0 ]
    then
        echo "Arrgh ... you need to be root (not uid=$id) to run this test"
        exit 1
    fi
}


# Do a command, log it to $seq.full, optionally test return status
# and die if command fails. If called with one argument _do executes the
# command, logs it, and returns its exit status. With two arguments _do
# first prints the message passed in the first argument, and then "done"
# or "fail" depending on the return status of the command passed in the
# second argument. If the command fails and the variable _do_die_on_error
# is set to "always" or the two argument form is used and _do_die_on_error
# is set to "message_only" _do will print an error message to
# $seq.out and exit.

_do()
{
    if [ $# -eq 1 ]; then
        _cmd=$1
    elif [ $# -eq 2 ]; then
        _note=$1
        _cmd=$2
        echo -n "$_note... "
    else
        echo "Usage: _do [note] cmd" 1>&2
        status=1; exit
    fi

    (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
    (eval "$_cmd") >$tmp._out 2>&1; ret=$?
    cat $tmp._out >>$here/$seq.full
    if [ $# -eq 2 ]; then
        if [ $ret -eq 0 ]; then
            echo "done"
        else
            echo "fail"
        fi
    fi
    if [ $ret -ne 0  ] \
        && [ "$_do_die_on_error" = "always" \
            -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
    then
        [ $# -ne 2 ] && echo
        eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
        status=1; exit
    fi

    return $ret
}

# bail out, setting up .notrun file
#
_notrun()
{
    echo "$*" >$seq.notrun
    echo "$seq not run: $*"
    status=0
    exit
}

# just plain bail out
#
_fail()
{
    echo "$*" | tee -a $here/$seq.full
    echo "(see $seq.full for details)"
    status=1
    exit 1
}

# tests whether $IMGFMT is one of the supported image formats for a test
#
_supported_fmt()
{
    for f; do
        if [ "$f" = "$IMGFMT" -o "$f" = "generic" ]; then
            return
        fi
    done

    _notrun "not suitable for this image format: $IMGFMT"
}

# tests whether $IMGPROTO is one of the supported image protocols for a test
#
_supported_proto()
{
    for f; do
        if [ "$f" = "$IMGPROTO" -o "$f" = "generic" ]; then
            return
        fi
    done

    _notrun "not suitable for this image protocol: $IMGPROTO"
}

# tests whether the host OS is one of the supported OSes for a test
#
_supported_os()
{
    for h
    do
        if [ "$h" = "$HOSTOS" ]
        then
            return
        fi
    done

    _notrun "not suitable for this OS: $HOSTOS"
}

_unsupported_qemu_io_options()
{
    for bad_opt
    do
        for opt in $QEMU_IO_OPTIONS
        do
            if [ "$bad_opt" = "$opt" ]
            then
                _notrun "not suitable for qemu-io option: $bad_opt"
            fi
        done
    done
}

# this test requires that a specified command (executable) exists
#
_require_command()
{
    [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
}

_full_imgfmt_details()
{
    if [ -n "$IMGOPTS" ]; then
        echo "$IMGFMT ($IMGOPTS)"
    else
        echo "$IMGFMT"
    fi
}

_full_imgproto_details()
{
    echo "$IMGPROTO"
}

_full_platform_details()
{
    os=`uname -s`
    host=`hostname -s`
    kernel=`uname -r`
    platform=`uname -m`
    echo "$os/$platform $host $kernel"
}

_link_out_file()
{
   if [ -z "$1" ]; then
      echo Error must pass \$seq.
      exit
   fi
   rm -f $1
   if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
      ln -s $1.irix $1
   elif [ "`uname`" == "Linux" ]; then
      ln -s $1.linux $1
   else
      echo Error test $seq does not run on the operating system: `uname`
      exit
   fi
}

_die()
{
        echo $@
        exit 1
}

# make sure this script returns success
/bin/true
