blob: b4fd38264cc905734f0425cd62fdb69153c14b42 [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')
22 ret = subprocess.call(argv)
David Reissbcaa2ad2008-06-10 22:55:26 +000023 if ret != 0:
24 raise Exception("subprocess failed")
25 finally:
26 # fixme: should check that server didn't die
27 os.kill(serverproc.pid, signal.SIGKILL)
28
29 # wait for shutdown
David Reiss31661412009-01-31 21:39:08 +000030 time.sleep(1)
David Reissbcaa2ad2008-06-10 22:55:26 +000031
32map(runTest, ["TForkingServer", "TThreadPoolServer",
David Reiss74421272008-11-07 23:09:31 +000033 "TThreadedServer", "TSimpleServer", "TNonblockingServer"])