-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.sh
executable file
·106 lines (86 loc) · 1.74 KB
/
test.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
#!/bin/bash
source shared.sh
USAGE="Usage: $0 [tests_prefix]
"
SERVER_IP="18.18.1.2"
MAIN_SERVER_IP="18.18.1.3"
LPID=1
SKIPPED_TESTS=("test_continuous_migrate")
all_passed=1
tests_prefix=
while (( "$#" )); do
case "$1" in
-h|--help) echo "$USAGE" >&2 ; exit 0 ;;
*) tests_prefix=$1 ; shift ;;
esac
done
function prepare {
kill_iokerneld
kill_controller
sleep 5
source setup.sh >/dev/null 2>&1
sudo sync; sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
}
function run_main_server {
sudo stdbuf -o0 sh -c "ulimit -c unlimited; $1 -m -l $LPID -i $MAIN_SERVER_IP"
}
function run_server {
sudo stdbuf -o0 sh -c "ulimit -c unlimited; $1 -l $LPID -i $SERVER_IP"
}
function run_test {
BIN="$SHARED_SCRIPT_DIR/bin/$1"
run_controller 1>/dev/null 2>&1 &
disown -r
sleep 3
run_server $BIN 1>/dev/null 2>&1 &
disown -r
sleep 3
run_main_server $BIN 2>/dev/null | grep -q "Passed"
ret=$?
kill_process test_
kill_controller
sleep 5
sudo mv core core.$1 1>/dev/null 2>&1
return $ret
}
function run_tests {
TESTS=`ls bin | grep $1`
for test in $TESTS
do
if [[ " ${SKIPPED_TESTS[*]} " =~ " $test " ]]; then
continue
fi
echo "Running test $test..."
rerun_iokerneld
run_test $test
if [[ $? == 0 ]]; then
say_passed
else
say_failed
all_passed=0
fi
done
}
function cleanup {
kill_iokerneld
}
function force_cleanup {
echo -e "\nPlease wait for proper cleanups..."
kill_process test_
kill_controller
cleanup
exit 1
}
prepare
trap force_cleanup INT
if [[ -z $tests_prefix ]]; then
run_tests test_
else
run_tests $tests_prefix
fi
cleanup
if [[ $all_passed -eq 1 ]]; then
exit 0
else
exit 1
fi