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