~ubuntu-branches/debian/sid/lvm2/sid

« back to all changes in this revision

Viewing changes to test/lib/inittest.sh

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2014-08-19 15:37:06 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20140819153706-i1gaio8lg534dara
Tags: 2.02.109-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env bash
 
2
# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
 
3
#
 
4
# This copyrighted material is made available to anyone wishing to use,
 
5
# modify, copy, or redistribute it subject to the terms and conditions
 
6
# of the GNU General Public License v.2.
 
7
#
 
8
# You should have received a copy of the GNU General Public License
 
9
# along with this program; if not, write to the Free Software Foundation,
 
10
# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
11
 
 
12
# sanitize the environment
 
13
LANG=C
 
14
LC_ALL=C
 
15
TZ=UTC
 
16
 
 
17
# Put script name into variable, so it can used in external scripts
 
18
TESTNAME=${0##*/}
 
19
# Nice debug message
 
20
PS4='#${BASH_SOURCE[0]##*/}:${LINENO}+ '
 
21
export TESTNAME PS4
 
22
 
 
23
unset CDPATH
 
24
 
 
25
# grab some common utilities
 
26
. lib/utils
 
27
 
 
28
TESTOLDPWD=$(pwd)
 
29
COMMON_PREFIX="LVMTEST"
 
30
PREFIX="${COMMON_PREFIX}$$"
 
31
 
 
32
TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-$TESTOLDPWD}" "$PREFIX.XXXXXXXXXX") || \
 
33
        die "failed to create temporary directory in ${LVM_TEST_DIR:-$TESTOLDPWD}"
 
34
RUNNING_DMEVENTD=$(pgrep dmeventd) || true
 
35
 
 
36
export TESTOLDPWD TESTDIR COMMON_PREFIX PREFIX RUNNING_DMEVENTD
 
37
 
 
38
test -n "$BASH" && trap 'set +vx; STACKTRACE; set -vx' ERR
 
39
trap 'aux teardown' EXIT # don't forget to clean up
 
40
 
 
41
cd "$TESTDIR"
 
42
 
 
43
if test -n "$LVM_TEST_FLAVOUR"; then
 
44
        touch flavour_overrides
 
45
        env | grep ^${LVM_TEST_FLAVOUR} | while read var; do
 
46
                (echo -n "export "; echo $var | sed -e s,^${LVM_TEST_FLAVOUR}_,,) >> flavour_overrides
 
47
        done
 
48
        . flavour_overrides
 
49
fi
 
50
 
 
51
DM_DEFAULT_NAME_MANGLING_MODE=none
 
52
DM_DEV_DIR="$TESTDIR/dev"
 
53
LVM_SYSTEM_DIR="$TESTDIR/etc"
 
54
mkdir "$LVM_SYSTEM_DIR" "$TESTDIR/lib" "$DM_DEV_DIR"
 
55
if test -n "$LVM_TEST_DEVDIR" ; then
 
56
        DM_DEV_DIR=$LVM_TEST_DEVDIR
 
57
else
 
58
        mknod "$DM_DEV_DIR/testnull" c 1 3 || die "mknod failed";
 
59
        echo >"$DM_DEV_DIR/testnull" || \
 
60
                die "Filesystem does support devices in $DM_DEV_DIR (mounted with nodev?)"
 
61
        mkdir "$DM_DEV_DIR/mapper"
 
62
fi
 
63
 
 
64
# abort on the internal dm errors in the tests (allowing test user override)
 
65
DM_ABORT_ON_INTERNAL_ERRORS=${DM_ABORT_ON_INTERNAL_ERRORS:-1}
 
66
 
 
67
export DM_DEFAULT_NAME_MANGLING_MODE DM_DEV_DIR LVM_SYSTEM_DIR DM_ABORT_ON_INTERNAL_ERRORS
 
68
 
 
69
echo "$TESTNAME" >TESTNAME
 
70
 
 
71
echo "Kernel is $(uname -a)"
 
72
# Report SELinux mode
 
73
if which getenforce &>/dev/null ; then
 
74
        echo "Selinux mode is \"$(getenforce 2>/dev/null)\"."
 
75
else
 
76
        echo "Selinux mode is not installed."
 
77
fi
 
78
 
 
79
# Setting up symlink from $i to $TESTDIR/lib
 
80
find "$abs_top_builddir/daemons/dmeventd/plugins/" -name '*.so' \
 
81
        -exec ln -s -t lib "{}" +
 
82
find "$abs_top_builddir/test/lib" ! \( -name '*.sh' -o -name '*.[cdo]' \
 
83
        -o -name '*~' \)  -exec ln -s -t lib "{}" +
 
84
 
 
85
# Set vars from utils now that we have TESTDIR/PREFIX/...
 
86
prepare_test_vars
 
87
 
 
88
test -n "$BASH" && set -eE -o pipefail
 
89
 
 
90
aux lvmconf
 
91
aux prepare_clvmd
 
92
test -n "$LVM_TEST_LVMETAD" && {
 
93
        export LVM_LVMETAD_SOCKET="$TESTDIR/lvmetad.socket"
 
94
        export LVM_LVMETAD_PIDFILE="$TESTDIR/lvmetad.pid"
 
95
        aux prepare_lvmetad
 
96
}
 
97
 
 
98
# Vars for harness
 
99
echo "@TESTDIR=$TESTDIR"
 
100
echo "@PREFIX=$PREFIX"
 
101
 
 
102
set -vx