add tests for command line args
This commit is contained in:
parent
6bbf347d0e
commit
a88d47883b
2 changed files with 30 additions and 12 deletions
|
@ -28,3 +28,5 @@ script:
|
||||||
- python tests/test.py -c tests/server-multi-ports.json
|
- python tests/test.py -c tests/server-multi-ports.json
|
||||||
- python tests/test.py -c tests/server-multi-passwd.json tests/server-multi-passwd-client-side.json
|
- python tests/test.py -c tests/server-multi-passwd.json tests/server-multi-passwd-client-side.json
|
||||||
- python tests/test.py -c tests/workers.json
|
- python tests/test.py -c tests/workers.json
|
||||||
|
- python tests/test.py -b "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388" -a "-m rc4-md5 -k testrc4 -s 127.0.0.1 -p 8388 -l 1081"
|
||||||
|
- python tests/test.py -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081"
|
||||||
|
|
|
@ -29,23 +29,39 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import select
|
import select
|
||||||
import time
|
import time
|
||||||
|
import argparse
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
sys.path.insert(0, './')
|
sys.path.insert(0, './')
|
||||||
|
|
||||||
if sys.argv[-3] == '-c':
|
python = 'python'
|
||||||
client_config = sys.argv[-1]
|
|
||||||
server_config = sys.argv[-2]
|
|
||||||
elif sys.argv[-2] == '-c':
|
|
||||||
client_config = sys.argv[-1]
|
|
||||||
server_config = sys.argv[-1]
|
|
||||||
else:
|
|
||||||
raise Exception('usage: test.py -c server_conf [client_conf]')
|
|
||||||
|
|
||||||
p1 = Popen(['python', 'shadowsocks/server.py', '-c', server_config],
|
parser = argparse.ArgumentParser(description='test Shadowsocks')
|
||||||
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
parser.add_argument('-c', '--client-conf', type=str, default=None)
|
||||||
p2 = Popen(['python', 'shadowsocks/local.py', '-c', client_config],
|
parser.add_argument('-s', '--server-conf', type=str, default=None)
|
||||||
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
parser.add_argument('-a', '--client-args', type=str, default=None)
|
||||||
|
parser.add_argument('-b', '--server-args', type=str, default=None)
|
||||||
|
|
||||||
|
config = parser.parse_args()
|
||||||
|
|
||||||
|
client_args = [python, 'shadowsocks/local.py']
|
||||||
|
server_args = [python, 'shadowsocks/server.py']
|
||||||
|
|
||||||
|
if config.client_conf:
|
||||||
|
client_args.extend(['-c', config.client_conf])
|
||||||
|
if config.server_conf:
|
||||||
|
server_args.extend(['-c', config.server_conf])
|
||||||
|
else:
|
||||||
|
server_args.extend(['-c', config.client_conf])
|
||||||
|
if config.client_args:
|
||||||
|
client_args.extend(config.client_args.split())
|
||||||
|
if config.server_args:
|
||||||
|
server_args.extend(config.server_args.split())
|
||||||
|
else:
|
||||||
|
server_args.extend(config.client_args.split())
|
||||||
|
|
||||||
|
p1 = Popen(server_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||||
|
p2 = Popen(client_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||||
p3 = None
|
p3 = None
|
||||||
p4 = None
|
p4 = None
|
||||||
p3_fin = False
|
p3_fin = False
|
||||||
|
|
Loading…
Add table
Reference in a new issue