This repository was archived by the owner on Apr 9, 2020. It is now read-only.
File tree 1 file changed +20
-17
lines changed
1 file changed +20
-17
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ # Use [ -n "$TRAVIS" ] to test for running on Travis-CI.
4
+
3
5
# Run in the scripts directory.
4
6
cd " $( dirname " ${BASH_SOURCE[0]} " ) "
5
7
6
- OPTION=" -p 8389 -k foobar"
7
8
LOCAL_PORT=" 1090"
9
+ SERVER_PORT=" 8389"
10
+ OPTION=" -p $SERVER_PORT -k foobar"
8
11
SOCKS=" 127.0.0.1:$LOCAL_PORT "
9
12
HTTP_PORT=" 8123"
10
13
14
+ wait_server () {
15
+ local port
16
+ port=$1
17
+ for i in {1..20}; do
18
+ # sleep first because this maybe called immediately after server start
19
+ sleep 0.1
20
+ nc -z -w 4 127.0.0.1 $port && break
21
+ done
22
+ }
23
+
11
24
start_http_server () {
12
25
go build http.go
13
26
./http $HTTP_PORT &
27
+ wait_server $HTTP_PORT
14
28
http_pid=$!
15
29
}
16
30
@@ -20,6 +34,8 @@ stop_http_server() {
20
34
21
35
test_get () {
22
36
local url
37
+ local target
38
+ local code
23
39
url=$1
24
40
target=$2
25
41
code=$3
@@ -56,24 +72,11 @@ test_shadowsocks() {
56
72
57
73
$SERVER $OPTION -m " $method " &
58
74
server_pid=$!
75
+ wait_server $SERVER_PORT
76
+
59
77
$LOCAL $OPTION -s 127.0.0.1 -l $LOCAL_PORT -m " $method " &
60
78
local_pid=$!
61
-
62
- # Wait server and client finish startup.
63
- sleeptime=0.1
64
- if [ -n " $TRAVIS " ]; then
65
- # On Travis we need to wait a little longer.
66
- sleeptime=1
67
- elif echo $SERVER $LOCAL | grep ' py' ; then
68
- # The python version is slow to start.
69
- if [[ $method == " table" ]]; then
70
- sleeptime=2
71
- else
72
- sleeptime=0.5
73
- fi
74
- fi
75
- echo $sleeptime
76
- sleep $sleeptime
79
+ wait_server $LOCAL_PORT
77
80
78
81
for i in {1..3}; do
79
82
if ! test_get $url " shadowsocks-go" ; then
You can’t perform that action at this time.
0 commit comments