2010-04-26 13:44:05 +04:00
|
|
|
#!/bin/bash
|
2009-06-22 20:29:05 +04:00
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Red Hat, Inc.
|
|
|
|
# Copyright (c) 2000-2003,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.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it would 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
|
2009-07-16 21:26:54 +04:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-22 20:29:05 +04:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# setup and check for config parameters, and in particular
|
|
|
|
#
|
|
|
|
# EMAIL - email of the script runner.
|
|
|
|
# TEST_DIR - scratch test directory
|
|
|
|
#
|
|
|
|
# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
|
|
|
|
# below or a separate local configuration file can be used (using
|
|
|
|
# the HOST_OPTIONS variable).
|
|
|
|
# - This script is shared by the stress test system and the auto-qa
|
|
|
|
# system (includes both regression test and benchmark components).
|
|
|
|
# - this script shouldn't make any assertions about filesystem
|
|
|
|
# validity or mountedness.
|
|
|
|
#
|
|
|
|
|
|
|
|
# all tests should use a common language setting to prevent golden
|
|
|
|
# output mismatches.
|
|
|
|
export LANG=C
|
|
|
|
|
|
|
|
PATH=".:$PATH"
|
|
|
|
|
2012-04-20 14:50:24 +04:00
|
|
|
HOST=`hostname -s 2> /dev/null`
|
2009-06-22 20:29:05 +04:00
|
|
|
HOSTOS=`uname -s`
|
|
|
|
|
|
|
|
EMAIL=root@localhost # where auto-qa will send its status messages
|
|
|
|
export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
|
|
|
|
export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
|
|
|
|
export PWD=`pwd`
|
|
|
|
|
|
|
|
# $1 = prog to look for, $2* = default pathnames if not found in $PATH
|
|
|
|
set_prog_path()
|
|
|
|
{
|
|
|
|
p=`which $1 2> /dev/null`
|
|
|
|
if [ -n "$p" -a -x "$p" ]; then
|
|
|
|
echo $p
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
p=$1
|
|
|
|
|
|
|
|
shift
|
|
|
|
for f; do
|
|
|
|
if [ -x $f ]; then
|
|
|
|
echo $f
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
_fatal()
|
|
|
|
{
|
|
|
|
echo "$*"
|
|
|
|
status=1
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
export PERL_PROG="`set_prog_path perl`"
|
|
|
|
[ "$PERL_PROG" = "" ] && _fatal "perl not found"
|
|
|
|
|
|
|
|
export AWK_PROG="`set_prog_path awk`"
|
|
|
|
[ "$AWK_PROG" = "" ] && _fatal "awk not found"
|
|
|
|
|
|
|
|
export SED_PROG="`set_prog_path sed`"
|
|
|
|
[ "$SED_PROG" = "" ] && _fatal "sed not found"
|
|
|
|
|
|
|
|
export BC_PROG="`set_prog_path bc`"
|
|
|
|
[ "$BC_PROG" = "" ] && _fatal "bc not found"
|
|
|
|
|
|
|
|
export PS_ALL_FLAGS="-ef"
|
|
|
|
|
2011-12-01 17:41:24 +04:00
|
|
|
if [ -z "$QEMU_PROG" ]; then
|
|
|
|
export QEMU_PROG="`set_prog_path qemu`"
|
|
|
|
fi
|
2009-06-22 20:29:05 +04:00
|
|
|
|
2011-12-01 17:41:24 +04:00
|
|
|
if [ -z "$QEMU_IMG_PROG" ]; then
|
|
|
|
export QEMU_IMG_PROG="`set_prog_path qemu-img`"
|
|
|
|
fi
|
2009-06-22 20:29:05 +04:00
|
|
|
|
2011-12-01 17:41:24 +04:00
|
|
|
if [ -z "$QEMU_IO_PROG" ]; then
|
|
|
|
export QEMU_IO_PROG="`set_prog_path qemu-io`"
|
|
|
|
fi
|
2012-11-02 17:01:23 +04:00
|
|
|
|
|
|
|
if [ -z "$QEMU_NBD_PROG" ]; then
|
|
|
|
export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
|
|
|
|
fi
|
2009-06-22 20:29:05 +04:00
|
|
|
|
|
|
|
export QEMU=$QEMU_PROG
|
2012-11-02 17:01:23 +04:00
|
|
|
export QEMU_IMG=$QEMU_IMG_PROG
|
2009-06-22 20:29:05 +04:00
|
|
|
export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS"
|
2012-11-02 17:01:23 +04:00
|
|
|
export QEMU_NBD=$QEMU_NBD_PROG
|
2009-06-22 20:29:05 +04:00
|
|
|
|
|
|
|
[ -f /etc/qemu-iotest.config ] && . /etc/qemu-iotest.config
|
|
|
|
|
2011-04-12 00:05:44 +04:00
|
|
|
if [ -z "$TEST_DIR" ]; then
|
|
|
|
TEST_DIR=`pwd`/scratch
|
|
|
|
fi
|
|
|
|
|
2009-06-22 20:29:05 +04:00
|
|
|
if [ ! -e "$TEST_DIR" ]; then
|
2011-04-12 00:05:44 +04:00
|
|
|
mkdir "$TEST_DIR"
|
2009-06-22 20:29:05 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$TEST_DIR" ]; then
|
|
|
|
echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-02-29 17:25:20 +04:00
|
|
|
export TEST_DIR
|
|
|
|
|
2009-06-22 20:29:05 +04:00
|
|
|
_readlink()
|
|
|
|
{
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: _readlink filename" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
perl -e "\$in=\"$1\";" -e '
|
|
|
|
$lnk = readlink($in);
|
|
|
|
if ($lnk =~ m!^/.*!) {
|
|
|
|
print "$lnk\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
chomp($dir = `dirname $in`);
|
|
|
|
print "$dir/$lnk\n";
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
# make sure this script returns success
|
|
|
|
/bin/true
|