File tree 3 files changed +55
-4
lines changed
3 files changed +55
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ script:
18
18
- pyflakes .
19
19
- coverage run tests/nose_plugin.py -v
20
20
- python setup.py sdist
21
+ - tests/test_daemon.sh
21
22
- python tests/test.py --with-coverage -c tests/aes.json
22
23
- python tests/test.py --with-coverage -c tests/aes-ctr.json
23
24
- python tests/test.py --with-coverage -c tests/aes-cfb1.json
Original file line number Diff line number Diff line change @@ -105,11 +105,14 @@ def daemon_start(pid_file, log_file):
105
105
assert pid != - 1
106
106
107
107
def handle_exit (signum , _ ):
108
- sys .exit (0 )
108
+ if signum == signal .SIGTERM :
109
+ sys .exit (0 )
110
+ sys .exit (1 )
109
111
110
112
if pid > 0 :
111
113
# parent waits for its child
112
114
signal .signal (signal .SIGINT , handle_exit )
115
+ signal .signal (signal .SIGTERM , handle_exit )
113
116
time .sleep (5 )
114
117
sys .exit (0 )
115
118
@@ -121,11 +124,16 @@ def handle_exit(signum, _):
121
124
sys .exit (1 )
122
125
123
126
print ('started' )
124
- os .kill (ppid , signal .SIGINT )
127
+ os .kill (ppid , signal .SIGTERM )
125
128
126
129
sys .stdin .close ()
127
- freopen (log_file , 'a' , sys .stdout )
128
- freopen (log_file , 'a' , sys .stderr )
130
+ try :
131
+ freopen (log_file , 'a' , sys .stdout )
132
+ freopen (log_file , 'a' , sys .stderr )
133
+ except IOError as e :
134
+ logging .error (e )
135
+ os .kill (ppid , signal .SIGINT )
136
+ sys .exit (1 )
129
137
130
138
131
139
def daemon_stop (pid_file ):
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ function test {
4
+ expected=$1
5
+ shift
6
+ echo " running test: $command $@ "
7
+ $command $@
8
+ status=$?
9
+ if [ $status -ne $expected ]; then
10
+ echo " exit $status != $expected "
11
+ exit 1
12
+ fi
13
+ echo " exit status $status == $expected "
14
+ echo OK
15
+ return
16
+ }
17
+
18
+ for module in local server
19
+ do
20
+
21
+ command=" coverage run -p -a shadowsocks/$module .py"
22
+
23
+ test 0 -c tests/aes.json -d stop --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
24
+
25
+ test 0 -c tests/aes.json -d start --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
26
+ test 0 -c tests/aes.json -d stop --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
27
+
28
+ test 0 -c tests/aes.json -d start --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
29
+ test 1 -c tests/aes.json -d start --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
30
+ test 0 -c tests/aes.json -d stop --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
31
+
32
+ test 0 -c tests/aes.json -d start --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
33
+ test 0 -c tests/aes.json -d restart --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
34
+ test 0 -c tests/aes.json -d stop --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
35
+
36
+ test 0 -c tests/aes.json -d restart --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
37
+ test 0 -c tests/aes.json -d stop --pid-file /tmp/shadowsocks.pid --log-file /tmp/shadowsocks.log
38
+
39
+ test 1 -c tests/aes.json -d start --pid-file /tmp/not_exist/shadowsocks.pid --log-file /tmp/shadowsocks.log
40
+ test 1 -c tests/aes.json -d start --pid-file /tmp/shadowsocks.pid --log-file /tmp/not_exist/shadowsocks.log
41
+
42
+ done
You can’t perform that action at this time.
0 commit comments