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