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]) |
David Reiss | 3166141 | 2009-01-31 21:39:08 +0000 | [diff] [blame] | 17 | time.sleep(0.25) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 18 | try: |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 19 | argv = [sys.executable, relfile("TestClient.py")] |
| 20 | if server_class in FRAMED: |
| 21 | argv.append('--framed') |
David Reiss | f78ec2b | 2009-01-31 21:59:32 +0000 | [diff] [blame] | 22 | if server_class == 'THttpServer': |
| 23 | argv.append('--http=/') |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 24 | ret = subprocess.call(argv) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 25 | 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 Reiss | 3166141 | 2009-01-31 21:39:08 +0000 | [diff] [blame] | 32 | time.sleep(1) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 33 | |
David Reiss | f78ec2b | 2009-01-31 21:59:32 +0000 | [diff] [blame] | 34 | map(runTest, [ |
| 35 | "TSimpleServer", |
| 36 | "TThreadedServer", |
| 37 | "TThreadPoolServer", |
| 38 | "TForkingServer", |
| 39 | "TNonblockingServer", |
| 40 | "THttpServer", |
| 41 | ]) |