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