Statistics
| Branch: | Revision:

root / tests / qemu-iotests / common.config @ 9a05feab

History | View | Annotate | Download (3.7 kB)

1 908eaf68 Stefan Hajnoczi
#!/bin/bash
2 6bf19c94 Christoph Hellwig
#
3 6bf19c94 Christoph Hellwig
# Copyright (C) 2009 Red Hat, Inc.
4 6bf19c94 Christoph Hellwig
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc.  All Rights Reserved.
5 6bf19c94 Christoph Hellwig
#
6 6bf19c94 Christoph Hellwig
# This program is free software; you can redistribute it and/or
7 6bf19c94 Christoph Hellwig
# modify it under the terms of the GNU General Public License as
8 6bf19c94 Christoph Hellwig
# published by the Free Software Foundation.
9 6bf19c94 Christoph Hellwig
#
10 6bf19c94 Christoph Hellwig
# This program is distributed in the hope that it would be useful,
11 6bf19c94 Christoph Hellwig
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12 6bf19c94 Christoph Hellwig
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 6bf19c94 Christoph Hellwig
# GNU General Public License for more details.
14 6bf19c94 Christoph Hellwig
#
15 6bf19c94 Christoph Hellwig
# You should have received a copy of the GNU General Public License
16 e8c212d6 Christoph Hellwig
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 6bf19c94 Christoph Hellwig
#
18 6bf19c94 Christoph Hellwig
#
19 6bf19c94 Christoph Hellwig
# setup and check for config parameters, and in particular
20 6bf19c94 Christoph Hellwig
#
21 6bf19c94 Christoph Hellwig
# EMAIL -           email of the script runner.
22 79e40ab1 Kevin Wolf
# TEST_DIR -        scratch test directory
23 6bf19c94 Christoph Hellwig
#
24 6bf19c94 Christoph Hellwig
# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
25 6bf19c94 Christoph Hellwig
#   below or a separate local configuration file can be used (using
26 6bf19c94 Christoph Hellwig
#   the HOST_OPTIONS variable).
27 6bf19c94 Christoph Hellwig
# - This script is shared by the stress test system and the auto-qa
28 6bf19c94 Christoph Hellwig
#   system (includes both regression test and benchmark components).
29 6bf19c94 Christoph Hellwig
# - this script shouldn't make any assertions about filesystem
30 6bf19c94 Christoph Hellwig
#   validity or mountedness.
31 6bf19c94 Christoph Hellwig
#
32 6bf19c94 Christoph Hellwig
33 6bf19c94 Christoph Hellwig
# all tests should use a common language setting to prevent golden
34 6bf19c94 Christoph Hellwig
# output mismatches.
35 6bf19c94 Christoph Hellwig
export LANG=C
36 6bf19c94 Christoph Hellwig
37 6bf19c94 Christoph Hellwig
PATH=".:$PATH"
38 6bf19c94 Christoph Hellwig
39 29926112 Andreas Färber
HOST=`hostname -s 2> /dev/null`
40 6bf19c94 Christoph Hellwig
HOSTOS=`uname -s`
41 6bf19c94 Christoph Hellwig
42 6bf19c94 Christoph Hellwig
EMAIL=root@localhost    # where auto-qa will send its status messages
43 6bf19c94 Christoph Hellwig
export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
44 6bf19c94 Christoph Hellwig
export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
45 6bf19c94 Christoph Hellwig
export PWD=`pwd`
46 6bf19c94 Christoph Hellwig
47 6bf19c94 Christoph Hellwig
# $1 = prog to look for, $2* = default pathnames if not found in $PATH
48 6bf19c94 Christoph Hellwig
set_prog_path()
49 6bf19c94 Christoph Hellwig
{
50 6bf19c94 Christoph Hellwig
    p=`which $1 2> /dev/null`
51 6bf19c94 Christoph Hellwig
    if [ -n "$p" -a -x "$p" ]; then
52 6bf19c94 Christoph Hellwig
        echo $p
53 6bf19c94 Christoph Hellwig
        return 0
54 6bf19c94 Christoph Hellwig
    fi
55 6bf19c94 Christoph Hellwig
    p=$1
56 6bf19c94 Christoph Hellwig
57 6bf19c94 Christoph Hellwig
    shift
58 6bf19c94 Christoph Hellwig
    for f; do
59 6bf19c94 Christoph Hellwig
        if [ -x $f ]; then
60 6bf19c94 Christoph Hellwig
            echo $f
61 6bf19c94 Christoph Hellwig
            return 0
62 6bf19c94 Christoph Hellwig
        fi
63 6bf19c94 Christoph Hellwig
    done
64 6bf19c94 Christoph Hellwig
65 6bf19c94 Christoph Hellwig
    echo ""
66 6bf19c94 Christoph Hellwig
    return 1
67 6bf19c94 Christoph Hellwig
}
68 6bf19c94 Christoph Hellwig
69 6bf19c94 Christoph Hellwig
_fatal()
70 6bf19c94 Christoph Hellwig
{
71 6bf19c94 Christoph Hellwig
    echo "$*"
72 6bf19c94 Christoph Hellwig
    status=1
73 6bf19c94 Christoph Hellwig
    exit 1
74 6bf19c94 Christoph Hellwig
}
75 6bf19c94 Christoph Hellwig
76 6bf19c94 Christoph Hellwig
export PERL_PROG="`set_prog_path perl`"
77 6bf19c94 Christoph Hellwig
[ "$PERL_PROG" = "" ] && _fatal "perl not found"
78 6bf19c94 Christoph Hellwig
79 6bf19c94 Christoph Hellwig
export AWK_PROG="`set_prog_path awk`"
80 6bf19c94 Christoph Hellwig
[ "$AWK_PROG" = "" ] && _fatal "awk not found"
81 6bf19c94 Christoph Hellwig
82 6bf19c94 Christoph Hellwig
export SED_PROG="`set_prog_path sed`"
83 6bf19c94 Christoph Hellwig
[ "$SED_PROG" = "" ] && _fatal "sed not found"
84 6bf19c94 Christoph Hellwig
85 6bf19c94 Christoph Hellwig
export BC_PROG="`set_prog_path bc`"
86 6bf19c94 Christoph Hellwig
[ "$BC_PROG" = "" ] && _fatal "bc not found"
87 6bf19c94 Christoph Hellwig
88 6bf19c94 Christoph Hellwig
export PS_ALL_FLAGS="-ef"
89 6bf19c94 Christoph Hellwig
90 d305fd5d Lucas Meneghel Rodrigues
if [ -z "$QEMU_PROG" ]; then
91 d305fd5d Lucas Meneghel Rodrigues
    export QEMU_PROG="`set_prog_path qemu`"
