2017-07-31 16:27:15 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2017-07-24 21:45:22 +00:00
|
|
|
|
2019-05-30 15:43:31 +00:00
|
|
|
if [ ! -e CMakeCache.txt -o ! -d bin ]; then
|
2017-07-24 21:45:22 +00:00
|
|
|
echo 'run this from the build dir'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-02-26 06:38:49 +00:00
|
|
|
function get_cmake_variable() {
|
|
|
|
local variable=$1
|
|
|
|
grep "$variable" CMakeCache.txt | cut -d "=" -f 2
|
|
|
|
}
|
|
|
|
|
2018-02-28 14:22:03 +00:00
|
|
|
function get_python_path() {
|
2018-02-26 06:38:49 +00:00
|
|
|
local py_ver=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1)
|
|
|
|
if [ -z "${py_ver}" ]; then
|
|
|
|
if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then
|
|
|
|
py_ver=2
|
|
|
|
else
|
|
|
|
py_ver=3
|
|
|
|
fi
|
|
|
|
fi
|
2018-08-17 22:21:57 +00:00
|
|
|
echo $(realpath ../src/pybind):$(pwd)/lib/cython_modules/lib.$py_ver
|
2018-02-26 06:38:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-26 10:01:37 +00:00
|
|
|
if [ `uname` = FreeBSD ]; then
|
2017-07-28 06:18:09 +00:00
|
|
|
# otherwise module prettytable will not be found
|
2018-02-28 14:22:03 +00:00
|
|
|
export PYTHONPATH=$(get_python_path):/usr/local/lib/python2.7/site-packages
|
2017-07-28 06:18:09 +00:00
|
|
|
exec_mode=+111
|
2017-08-04 19:34:47 +00:00
|
|
|
KERNCORE="kern.corefile"
|
|
|
|
COREPATTERN="core.%N.%P"
|
2017-07-28 06:18:09 +00:00
|
|
|
else
|
2018-02-28 14:22:03 +00:00
|
|
|
export PYTHONPATH=$(get_python_path)
|
2017-07-28 06:18:09 +00:00
|
|
|
exec_mode=/111
|
2017-08-04 19:34:47 +00:00
|
|
|
KERNCORE="kernel.core_pattern"
|
|
|
|
COREPATTERN="core.%e.%p.%t"
|
2017-07-26 10:01:37 +00:00
|
|
|
fi
|
|
|
|
|
2018-02-14 20:57:57 +00:00
|
|
|
function cleanup() {
|
2017-08-15 01:17:09 +00:00
|
|
|
if [ -n "$precore" ]; then
|
2019-02-15 00:47:29 +00:00
|
|
|
sudo sysctl -w "${KERNCORE}=${precore}"
|
2017-08-15 01:17:09 +00:00
|
|
|
fi
|
2018-02-14 20:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function finish() {
|
|
|
|
cleanup
|
2017-08-15 01:17:09 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
trap finish TERM HUP INT
|
|
|
|
|
2017-07-31 16:27:15 +00:00
|
|
|
PATH=$(pwd)/bin:$PATH
|
|
|
|
|
2018-02-20 15:42:39 +00:00
|
|
|
# add /sbin and /usr/sbin to PATH to find sysctl in those cases where the
|
|
|
|
# user's PATH does not get these directories by default (e.g., tumbleweed)
|
|
|
|
PATH=$PATH:/sbin:/usr/sbin
|
|
|
|
|
2019-02-12 00:22:40 +00:00
|
|
|
export LD_LIBRARY_PATH="$(pwd)/lib"
|
|
|
|
|
2017-07-31 16:27:15 +00:00
|
|
|
# TODO: Use getops
|
|
|
|
dryrun=false
|
|
|
|
if [[ "$1" = "--dry-run" ]]; then
|
|
|
|
dryrun=true
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
all=false
|
|
|
|
if [ "$1" = "" ]; then
|
|
|
|
all=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
select=("$@")
|
|
|
|
|
|
|
|
location="../qa/standalone"
|
|
|
|
|
|
|
|
count=0
|
|
|
|
errors=0
|
2017-08-01 23:04:10 +00:00
|
|
|
userargs=""
|
2017-08-04 19:34:47 +00:00
|
|
|
precore="$(sysctl -n $KERNCORE)"
|
2017-08-18 17:00:10 +00:00
|
|
|
# If corepattern already set, avoid having to use sudo
|
|
|
|
if [ "$precore" = "$COREPATTERN" ]; then
|
|
|
|
precore=""
|
|
|
|
else
|
2019-02-15 00:47:29 +00:00
|
|
|
sudo sysctl -w "${KERNCORE}=${COREPATTERN}"
|
2017-08-18 17:00:10 +00:00
|
|
|
fi
|
2018-06-08 22:31:35 +00:00
|
|
|
# Clean out any cores in core target directory (currently .)
|
|
|
|
if ls $(dirname $(sysctl -n $KERNCORE)) | grep -q '^core\|core$' ; then
|
|
|
|
mkdir found.cores.$$ 2> /dev/null || true
|
|
|
|
for i in $(ls $(dirname $(sysctl -n $KERNCORE)) | grep '^core\|core$'); do
|
|
|
|
mv $i found.cores.$$
|
|
|
|
done
|
|
|
|
echo "Stray cores put in $(pwd)/found.cores.$$"
|
|
|
|
fi
|
|
|
|
|
2017-08-04 19:34:47 +00:00
|
|
|
ulimit -c unlimited
|
2017-07-31 16:27:15 +00:00
|
|
|
for f in $(cd $location ; find . -perm $exec_mode -type f)
|
2017-07-24 21:45:22 +00:00
|
|
|
do
|
2017-07-31 16:27:15 +00:00
|
|
|
f=$(echo $f | sed 's/\.\///')
|
2017-08-01 20:42:29 +00:00
|
|
|
# This is tested with misc/test-ceph-helpers.sh
|
|
|
|
if [[ "$f" = "ceph-helpers.sh" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2017-07-31 16:27:15 +00:00
|
|
|
if [[ "$all" = "false" ]]; then
|
|
|
|
found=false
|
|
|
|
for c in "${!select[@]}"
|
|
|
|
do
|
2018-08-26 17:18:21 +00:00
|
|
|
# Get command and any arguments of subset of tests to run
|
2017-08-01 23:04:10 +00:00
|
|
|
allargs="${select[$c]}"
|
|
|
|
arg1=$(echo "$allargs" | cut --delimiter " " --field 1)
|
|
|
|
# Get user args for this selection for use below
|
|
|
|
userargs="$(echo $allargs | cut -s --delimiter " " --field 2-)"
|
2018-08-26 17:18:21 +00:00
|
|
|
if [[ "$arg1" = $(basename $f) ]] || [[ "$arg1" = $(dirname $f) ]]; then
|
2017-07-31 16:27:15 +00:00
|
|
|
found=true
|
|
|
|
break
|
|
|
|
fi
|
2017-08-01 23:04:10 +00:00
|
|
|
if [[ "$arg1" = "$f" ]]; then
|
2017-07-31 16:27:15 +00:00
|
|
|
found=true
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ "$found" = "false" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
2017-07-31 16:28:12 +00:00
|
|
|
# Don't run test-failure.sh unless explicitly specified
|
|
|
|
if [ "$all" = "true" -a "$f" = "special/test-failure.sh" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2017-08-01 23:04:10 +00:00
|
|
|
cmd="$location/$f $userargs"
|
2017-07-31 16:27:15 +00:00
|
|
|
count=$(expr $count + 1)
|
2017-08-01 23:04:10 +00:00
|
|
|
echo "--- $cmd ---"
|
2017-07-31 16:27:15 +00:00
|
|
|
if [[ "$dryrun" != "true" ]]; then
|
|
|
|
if ! PATH=$PATH:bin \
|
|
|
|
CEPH_ROOT=.. \
|
|
|
|
CEPH_LIB=lib \
|
2017-08-04 19:34:47 +00:00
|
|
|
LOCALRUN=yes \
|
2019-04-10 04:33:42 +00:00
|
|
|
time -f "Elapsed %E (%e seconds)" $cmd ; then
|
2017-07-31 16:27:15 +00:00
|
|
|
echo "$f .............. FAILED"
|
|
|
|
errors=$(expr $errors + 1)
|
|
|
|
fi
|
|
|
|
fi
|
2017-07-24 21:45:22 +00:00
|
|
|
done
|
2018-02-14 20:57:57 +00:00
|
|
|
cleanup
|
2017-07-24 21:45:22 +00:00
|
|
|
|
2017-07-31 16:27:15 +00:00
|
|
|
if [ "$errors" != "0" ]; then
|
|
|
|
echo "$errors TESTS FAILED, $count TOTAL TESTS"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "ALL $count TESTS PASSED"
|
2017-07-24 21:45:22 +00:00
|
|
|
exit 0
|