forked from asterisk/testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-local
executable file
·97 lines (87 loc) · 2.45 KB
/
run-local
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
92
93
94
95
96
97
#!/bin/bash
# run_local: run the test suite without changing the system
set -e
HERE="`(cd "\`dirname "$0"\`" >/dev/null; pwd; cd - >/dev/null)`"
cd "$HERE"
if [ -r run-local.conf ]; then
# Read environment from run-local.conf
source run-local.conf
fi
usage() {
echo >&2 "$0: Run the test suite locally:"
echo >&2 "$0 setup # Initial setup"
echo >&2 "$0 run <params> # A wrapper for ./runtests.py"
}
setup() {
# If getfenv fails the Lua version is >=5.2 and asttest won't compile
lua -e "getfenv()" 2>/dev/null && (
cd asttest
make
make install DESTDIR="$HERE/astroot"
)
(
if test -z $ASTSRCDIR; then
ASTSRCDIR=..
fi
cd $ASTSRCDIR
# The user may have already run ./configure and make
if [ ! -f config.status ]; then
./configure --enable-dev-mode $CONFIGURE_OPTIONS
make menuselect.makeopts
menuselect/menuselect --enable DONT_OPTIMIZE --enable TEST_FRAMEWORK $MENUSELECT_OPTIONS
fi
make
make install samples DESTDIR="$HERE/astroot"
)
if [ -x tests/custom/custom-setup ]; then
./tests/custom/custom-setup
fi
}
mktemp_symlink() {
template="$1"
target="$2"
for i in `seq 8`; do
link_name=`mktemp -u "$template"`
if ln -s "$HERE/astroot" "$link_name"; then
echo "$link_name"
return 0
fi
done
# We should get here. Normally symlinking should work at first shot.
# If it fails even once, it's pretty bad luck. Twice or more: a bug?
echo >&2 "$0: Failed generating temporary link. Aborting"
return 1
}
run() {
# Explicitly under /tmp as it has to be a short enough path:
# a unix socket name (asterisk.ctl) has to be no longer than
# UNIX_PATH_MAX (108) characters:
export AST_TEST_ROOT=`mktemp_symlink /tmp/ast_test_XXXXXX $HERE/astroot`
# Prepend $PATH to include locations populated by ./run-local setup
# astroot/usr/local/bin - asttest
# astroot/usr/sbin - asterisk
export PATH="$HERE/astroot/usr/local/bin:$HERE/astroot/usr/sbin:$PATH"
# Preprend ':' if LD_LIBRARY_PATH is not empty:
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
# Libraries could be in lib or lib64 so search for libasteriskssl.so
LIBDIR=`dirname $HERE/astroot/usr/lib*/libasteriskssl.so`
export LD_LIBRARY_PATH="${LIBDIR}${LD_LIBRARY_PATH}"
set +e
if test -n "$PYTHON"; then
# Use specific interpreter
$PYTHON ./runtests.py "$@"
else
./runtests.py "$@"
fi
status=$?
rm "$AST_TEST_ROOT"
set -e
return $status
}
cmd="$1"
case "$cmd" in
setup | run)
shift
"$cmd" "$@";;
*) usage; exit 1;;
esac