diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2016-12-07 14:10:32 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2016-12-07 14:10:32 -0500 |
commit | 5bb456d80cfbcdfe87526510f3b8297d315afdd8 (patch) | |
tree | e85d753f2a2535313ac199a998b76c0006a5406e /indra/llcorehttp | |
parent | 54f95e4d611a192b8a93c23e4c2499096121ae57 (diff) |
DRTVWR-418: Apparently (some) Windows hosts still need freeport().
This is the function in indra/llmessage/tests/testrunner.py that iterates
through ports in a specified range, looking for an available one. Other
platforms understand a specification of port 0 to mean: "You pick one. I'll
just use whichever one you picked."
Diffstat (limited to 'indra/llcorehttp')
-rwxr-xr-x | indra/llcorehttp/tests/test_llcorehttp_peer.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index 6c223990ca..493143641b 100755 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -34,7 +34,6 @@ import sys import time import select import getopt -from threading import Thread try: from cStringIO import StringIO except ImportError: @@ -48,7 +47,7 @@ from llbase import llsd sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "llmessage", "tests")) -from testrunner import run, debug, VERBOSE +from testrunner import freeport, run, debug, VERBOSE class TestHTTPRequestHandler(BaseHTTPRequestHandler): """This subclass of BaseHTTPRequestHandler is to receive and echo @@ -297,9 +296,18 @@ if __name__ == "__main__": if option == "-V" or option == "--valgrind": do_valgrind = True - # Instantiate a Server(TestHTTPRequestHandler) on a port chosen by the - # runtime. - httpd = Server(('127.0.0.1', 0), TestHTTPRequestHandler) + # function to make a server with specified port + make_server = lambda port: Server(('127.0.0.1', port), TestHTTPRequestHandler) + + if not sys.platform.startswith("win"): + # Instantiate a Server(TestHTTPRequestHandler) on a port chosen by the + # runtime. + httpd = make_server(0) + else: + # "Then there's Windows" + # Instantiate a Server(TestHTTPRequestHandler) on the first free port + # in the specified port range. + httpd, port = freeport(xrange(8000, 8020), make_server) # Pass the selected port number to the subject test program via the # environment. We don't want to impose requirements on the test program's |