forked from ClusterLabs/pacemaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicSanity.sh
executable file
·107 lines (85 loc) · 2.28 KB
/
BasicSanity.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
test_home=`dirname $0`
valgrind=""
verbose=""
tests=""
if [ "$test_home" = "." ]; then
test_home="$PWD"
fi
function info() {
printf "$*\n"
}
function error() {
printf " * ERROR: $*\n"
}
function run_as_root() {
CMD="$1"
shift
ARGS="$@"
# Test might not be executable if run from source directory
chmod a+x $CMD
CMD="$CMD $ARGS $verbose"
if [ $EUID -eq 0 ]; then
$CMD
elif [ -z $TRAVIS ]; then
# sudo doesn't work in buildbot, su doesn't work in travis
echo "Enter the root password..."
su root -c "$CMD"
else
echo "Enter the root password if prompted..."
sudo -- $CMD
fi
}
info "Test home is:\t$test_home"
while true ; do
case "$1" in
all) tests="$tests pengine cli lrmd fencing"; shift;;
pengine|lrmd|pacemaker_remote|fencing|cli) tests="$tests $1"; shift;;
-V|--verbose) verbose="-V"; shift;;
-v|--valgrind) valgrind="-v"; shift;;
--) shift ; break ;;
"") break;;
*) echo "unknown option: $1"; exit 1;;
esac
done
if [ -z "$tests" ]; then
tests="pengine cli lrmd"
fi
failed=""
for t in $tests; do
info "Executing the $t regression tests"
info "============================================================"
if [ -e $test_home/$t/regression.py ]; then
# fencing, lrmd need root access
run_as_root $test_home/$t/regression.py
rc=$?
elif [ $t == "pacemaker_remote" ] && [ -e $test_home/lrmd/regression.py ]; then
# pacemaker_remote
run_as_root $test_home/lrmd/regression.py -R
rc=$?
elif [ -e $test_home/$t/regression.sh ]; then
# pengine, cli
$test_home/$t/regression.sh $verbose $valgrind
rc=$?
elif [ $t = cli -a -e $test_home/tools ]; then
# cli when run from the source tree
t=tools
$test_home/$t/regression.sh $verbose $valgrind
rc=$?
else
error "Cannot find $t test in $test_home"
rc=1
fi
if [ $rc != 0 ]; then
info "$t regression tests failed: $rc"
failed="$failed $t"
fi
info "============================================================"
info ""
info ""
done
if [ -z "$failed" ]; then
exit 0
fi
error "regression tests for $failed failed"
exit 1