]>
Commit | Line | Data |
---|---|---|
b5b8bbf5 FG |
1 | #!/usr/bin/env bash |
2 | set -e | |
c07f9fc5 | 3 | |
9f95a23c | 4 | if [ ! -e CMakeCache.txt -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() { | |
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 |
19 | if [ `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 | 25 | else |
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" | |
30 | fi | |
31 | ||
11fdf7f2 | 32 | function cleanup() { |
b5b8bbf5 | 33 | if [ -n "$precore" ]; then |
11fdf7f2 | 34 | sudo sysctl -w "${KERNCORE}=${precore}" |
b5b8bbf5 | 35 | fi |
11fdf7f2 TL |
36 | } |
37 | ||
38 | function finish() { | |
39 | cleanup | |
b5b8bbf5 FG |
40 | exit 0 |
41 | } | |
42 | ||
43 | trap finish TERM HUP INT | |
44 | ||
45 | PATH=$(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) | |
49 | PATH=$PATH:/sbin:/usr/sbin | |
50 | ||
a8e16298 TL |
51 | export LD_LIBRARY_PATH="$(pwd)/lib" |
52 | ||
b5b8bbf5 FG |
53 | # TODO: Use getops |
54 | dryrun=false | |
55 | if [[ "$1" = "--dry-run" ]]; then | |
56 | dryrun=true | |
57 | shift | |
58 | fi | |
59 | ||
60 | all=false | |
61 | if [ "$1" = "" ]; then | |
62 | all=true | |
c07f9fc5 FG |
63 | fi |
64 | ||
b5b8bbf5 FG |
65 | select=("$@") |
66 | ||
67 | location="../qa/standalone" | |
68 | ||
69 | count=0 | |
70 | errors=0 | |
71 | userargs="" | |
72 | precore="$(sysctl -n $KERNCORE)" | |
73 | # If corepattern already set, avoid having to use sudo | |
74 | if [ "$precore" = "$COREPATTERN" ]; then | |
75 | precore="" | |
76 | else | |
11fdf7f2 | 77 | sudo sysctl -w "${KERNCORE}=${COREPATTERN}" |
b5b8bbf5 | 78 | fi |
1adf2230 AA |
79 | # Clean out any cores in core target directory (currently .) |
80 | if 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.$$" | |
86 | fi | |
87 | ||
b5b8bbf5 | 88 | ulimit -c unlimited |
9f95a23c | 89 | for f in $(cd $location ; find . -mindepth 2 -perm $exec_mode -type f) |
c07f9fc5 | 90 | do |
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 | 132 | done |
11fdf7f2 | 133 | cleanup |
b5b8bbf5 FG |
134 | |
135 | if [ "$errors" != "0" ]; then | |
136 | echo "$errors TESTS FAILED, $count TOTAL TESTS" | |
137 | exit 1 | |
138 | fi | |
c07f9fc5 | 139 | |
b5b8bbf5 | 140 | echo "ALL $count TESTS PASSED" |
c07f9fc5 | 141 | exit 0 |