Mark Slee | 5299a95 | 2007-10-05 00:13:24 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 3 | import time |
Mark Slee | 5299a95 | 2007-10-05 00:13:24 +0000 | [diff] [blame] | 4 | import subprocess |
| 5 | import sys |
| 6 | import os |
| 7 | import signal |
| 8 | |
David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 9 | def relfile(fname): |
| 10 | return os.path.join(os.path.dirname(__file__), fname) |
| 11 | |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame^] | 12 | FRAMED = ["TNonblockingServer"] |
| 13 | |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 14 | def runTest(server_class): |
| 15 | print "Testing ", server_class |
| 16 | serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py"), server_class]) |
| 17 | try: |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame^] | 18 | argv = [sys.executable, relfile("TestClient.py")] |
| 19 | if server_class in FRAMED: |
| 20 | argv.append('--framed') |
| 21 | ret = subprocess.call(argv) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 22 | if ret != 0: |
| 23 | raise Exception("subprocess failed") |
| 24 | finally: |
| 25 | # fixme: should check that server didn't die |
| 26 | os.kill(serverproc.pid, signal.SIGKILL) |
| 27 | |
| 28 | # wait for shutdown |
| 29 | time.sleep(5) |
| 30 | |
| 31 | map(runTest, ["TForkingServer", "TThreadPoolServer", |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame^] | 32 | "TThreadedServer", "TSimpleServer", "TNonblockingServer"]) |