Mark Slee | 5299a95 | 2007-10-05 00:13:24 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 3 | # |
| 4 | # Licensed to the Apache Software Foundation (ASF) under one |
| 5 | # or more contributor license agreements. See the NOTICE file |
| 6 | # distributed with this work for additional information |
| 7 | # regarding copyright ownership. The ASF licenses this file |
| 8 | # to you under the Apache License, Version 2.0 (the |
| 9 | # "License"); you may not use this file except in compliance |
| 10 | # with the License. You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, |
| 15 | # software distributed under the License is distributed on an |
| 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | # KIND, either express or implied. See the License for the |
| 18 | # specific language governing permissions and limitations |
| 19 | # under the License. |
| 20 | # |
| 21 | |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 22 | import time |
Mark Slee | 5299a95 | 2007-10-05 00:13:24 +0000 | [diff] [blame] | 23 | import subprocess |
| 24 | import sys |
| 25 | import os |
| 26 | import signal |
| 27 | |
David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 28 | def relfile(fname): |
| 29 | return os.path.join(os.path.dirname(__file__), fname) |
| 30 | |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 31 | FRAMED = ["TNonblockingServer"] |
| 32 | |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 33 | def runTest(server_class): |
| 34 | print "Testing ", server_class |
| 35 | serverproc = subprocess.Popen([sys.executable, relfile("TestServer.py"), server_class]) |
David Reiss | 3166141 | 2009-01-31 21:39:08 +0000 | [diff] [blame] | 36 | time.sleep(0.25) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 37 | try: |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 38 | argv = [sys.executable, relfile("TestClient.py")] |
| 39 | if server_class in FRAMED: |
| 40 | argv.append('--framed') |
David Reiss | f78ec2b | 2009-01-31 21:59:32 +0000 | [diff] [blame] | 41 | if server_class == 'THttpServer': |
| 42 | argv.append('--http=/') |
David Reiss | 7442127 | 2008-11-07 23:09:31 +0000 | [diff] [blame] | 43 | ret = subprocess.call(argv) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 44 | if ret != 0: |
| 45 | raise Exception("subprocess failed") |
| 46 | finally: |
| 47 | # fixme: should check that server didn't die |
| 48 | os.kill(serverproc.pid, signal.SIGKILL) |
| 49 | |
| 50 | # wait for shutdown |
David Reiss | 3166141 | 2009-01-31 21:39:08 +0000 | [diff] [blame] | 51 | time.sleep(1) |
David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 52 | |
David Reiss | f78ec2b | 2009-01-31 21:59:32 +0000 | [diff] [blame] | 53 | map(runTest, [ |
| 54 | "TSimpleServer", |
| 55 | "TThreadedServer", |
| 56 | "TThreadPoolServer", |
| 57 | "TForkingServer", |
| 58 | "TNonblockingServer", |
| 59 | "THttpServer", |
| 60 | ]) |