]> git.proxmox.com Git - ceph.git/blame - ceph/qa/run-standalone.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / qa / run-standalone.sh
CommitLineData
b5b8bbf5
FG
1#!/usr/bin/env bash
2set -e
c07f9fc5 3
b5b8bbf5 4if [ ! -e Makefile -o ! -d bin ]; then
c07f9fc5
FG
5 echo 'run this from the build dir'
6 exit 1
7fi
8
11fdf7f2
TL
9function get_cmake_variable() {
10 local variable=$1
11 grep "$variable" CMakeCache.txt | cut -d "=" -f 2
12}
13
14function get_python_path() {
15 local py_ver=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1)
16 if [ -z "${py_ver}" ]; then
17 if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then
18 py_ver=2
19 else
20 py_ver=3
21 fi
22 fi
23 echo $(realpath ../src/pybind):$(pwd)/lib/cython_modules/lib.$py_ver
24}
b5b8bbf5 25
c07f9fc5
FG
26if [ `uname` = FreeBSD ]; then
27 # otherwise module prettytable will not be found
11fdf7f2 28 export PYTHONPATH=$(get_python_path):/usr/local/lib/python2.7/site-packages
c07f9fc5 29 exec_mode=+111
b5b8bbf5
FG
30 KERNCORE="kern.corefile"
31 COREPATTERN="core.%N.%P"
c07f9fc5 32else
11fdf7f2 33 export PYTHONPATH=$(get_python_path)
c07f9fc5 34 exec_mode=/111
b5b8bbf5
FG
35 KERNCORE="kernel.core_pattern"
36 COREPATTERN="core.%e.%p.%t"
37fi
38
11fdf7f2 39function cleanup() {
b5b8bbf5 40 if [ -n "$precore" ]; then
11fdf7f2 41 sudo sysctl -w "${KERNCORE}=${precore}"
b5b8bbf5 42 fi
11fdf7f2
TL
43}
44
45function finish() {
46 cleanup
b5b8bbf5
FG
47 exit 0
48}
49
50trap finish TERM HUP INT
51
52PATH=$(pwd)/bin:$PATH
53
11fdf7f2
TL
54# add /sbin and /usr/sbin to PATH to find sysctl in those cases where the
55# user's PATH does not get these directories by default (e.g., tumbleweed)
56PATH=$PATH:/sbin:/usr/sbin
57
a8e16298
TL
58export LD_LIBRARY_PATH="$(pwd)/lib"
59
b5b8bbf5
FG
60# TODO: Use getops
61dryrun=false
62if [[ "$1" = "--dry-run" ]]; then
63 dryrun=true
64 shift
65fi
66
67all=false
68if [ "$1" = "" ]; then
69 all=true
c07f9fc5
FG
70fi
71
b5b8bbf5
FG
72select=("$@")
73
74location="../qa/standalone"
75
76count=0
77errors=0
78userargs=""
79precore="$(sysctl -n $KERNCORE)"
80# If corepattern already set, avoid having to use sudo
81if [ "$precore" = "$COREPATTERN" ]; then
82 precore=""
83else
11fdf7f2 84 sudo sysctl -w "${KERNCORE}=${COREPATTERN}"
b5b8bbf5 85fi
1adf2230
AA
86# Clean out any cores in core target directory (currently .)
87if ls $(dirname $(sysctl -n $KERNCORE)) | grep -q '^core\|core$' ; then
88 mkdir found.cores.$$ 2> /dev/null || true
89 for i in $(ls $(dirname $(sysctl -n $KERNCORE)) | grep '^core\|core$'); do
90 mv $i found.cores.$$
91 done
92 echo "Stray cores put in $(pwd)/found.cores.$$"
93fi
94
b5b8bbf5
FG
95ulimit -c unlimited
96for f in $(cd $location ; find . -perm $exec_mode -type f)
c07f9fc5 97do
b5b8bbf5
FG
98 f=$(echo $f | sed 's/\.\///')
99 # This is tested with misc/test-ceph-helpers.sh
100 if [[ "$f" = "ceph-helpers.sh" ]]; then
101 continue
102 fi
103 if [[ "$all" = "false" ]]; then
104 found=false
105 for c in "${!select[@]}"
106 do
11fdf7f2 107 # Get command and any arguments of subset of tests to run
b5b8bbf5
FG
108 allargs="${select[$c]}"
109 arg1=$(echo "$allargs" | cut --delimiter " " --field 1)
110 # Get user args for this selection for use below
111 userargs="$(echo $allargs | cut -s --delimiter " " --field 2-)"
11fdf7f2 112 if [[ "$arg1" = $(basename $f) ]] || [[ "$arg1" = $(dirname $f) ]]; then
b5b8bbf5
FG
113 found=true
114 break
115 fi
116 if [[ "$arg1" = "$f" ]]; then
117 found=true
118 break
119 fi
120 done
121 if [[ "$found" = "false" ]]; then
122 continue
123 fi
124 fi
125 # Don't run test-failure.sh unless explicitly specified
126 if [ "$all" = "true" -a "$f" = "special/test-failure.sh" ]; then
127 continue
128 fi
129
130 cmd="$location/$f $userargs"
131 count=$(expr $count + 1)
132 echo "--- $cmd ---"
133 if [[ "$dryrun" != "true" ]]; then
134 if ! PATH=$PATH:bin \
135 CEPH_ROOT=.. \
136 CEPH_LIB=lib \
137 LOCALRUN=yes \
138 $cmd ; then
139 echo "$f .............. FAILED"
140 errors=$(expr $errors + 1)
141 fi
142 fi
c07f9fc5 143done
11fdf7f2 144cleanup
b5b8bbf5
FG
145
146if [ "$errors" != "0" ]; then
147 echo "$errors TESTS FAILED, $count TOTAL TESTS"
148 exit 1
149fi
c07f9fc5 150
b5b8bbf5 151echo "ALL $count TESTS PASSED"
c07f9fc5 152exit 0