Skip to content

Commit

Permalink
test -d and -m
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Feb 1, 2015
1 parent 3fec6b6 commit 35e6300
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
11 changes: 8 additions & 3 deletions .jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ function run_test {
return 0
}

rm src/*.gc*
run_test ./autogen.sh
run_test ./configure --enable-debug
run_test make
run_test tests/test.py tests/google.com
run_test tests/test.py tests/facebook.com
run_test tests/test.py tests/twitter.com
run_test tests/test.py -a '-c chnroute.txt -l iplist.txt' -t tests/google.com
run_test tests/test.py -a '-c chnroute.txt -l iplist.txt' -t tests/facebook.com
run_test tests/test.py -a '-c chnroute.txt -l iplist.txt' -t tests/twitter.com
run_test tests/test.py -a '-d -c chnroute.txt -l iplist.txt' -t tests/twitter.com
run_test tests/test.py -a '-c chnroute.txt' -t tests/twitter.com
run_test tests/test.py -a '-m -c chnroute.txt' -t tests/twitter.com

gcov src/*.c
rm src/*.html
cd src && gcovr -r . --html --html-details -o index.html
gcovr -r . | grep TOTAL | rev | cut -d' ' -f 1 | rev > /tmp/chinadns-coverage

Expand Down
45 changes: 27 additions & 18 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,40 @@
import os
import signal
import time
import argparse
from subprocess import Popen

chinadns = ['src/chinadns', '-l', 'iplist.txt', '-c', 'chnroute.txt',
'-p', '15353', '-v']
parser = argparse.ArgumentParser(description='test ChinaDNS')
parser.add_argument('-a', '--arguments', type=list, default=[])
parser.add_argument('-t', '--test-command', type=str, default=None)

config = parser.parse_args()

arguments = config.arguments
chinadns = ['src/chinadns', '-p', '15353', '-v'] + arguments

p1 = Popen(chinadns, shell=False, bufsize=0, close_fds=True)
try:

with open(sys.argv[-1]) as f:
dig_cmd = f.read()
with open(config.test_command) as f:
dig_cmd = f.read()

time.sleep(1)
time.sleep(1)

p2 = Popen(dig_cmd.split() + ['-p', '15353'], shell=False,
bufsize=0, close_fds=True)
p2 = Popen(dig_cmd.split() + ['-p', '15353'], shell=False,
bufsize=0, close_fds=True)

if p2 is not None:
r = p2.wait()
if r == 0:
print 'test passed'
if p2 is not None:
r = p2.wait()
if r == 0:
print 'test passed'

for p in [p1]:
try:
os.kill(p.pid, signal.SIGTERM)
os.waitpid(p.pid, 0)
except OSError:
pass
sys.exit(r)
finally:
for p in [p1]:
try:
os.kill(p.pid, signal.SIGTERM)
os.waitpid(p.pid, 0)
except OSError:
pass

sys.exit(r)

0 comments on commit 35e6300

Please sign in to comment.