forked from loggerhead/shadowsocks-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·105 lines (89 loc) · 2.7 KB
/
test.sh
File metadata and controls
executable file
·105 lines (89 loc) · 2.7 KB
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
#!/bin/bash
work_dir=/tmp
sss_pid_path=/tmp/sss.pid
sss_log_path=/tmp/sss.log
ssc_pid_path=/tmp/ssc.pid
ssc_log_path=/tmp/ssc.log
src_dir=$(pwd)
echo_port=9000
sss_port=8111
ssc_port=8010
# run at crate root directory
cargo build --features "openssl" && mv $src_dir/target/debug/ssserver $work_dir/ssserver
cargo build --features "openssl sslocal" && mv $src_dir/target/debug/ssserver $work_dir/sslocal
python $src_dir/tests/echo_server.py &
cd $work_dir
function get_pid {
lsof -i :$1 | grep LISTEN | awk '{ print $2 }' | tail -n 1
}
function kill_all {
kill $(get_pid $echo_port) $(get_pid $ssc_port) $(get_pid $sss_port)
}
function assert {
echo "$@"
$command "$@"
if [ $? -ne 0 ]; then
echo "failed: $@"
kill_all
exit 1
fi
}
function assert_raise {
if [ $? -ne 0 ]; then
echo "$1"
kill_all
exit 1
fi
}
function run_test {
sss_version=$1
ssc_version=$2
sss_conf_name=$3
ssc_conf_name=$4
sss_conf=$src_dir/tests/config/$sss_conf_name
ssc_conf=$src_dir/tests/config/$ssc_conf_name
sss_cmd=$work_dir/ssserver
ssc_cmd=$work_dir/sslocal
if [[ "$sss_version" == "py" ]]; then
sss_cmd=ssserver
fi
if [[ "$ssc_version" == "py" ]]; then
ssc_cmd=sslocal
fi
start_sss_cmd="$sss_cmd -d start -v -c $sss_conf --pid-file $sss_pid_path --log-file $sss_log_path"
start_ssc_cmd="$ssc_cmd -d start -v -c $ssc_conf --pid-file $ssc_pid_path --log-file $ssc_log_path"
# start ssserver
if [[ "$sss_version" == "py" ]]; then
start_sss_cmd="$start_sss_cmd --forbidden-ip ''"
fi
# start ssserver & sslocal
echo "start ssserver..."
eval $start_sss_cmd
assert_raise "ERROR: start ssserver failed ($sss_conf_name)"
echo "start sslocal..."
eval $start_ssc_cmd
assert_raise "ERROR: start sslocal failed ($ssc_conf_name)"
# test
assert nosetests -q -x $src_dir/tests/test_tcp.py
assert nosetests -q -x $src_dir/tests/test_udp.py
# stop
echo "stop ssserver..."
$sss_cmd -d stop --pid-file $sss_pid_path
assert_raise "ERROR: stop ssserver failed ($sss_conf_name)"
echo "stop sslocal..."
# a bug of python version sslocal
if [[ "$ssc_version" == "py" ]]; then
kill $(get_pid $ssc_port)
else
$ssc_cmd -d stop --pid-file $ssc_pid_path
fi
assert_raise "ERROR: stop sslocal failed ($ssc_conf_name)"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
}
# ssserver sslocal
run_test rs rs rs_server.toml rs_local.toml
run_test rs py rs_server.toml ss.json
run_test rs py rs_server.toml ss_ota.json
run_test py rs ss.json rs_local.toml
run_test py rs ss.json rs_local_ota.toml
kill_all