]>
Commit | Line | Data |
---|---|---|
b5b8bbf5 FG |
1 | #!/usr/bin/env bash |
2 | set -e | |
c07f9fc5 | 3 | |
b5b8bbf5 | 4 | if [ ! -e Makefile -o ! -d bin ]; then |
c07f9fc5 FG |
5 | echo 'run this from the build dir' |
6 | exit 1 | |
7 | fi | |
8 | ||
11fdf7f2 TL |
9 | function get_cmake_variable() { |
10 | local variable=$1 | |
11 | grep "$variable" CMakeCache.txt | cut -d "=" -f 2 | |
12 | } | |
13 | ||
14 | function 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 |
26 | if [ `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 | 32 | else |
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" | |
37 | fi | |
38 | ||
11fdf7f2 | 39 | function cleanup() { |
b5b8bbf5 | 40 | if [ -n "$precore" ]; then |
11fdf7f2 | 41 | sudo sysctl -w "${KERNCORE}=${precore}" |
b5b8bbf5 | 42 | fi |
11fdf7f2 TL |
43 | } |
44 | ||
45 | function finish() { | |
46 | cleanup | |
b5b8bbf5 FG |
47 | exit 0 |
48 | } | |
49 | ||
50 | trap finish TERM HUP INT | |
51 | ||
52 | PATH=$(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) | |
56 | PATH=$PATH:/sbin:/usr/sbin | |
57 | ||
a8e16298 TL |
58 | export LD_LIBRARY_PATH="$(pwd)/lib" |
59 | ||
b5b8bbf5 FG |
60 | # TODO: Use getops |
61 | dryrun=false | |
62 | if [[ "$1" = "--dry-run" ]]; then | |
63 | dryrun=true | |
64 | shift | |
65 | fi | |
66 | ||
67 | all=false | |
68 | if [ "$1" = "" ]; then | |
69 | all=true | |
c07f9fc5 FG |
70 | fi |
71 | ||
b5b8bbf5 FG |
72 | select=("$@") |
73 | ||
74 | location="../qa/standalone" | |
75 | ||
76 | count=0 | |
77 | errors=0 | |
78 | userargs="" | |
79 | precore="$(sysctl -n $KERNCORE)" | |
80 | # If corepattern already set, avoid having to use sudo | |
81 | if [ "$precore" = "$COREPATTERN" ]; then | |
82 | precore="" | |
83 | else | |
11fdf7f2 | 84 | sudo sysctl -w "${KERNCORE}=${COREPATTERN}" |
b5b8bbf5 | 85 | fi |
1adf2230 AA |
86 | # Clean out any cores in core target directory (currently .) |
87 | if 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.$$" | |
93 | fi | |
94 | ||
b5b8bbf5 FG |
95 | ulimit -c unlimited |
96 | for f in $(cd $location ; find . -perm $exec_mode -type f) | |
c07f9fc5 | 97 | do |
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 | 143 | done |
11fdf7f2 | 144 | cleanup |
b5b8bbf5 FG |
145 | |
146 | if [ "$errors" != "0" ]; then | |
147 | echo "$errors TESTS FAILED, $count TOTAL TESTS" | |
148 | exit 1 | |
149 | fi | |
c07f9fc5 | 150 | |
b5b8bbf5 | 151 | echo "ALL $count TESTS PASSED" |
c07f9fc5 | 152 | exit 0 |