92 d305fd5d Lucas Meneghel Rodrigues
fi
93 6bf19c94 Christoph Hellwig
94 d305fd5d Lucas Meneghel Rodrigues
if [ -z "$QEMU_IMG_PROG" ]; then
95 d305fd5d Lucas Meneghel Rodrigues
    export QEMU_IMG_PROG="`set_prog_path qemu-img`"
96 d305fd5d Lucas Meneghel Rodrigues
fi
97 6bf19c94 Christoph Hellwig
98 d305fd5d Lucas Meneghel Rodrigues
if [ -z "$QEMU_IO_PROG" ]; then
99 d305fd5d Lucas Meneghel Rodrigues
    export QEMU_IO_PROG="`set_prog_path qemu-io`"
100 d305fd5d Lucas Meneghel Rodrigues
fi
101 a9660664 Nick Thomas
102 a9660664 Nick Thomas
if [ -z "$QEMU_NBD_PROG" ]; then
103 a9660664 Nick Thomas
    export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
104 a9660664 Nick Thomas
fi
105 6bf19c94 Christoph Hellwig
106 6bf19c94 Christoph Hellwig
export QEMU=$QEMU_PROG
107 a9660664 Nick Thomas
export QEMU_IMG=$QEMU_IMG_PROG
108 6bf19c94 Christoph Hellwig
export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS"
109 a9660664 Nick Thomas
export QEMU_NBD=$QEMU_NBD_PROG
110 6bf19c94 Christoph Hellwig
111 6bf19c94 Christoph Hellwig
[ -f /etc/qemu-iotest.config ]       && . /etc/qemu-iotest.config
112 6bf19c94 Christoph Hellwig
113 5e654e08 Mitnick Lyu
if [ -z "$TEST_DIR" ]; then
114 79e40ab1 Kevin Wolf
        TEST_DIR=`pwd`/scratch
115 5e654e08 Mitnick Lyu
fi
116 5e654e08 Mitnick Lyu
117 6bf19c94 Christoph Hellwig
if [ ! -e "$TEST_DIR" ]; then
118 79e40ab1 Kevin Wolf
        mkdir "$TEST_DIR"
119 6bf19c94 Christoph Hellwig
fi
120 6bf19c94 Christoph Hellwig
121 6bf19c94 Christoph Hellwig
if [ ! -d "$TEST_DIR" ]; then
122 6bf19c94 Christoph Hellwig
    echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
123 6bf19c94 Christoph Hellwig
    exit 1
124 6bf19c94 Christoph Hellwig
fi
125 6bf19c94 Christoph Hellwig
126 049255b6 Stefan Hajnoczi
export TEST_DIR
127 049255b6 Stefan Hajnoczi
128 85edbd37 Jeff Cody
if [ -z "$SAMPLE_IMG_DIR" ]; then
129 85edbd37 Jeff Cody
        SAMPLE_IMG_DIR=`pwd`/sample_images
130 85edbd37 Jeff Cody
fi
131 85edbd37 Jeff Cody
132 85edbd37 Jeff Cody
if [ ! -d "$SAMPLE_IMG_DIR" ]; then
133 85edbd37 Jeff Cody
    echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
134 85edbd37 Jeff Cody
    exit 1
135 85edbd37 Jeff Cody
fi
136 85edbd37 Jeff Cody
137 85edbd37 Jeff Cody
export SAMPLE_IMG_DIR
138 85edbd37 Jeff Cody
139 6bf19c94 Christoph Hellwig
_readlink()
140 6bf19c94 Christoph Hellwig
{
141 6bf19c94 Christoph Hellwig
    if [ $# -ne 1 ]; then
142 6bf19c94 Christoph Hellwig
        echo "Usage: _readlink filename" 1>&2
143 6bf19c94 Christoph Hellwig
        exit 1
144 6bf19c94 Christoph Hellwig
    fi
145 6bf19c94 Christoph Hellwig
146 6bf19c94 Christoph Hellwig
    perl -e "\$in=\"$1\";" -e '
147 6bf19c94 Christoph Hellwig
    $lnk = readlink($in);
148 6bf19c94 Christoph Hellwig
    if ($lnk =~ m!^/.*!) {
149 6bf19c94 Christoph Hellwig
        print "$lnk\n";
150 6bf19c94 Christoph Hellwig
    }
151 6bf19c94 Christoph Hellwig
    else {
152 6bf19c94 Christoph Hellwig
        chomp($dir = `dirname $in`);
153 6bf19c94 Christoph Hellwig
        print "$dir/$lnk\n";
154 6bf19c94 Christoph Hellwig
    }'
155 6bf19c94 Christoph Hellwig
}
156 6bf19c94 Christoph Hellwig
157 6bf19c94 Christoph Hellwig
# make sure this script returns success
158 6bf19c94 Christoph Hellwig
/bin/true