| 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 |  | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 22 | from __future__ import division | 
| Nobuaki Sukegawa | 760511f | 2015-11-06 21:24:16 +0900 | [diff] [blame] | 23 | from __future__ import print_function | 
| Nobuaki Sukegawa | 06e8fd4 | 2016-02-28 12:50:03 +0900 | [diff] [blame] | 24 | import platform | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 25 | import copy | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 26 | import os | 
|  | 27 | import signal | 
| Roger Meier | 9b32853 | 2014-04-21 21:22:54 +0200 | [diff] [blame] | 28 | import socket | 
| Mark Slee | 5299a95 | 2007-10-05 00:13:24 +0000 | [diff] [blame] | 29 | import subprocess | 
|  | 30 | import sys | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 31 | import time | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 32 | from optparse import OptionParser | 
|  | 33 |  | 
| Nobuaki Sukegawa | 7af189a | 2016-02-11 16:21:01 +0900 | [diff] [blame] | 34 | from util import local_libpath | 
|  | 35 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 36 | SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 37 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 38 | SCRIPTS = [ | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 39 | 'FastbinaryTest.py', | 
|  | 40 | 'TestFrozen.py', | 
| Ozan Can Altiok | e46419b | 2018-03-20 15:02:28 +0300 | [diff] [blame] | 41 | 'TestRenderedDoubleConstants.py', | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 42 | 'TSimpleJSONProtocolTest.py', | 
|  | 43 | 'SerializationTest.py', | 
|  | 44 | 'TestEof.py', | 
|  | 45 | 'TestSyntax.py', | 
|  | 46 | 'TestSocket.py', | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 47 | ] | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 48 | FRAMED = ["TNonblockingServer"] | 
| Bryan Duxbury | 1606659 | 2011-03-22 18:06:04 +0000 | [diff] [blame] | 49 | SKIP_ZLIB = ['TNonblockingServer', 'THttpServer'] | 
| Nobuaki Sukegawa | 4626fd8 | 2017-02-12 21:11:36 +0900 | [diff] [blame] | 50 | SKIP_SSL = ['THttpServer'] | 
| Roger Meier | 6857b7f | 2015-09-16 19:53:07 +0200 | [diff] [blame] | 51 | EXTRA_DELAY = dict(TProcessPoolServer=5.5) | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 52 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 53 | PROTOS = [ | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 54 | 'accel', | 
| Nobuaki Sukegawa | 6525f6a | 2016-02-11 13:58:39 +0900 | [diff] [blame] | 55 | 'accelc', | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 56 | 'binary', | 
|  | 57 | 'compact', | 
|  | 58 | 'json', | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 59 | ] | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 60 |  | 
| Nobuaki Sukegawa | 06e8fd4 | 2016-02-28 12:50:03 +0900 | [diff] [blame] | 61 |  | 
|  | 62 | def default_servers(): | 
|  | 63 | servers = [ | 
|  | 64 | 'TSimpleServer', | 
|  | 65 | 'TThreadedServer', | 
|  | 66 | 'TThreadPoolServer', | 
|  | 67 | 'TNonblockingServer', | 
|  | 68 | 'THttpServer', | 
|  | 69 | ] | 
|  | 70 | if platform.system() != 'Windows': | 
|  | 71 | servers.append('TProcessPoolServer') | 
|  | 72 | servers.append('TForkingServer') | 
|  | 73 | return servers | 
| Bryan Duxbury | 59d4efd | 2011-03-21 17:38:22 +0000 | [diff] [blame] | 74 |  | 
| Mark Slee | 5299a95 | 2007-10-05 00:13:24 +0000 | [diff] [blame] | 75 |  | 
| David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 76 | def relfile(fname): | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 77 | return os.path.join(SCRIPT_DIR, fname) | 
| David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 78 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 79 |  | 
| Nobuaki Sukegawa | a3b88a0 | 2016-01-06 20:44:17 +0900 | [diff] [blame] | 80 | def setup_pypath(libdir, gendir): | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 81 | dirs = [libdir, gendir] | 
|  | 82 | env = copy.deepcopy(os.environ) | 
|  | 83 | pypath = env.get('PYTHONPATH', None) | 
|  | 84 | if pypath: | 
|  | 85 | dirs.append(pypath) | 
| Nobuaki Sukegawa | 06e8fd4 | 2016-02-28 12:50:03 +0900 | [diff] [blame] | 86 | env['PYTHONPATH'] = os.pathsep.join(dirs) | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 87 | if gendir.endswith('gen-py-no_utf8strings'): | 
|  | 88 | env['THRIFT_TEST_PY_NO_UTF8STRINGS'] = '1' | 
|  | 89 | return env | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 90 |  | 
|  | 91 |  | 
| Nobuaki Sukegawa | a3b88a0 | 2016-01-06 20:44:17 +0900 | [diff] [blame] | 92 | def runScriptTest(libdir, genbase, genpydir, script): | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 93 | env = setup_pypath(libdir, os.path.join(genbase, genpydir)) | 
|  | 94 | script_args = [sys.executable, relfile(script)] | 
|  | 95 | print('\nTesting script: %s\n----' % (' '.join(script_args))) | 
|  | 96 | ret = subprocess.call(script_args, env=env) | 
|  | 97 | if ret != 0: | 
|  | 98 | print('*** FAILED ***', file=sys.stderr) | 
|  | 99 | print('LIBDIR: %s' % libdir, file=sys.stderr) | 
|  | 100 | print('PY_GEN: %s' % genpydir, file=sys.stderr) | 
|  | 101 | print('SCRIPT: %s' % script, file=sys.stderr) | 
|  | 102 | raise Exception("Script subprocess failed, retcode=%d, args: %s" % (ret, ' '.join(script_args))) | 
| Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 103 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 104 |  | 
| Nobuaki Sukegawa | a3b88a0 | 2016-01-06 20:44:17 +0900 | [diff] [blame] | 105 | def runServiceTest(libdir, genbase, genpydir, server_class, proto, port, use_zlib, use_ssl, verbose): | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 106 | env = setup_pypath(libdir, os.path.join(genbase, genpydir)) | 
|  | 107 | # Build command line arguments | 
|  | 108 | server_args = [sys.executable, relfile('TestServer.py')] | 
|  | 109 | cli_args = [sys.executable, relfile('TestClient.py')] | 
|  | 110 | for which in (server_args, cli_args): | 
|  | 111 | which.append('--protocol=%s' % proto)  # accel, binary, compact or json | 
|  | 112 | which.append('--port=%d' % port)  # default to 9090 | 
|  | 113 | if use_zlib: | 
|  | 114 | which.append('--zlib') | 
|  | 115 | if use_ssl: | 
|  | 116 | which.append('--ssl') | 
|  | 117 | if verbose == 0: | 
|  | 118 | which.append('-q') | 
|  | 119 | if verbose == 2: | 
|  | 120 | which.append('-v') | 
|  | 121 | # server-specific option to select server class | 
|  | 122 | server_args.append(server_class) | 
|  | 123 | # client-specific cmdline options | 
|  | 124 | if server_class in FRAMED: | 
|  | 125 | cli_args.append('--transport=framed') | 
|  | 126 | else: | 
|  | 127 | cli_args.append('--transport=buffered') | 
|  | 128 | if server_class == 'THttpServer': | 
|  | 129 | cli_args.append('--http=/') | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 130 | if verbose > 0: | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 131 | print('Testing server %s: %s' % (server_class, ' '.join(server_args))) | 
|  | 132 | serverproc = subprocess.Popen(server_args, env=env) | 
|  | 133 |  | 
|  | 134 | def ensureServerAlive(): | 
|  | 135 | if serverproc.poll() is not None: | 
|  | 136 | print(('FAIL: Server process (%s) failed with retcode %d') | 
|  | 137 | % (' '.join(server_args), serverproc.returncode)) | 
|  | 138 | raise Exception('Server subprocess %s died, args: %s' | 
|  | 139 | % (server_class, ' '.join(server_args))) | 
|  | 140 |  | 
|  | 141 | # Wait for the server to start accepting connections on the given port. | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 142 | sleep_time = 0.1  # Seconds | 
|  | 143 | max_attempts = 100 | 
| Nobuaki Sukegawa | e9b3234 | 2016-02-27 03:44:02 +0900 | [diff] [blame] | 144 | attempt = 0 | 
|  | 145 | while True: | 
|  | 146 | sock4 = socket.socket() | 
|  | 147 | sock6 = socket.socket(socket.AF_INET6) | 
|  | 148 | try: | 
|  | 149 | if sock4.connect_ex(('127.0.0.1', port)) == 0 \ | 
|  | 150 | or sock6.connect_ex(('::1', port)) == 0: | 
|  | 151 | break | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 152 | attempt += 1 | 
|  | 153 | if attempt >= max_attempts: | 
|  | 154 | raise Exception("TestServer not ready on port %d after %.2f seconds" | 
|  | 155 | % (port, sleep_time * attempt)) | 
|  | 156 | ensureServerAlive() | 
|  | 157 | time.sleep(sleep_time) | 
| Nobuaki Sukegawa | e9b3234 | 2016-02-27 03:44:02 +0900 | [diff] [blame] | 158 | finally: | 
|  | 159 | sock4.close() | 
|  | 160 | sock6.close() | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 161 |  | 
|  | 162 | try: | 
|  | 163 | if verbose > 0: | 
|  | 164 | print('Testing client: %s' % (' '.join(cli_args))) | 
|  | 165 | ret = subprocess.call(cli_args, env=env) | 
|  | 166 | if ret != 0: | 
|  | 167 | print('*** FAILED ***', file=sys.stderr) | 
|  | 168 | print('LIBDIR: %s' % libdir, file=sys.stderr) | 
|  | 169 | print('PY_GEN: %s' % genpydir, file=sys.stderr) | 
|  | 170 | raise Exception("Client subprocess failed, retcode=%d, args: %s" % (ret, ' '.join(cli_args))) | 
|  | 171 | finally: | 
|  | 172 | # check that server didn't die | 
|  | 173 | ensureServerAlive() | 
|  | 174 | extra_sleep = EXTRA_DELAY.get(server_class, 0) | 
|  | 175 | if extra_sleep > 0 and verbose > 0: | 
|  | 176 | print('Giving %s (proto=%s,zlib=%s,ssl=%s) an extra %d seconds for child' | 
|  | 177 | 'processes to terminate via alarm' | 
|  | 178 | % (server_class, proto, use_zlib, use_ssl, extra_sleep)) | 
|  | 179 | time.sleep(extra_sleep) | 
| Nobuaki Sukegawa | 06e8fd4 | 2016-02-28 12:50:03 +0900 | [diff] [blame] | 180 | sig = signal.SIGKILL if platform.system() != 'Windows' else signal.SIGABRT | 
|  | 181 | os.kill(serverproc.pid, sig) | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 182 | serverproc.wait() | 
| David Reiss | bcaa2ad | 2008-06-10 22:55:26 +0000 | [diff] [blame] | 183 |  | 
| Roger Meier | 7615072 | 2014-05-31 22:22:07 +0200 | [diff] [blame] | 184 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 185 | class TestCases(object): | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 186 | def __init__(self, genbase, libdir, port, gendirs, servers, verbose): | 
|  | 187 | self.genbase = genbase | 
|  | 188 | self.libdir = libdir | 
|  | 189 | self.port = port | 
|  | 190 | self.verbose = verbose | 
|  | 191 | self.gendirs = gendirs | 
|  | 192 | self.servers = servers | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 193 |  | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 194 | def default_conf(self): | 
|  | 195 | return { | 
|  | 196 | 'gendir': self.gendirs[0], | 
|  | 197 | 'server': self.servers[0], | 
|  | 198 | 'proto': PROTOS[0], | 
|  | 199 | 'zlib': False, | 
|  | 200 | 'ssl': False, | 
|  | 201 | } | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 202 |  | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 203 | def run(self, conf, test_count): | 
|  | 204 | with_zlib = conf['zlib'] | 
|  | 205 | with_ssl = conf['ssl'] | 
|  | 206 | try_server = conf['server'] | 
|  | 207 | try_proto = conf['proto'] | 
|  | 208 | genpydir = conf['gendir'] | 
|  | 209 | # skip any servers that don't work with the Zlib transport | 
|  | 210 | if with_zlib and try_server in SKIP_ZLIB: | 
|  | 211 | return False | 
|  | 212 | # skip any servers that don't work with SSL | 
|  | 213 | if with_ssl and try_server in SKIP_SSL: | 
|  | 214 | return False | 
|  | 215 | if self.verbose > 0: | 
|  | 216 | print('\nTest run #%d:  (includes %s) Server=%s,  Proto=%s,  zlib=%s,  SSL=%s' | 
|  | 217 | % (test_count, genpydir, try_server, try_proto, with_zlib, with_ssl)) | 
|  | 218 | runServiceTest(self.libdir, self.genbase, genpydir, try_server, try_proto, self.port, with_zlib, with_ssl, self.verbose) | 
|  | 219 | if self.verbose > 0: | 
|  | 220 | print('OK: Finished (includes %s)  %s / %s proto / zlib=%s / SSL=%s.   %d combinations tested.' | 
|  | 221 | % (genpydir, try_server, try_proto, with_zlib, with_ssl, test_count)) | 
|  | 222 | return True | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 223 |  | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 224 | def test_feature(self, name, values): | 
|  | 225 | test_count = 0 | 
|  | 226 | conf = self.default_conf() | 
|  | 227 | for try_server in values: | 
|  | 228 | conf[name] = try_server | 
|  | 229 | if self.run(conf, test_count): | 
|  | 230 | test_count += 1 | 
|  | 231 | return test_count | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 232 |  | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 233 | def run_all_tests(self): | 
|  | 234 | test_count = 0 | 
|  | 235 | for try_server in self.servers: | 
|  | 236 | for genpydir in self.gendirs: | 
|  | 237 | for try_proto in PROTOS: | 
|  | 238 | for with_zlib in (False, True): | 
|  | 239 | # skip any servers that don't work with the Zlib transport | 
|  | 240 | if with_zlib and try_server in SKIP_ZLIB: | 
|  | 241 | continue | 
|  | 242 | for with_ssl in (False, True): | 
|  | 243 | # skip any servers that don't work with SSL | 
|  | 244 | if with_ssl and try_server in SKIP_SSL: | 
|  | 245 | continue | 
|  | 246 | test_count += 1 | 
|  | 247 | if self.verbose > 0: | 
|  | 248 | print('\nTest run #%d:  (includes %s) Server=%s,  Proto=%s,  zlib=%s,  SSL=%s' | 
|  | 249 | % (test_count, genpydir, try_server, try_proto, with_zlib, with_ssl)) | 
|  | 250 | runServiceTest(self.libdir, self.genbase, genpydir, try_server, try_proto, self.port, with_zlib, with_ssl) | 
|  | 251 | if self.verbose > 0: | 
|  | 252 | print('OK: Finished (includes %s)  %s / %s proto / zlib=%s / SSL=%s.   %d combinations tested.' | 
|  | 253 | % (genpydir, try_server, try_proto, with_zlib, with_ssl, test_count)) | 
|  | 254 | return test_count | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 255 |  | 
|  | 256 |  | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 257 | def main(): | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 258 | parser = OptionParser() | 
|  | 259 | parser.add_option('--all', action="store_true", dest='all') | 
|  | 260 | parser.add_option('--genpydirs', type='string', dest='genpydirs', | 
|  | 261 | default='default,slots,oldstyle,no_utf8strings,dynamic,dynamicslots', | 
|  | 262 | help='directory extensions for generated code, used as suffixes for \"gen-py-*\" added sys.path for individual tests') | 
|  | 263 | parser.add_option("--port", type="int", dest="port", default=9090, | 
|  | 264 | help="port number for server to listen on") | 
|  | 265 | parser.add_option('-v', '--verbose', action="store_const", | 
|  | 266 | dest="verbose", const=2, | 
|  | 267 | help="verbose output") | 
|  | 268 | parser.add_option('-q', '--quiet', action="store_const", | 
|  | 269 | dest="verbose", const=0, | 
|  | 270 | help="minimal output") | 
| Nobuaki Sukegawa | 7af189a | 2016-02-11 16:21:01 +0900 | [diff] [blame] | 271 | parser.add_option('-L', '--libdir', dest="libdir", default=local_libpath(), | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 272 | help="directory path that contains Thrift Python library") | 
|  | 273 | parser.add_option('--gen-base', dest="gen_base", default=SCRIPT_DIR, | 
|  | 274 | help="directory path that contains Thrift Python library") | 
|  | 275 | parser.set_defaults(verbose=1) | 
|  | 276 | options, args = parser.parse_args() | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 277 |  | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 278 | generated_dirs = [] | 
|  | 279 | for gp_dir in options.genpydirs.split(','): | 
|  | 280 | generated_dirs.append('gen-py-%s' % (gp_dir)) | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 281 |  | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 282 | # commandline permits a single class name to be specified to override SERVERS=[...] | 
| Nobuaki Sukegawa | 06e8fd4 | 2016-02-28 12:50:03 +0900 | [diff] [blame] | 283 | servers = default_servers() | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 284 | if len(args) == 1: | 
| Nobuaki Sukegawa | 06e8fd4 | 2016-02-28 12:50:03 +0900 | [diff] [blame] | 285 | if args[0] in servers: | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 286 | servers = args | 
|  | 287 | else: | 
|  | 288 | print('Unavailable server type "%s", please choose one of: %s' % (args[0], servers)) | 
|  | 289 | sys.exit(0) | 
|  | 290 |  | 
|  | 291 | tests = TestCases(options.gen_base, options.libdir, options.port, generated_dirs, servers, options.verbose) | 
|  | 292 |  | 
|  | 293 | # run tests without a client/server first | 
|  | 294 | print('----------------') | 
|  | 295 | print(' Executing individual test scripts with various generated code directories') | 
|  | 296 | print(' Directories to be tested: ' + ', '.join(generated_dirs)) | 
|  | 297 | print(' Scripts to be tested: ' + ', '.join(SCRIPTS)) | 
|  | 298 | print('----------------') | 
|  | 299 | for genpydir in generated_dirs: | 
|  | 300 | for script in SCRIPTS: | 
|  | 301 | runScriptTest(options.libdir, options.gen_base, genpydir, script) | 
|  | 302 |  | 
|  | 303 | print('----------------') | 
|  | 304 | print(' Executing Client/Server tests with various generated code directories') | 
|  | 305 | print(' Servers to be tested: ' + ', '.join(servers)) | 
|  | 306 | print(' Directories to be tested: ' + ', '.join(generated_dirs)) | 
|  | 307 | print(' Protocols to be tested: ' + ', '.join(PROTOS)) | 
|  | 308 | print(' Options to be tested: ZLIB(yes/no), SSL(yes/no)') | 
|  | 309 | print('----------------') | 
|  | 310 |  | 
|  | 311 | if options.all: | 
|  | 312 | tests.run_all_tests() | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 313 | else: | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 314 | tests.test_feature('gendir', generated_dirs) | 
|  | 315 | tests.test_feature('server', servers) | 
|  | 316 | tests.test_feature('proto', PROTOS) | 
|  | 317 | tests.test_feature('zlib', [False, True]) | 
|  | 318 | tests.test_feature('ssl', [False, True]) | 
| Nobuaki Sukegawa | cacce2f | 2015-11-08 23:43:55 +0900 | [diff] [blame] | 319 |  | 
|  | 320 |  | 
|  | 321 | if __name__ == '__main__': | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 322 | sys.exit(main()) |