summaryrefslogtreecommitdiffstats
path: root/tests/qemu-iotests/common.config
blob: c7f0a7a7e08a1a23cb91392dbea91a3ba54d78a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#
# 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
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# all tests should use a common language setting to prevent golden
# output mismatches.
export LANG=C

PATH=".:$PATH"

HOSTOS=`uname -s`
arch=`uname -m`

export PWD=`pwd`

export _QEMU_HANDLE=0

# make sure we have a standard umask
umask 022

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

QEMU_IMG_EXTRA_ARGS=
if [ "$IMGOPTSSYNTAX" = "true" ]; then
    QEMU_IMG_EXTRA_ARGS="--image-opts $QEMU_IMG_EXTRA_ARGS"
    if [ -n "$IMGKEYSECRET" ]; then
        QEMU_IMG_EXTRA_ARGS="--object secret,id=keysec0,data=$IMGKEYSECRET $QEMU_IMG_EXTRA_ARGS"
    fi
fi
export QEMU_IMG_EXTRA_ARGS


default_machine=$($QEMU_PROG -machine help | sed -n '/(default)/ s/ .*//p')
default_alias_machine=$($QEMU_PROG -machine help | \
   sed -n "/(alias of $default_machine)/ { s/ .*//p; q; }")
if [[ "$default_alias_machine" ]]; then
    default_machine="$default_alias_machine"
fi

export QEMU_DEFAULT_MACHINE="$default_machine"

if [ -z "$TEST_DIR" ]; then
        TEST_DIR=`pwd`/scratch
fi

QEMU_TEST_DIR="${TEST_DIR}"

if [ ! -e "$TEST_DIR" ]; then
        mkdir "$TEST_DIR"
fi

if [ ! -d "$TEST_DIR" ]; then
    echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
    exit 1
fi

export TEST_DIR

if [ -z "$SAMPLE_IMG_DIR" ]; then
        SAMPLE_IMG_DIR="$source_iotests/sample_images"
fi

if [ ! -d "$SAMPLE_IMG_DIR" ]; then
    echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
    exit 1
fi

export SAMPLE_IMG_DIR

# make sure this script returns success
true