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