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 | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 12 | def runTest(server_class): |
| 13 | print "Testing ", server_class |
| 14 | serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py"), server_class]) |
| 15 | try: |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 16 | |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 17 | ret = subprocess.call([sys.executable, relfile("TestClient.py")]) |
| 18 | if ret != 0: |
| 19 | raise Exception("subprocess failed") |
| 20 | finally: |
| 21 | # fixme: should check that server didn't die |
| 22 | os.kill(serverproc.pid, signal.SIGKILL) |
| 23 | |
| 24 | # wait for shutdown |
| 25 | time.sleep(5) |
| 26 | |
| 27 | map(runTest, ["TForkingServer", "TThreadPoolServer", |
| 28 | "TThreadedServer", "TSimpleServer"]) |