Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: third_party/grpc/test/core/httpcli/test_server.py

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/test/core/httpcli/test_server.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/print_layout_test_types.py b/third_party/grpc/test/core/httpcli/test_server.py
old mode 100644
new mode 100755
similarity index 51%
copy from third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/print_layout_test_types.py
copy to third_party/grpc/test/core/httpcli/test_server.py
index 2756dc5f804677923b528958e053d8662bcf1bf2..dbbf5ceb3c7975b19941d72590107e9643d0daf3
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/print_layout_test_types.py
+++ b/third_party/grpc/test/core/httpcli/test_server.py
@@ -1,4 +1,6 @@
-# Copyright (C) 2013 Google Inc. All rights reserved.
+#!/usr/bin/env python2.7
+# Copyright 2015, Google Inc.
+# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -26,27 +28,44 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import optparse
+"""Server for httpcli_test"""
-from webkitpy.layout_tests.controllers import layout_test_finder
+import argparse
+import BaseHTTPServer
+import os
+import ssl
+import sys
+_PEM = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..', 'src/core/tsi/test_creds/server1.pem'))
+_KEY = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..', 'src/core/tsi/test_creds/server1.key'))
+print _PEM
+open(_PEM).close()
-def main(host, argv):
- port = host.port_factory.get()
+argp = argparse.ArgumentParser(description='Server for httpcli_test')
+argp.add_argument('-p', '--port', default=10080, type=int)
+argp.add_argument('-s', '--ssl', default=False, action='store_true')
+args = argp.parse_args()
- parser = optparse.OptionParser()
- parser.add_option('--test-list', action='append')
- parser.add_option('--type', action='append',
- help='limit to tests of type X (valid values %s)' % port.ALL_TEST_TYPES)
+print 'server running on port %d' % args.port
- options, args = parser.parse_args(argv)
- finder = layout_test_finder.LayoutTestFinder(port, options)
- _, tests, _ = finder.find_tests(args, test_list=options.test_list)
+class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
+ def good(self):
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/html')
+ self.end_headers()
+ self.wfile.write('<html><head><title>Hello world!</title></head>')
+ self.wfile.write('<body><p>This is a test</p></body></html>')
- for test_name in tests:
- test_type = port.test_type(test_name)
- if options.type:
- if test_type in options.type:
- host.print_(test_name)
- else:
- host.print_(test_name, test_type)
+ def do_GET(self):
+ if self.path == '/get':
+ self.good()
+
+ def do_POST(self):
+ content = self.rfile.read(int(self.headers.getheader('content-length')))
+ if self.path == '/post' and content == 'hello':
+ self.good()
+
+httpd = BaseHTTPServer.HTTPServer(('localhost', args.port), Handler)
+if args.ssl:
+ httpd.socket = ssl.wrap_socket(httpd.socket, certfile=_PEM, keyfile=_KEY, server_side=True)
+httpd.serve_forever()
« no previous file with comments | « third_party/grpc/test/core/httpcli/parser_test.c ('k') | third_party/grpc/test/core/iomgr/endpoint_pair_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698