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