blob: 34f883ecfccc527fa0cfabec622e1722750eeafb [file] [log] [blame]
Mark Slee5299a952007-10-05 00:13:24 +00001#!/usr/bin/env python
2
David Reissbcaa2ad2008-06-10 22:55:26 +00003import time
Mark Slee5299a952007-10-05 00:13:24 +00004import subprocess
5import sys
6import os
7import signal
8
David Reiss2a4bfd62008-04-07 23:45:00 +00009def relfile(fname):
10 return os.path.join(os.path.dirname(__file__), fname)
11
David Reiss74421272008-11-07 23:09:31 +000012FRAMED = ["TNonblockingServer"]
13
David Reissbcaa2ad2008-06-10 22:55:26 +000014def runTest(server_class):
15 print "Testing ", server_class
16 serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py"), server_class])
David Reiss31661412009-01-31 21:39:08 +000017 time.sleep(0.25)
David Reissbcaa2ad2008-06-10 22:55:26 +000018 try:
David Reiss74421272008-11-07 23:09:31 +000019 argv = [sys.executable, relfile("TestClient.py")]
20 if server_class in FRAMED:
21 argv.append('--framed')
David Reissf78ec2b2009-01-31 21:59:32 +000022 if server_class == 'THttpServer':
23 argv.append('--http=/')
David Reiss74421272008-11-07 23:09:31 +000024 ret = subprocess.call(argv)
David Reissbcaa2ad2008-06-10 22:55:26 +000025 if ret != 0:
26 raise Exception("subprocess failed")
27 finally:
28 # fixme: should check that server didn't die
29 os.kill(serverproc.pid, signal.SIGKILL)
30
31 # wait for shutdown
David Reiss31661412009-01-31 21:39:08 +000032 time.sleep(1)
David Reissbcaa2ad2008-06-10 22:55:26 +000033
David Reissf78ec2b2009-01-31 21:59:32 +000034map(runTest, [
35 "TSimpleServer",
36 "TThreadedServer",
37 "TThreadPoolServer",
38 "TForkingServer",
39 "TNonblockingServer",
40 "THttpServer",
41 ])