| Index: third_party/grpc/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/systemhost.py b/third_party/grpc/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
|
| old mode 100644
|
| new mode 100755
|
| similarity index 53%
|
| copy from third_party/WebKit/Tools/Scripts/webkitpy/common/system/systemhost.py
|
| copy to third_party/grpc/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
|
| index e3bbe7c6d2295b9c7d2a466df9b75e4c195f3bd0..76c98767e6a2451df9dc62869fb0616f3857f148
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/system/systemhost.py
|
| +++ b/third_party/grpc/tools/codegen/core/gen_server_registered_method_bad_client_test_body.py
|
| @@ -1,4 +1,7 @@
|
| -# Copyright (c) 2011 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,34 +29,48 @@
|
| # (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 os
|
| -import platform
|
| -import sys
|
| -
|
| -from webkitpy.common.system import environment, executive, filesystem, platforminfo, user, workspace
|
| -
|
| -
|
| -class SystemHost(object):
|
| -
|
| - def __init__(self):
|
| - self.executable = sys.executable
|
| - self.executive = executive.Executive()
|
| - self.filesystem = filesystem.FileSystem()
|
| - self.user = user.User()
|
| - self.platform = platforminfo.PlatformInfo(sys, platform, self.filesystem, self.executive)
|
| - self.workspace = workspace.Workspace(self.filesystem, self.executive)
|
| - self.stdin = sys.stdin
|
| - self.stdout = sys.stdout
|
| - self.stderr = sys.stderr
|
| -
|
| - def copy_current_environment(self):
|
| - return environment.Environment(os.environ.copy())
|
| +def esc_c(line):
|
| + out = "\""
|
| + last_was_hex = False
|
| + for c in line:
|
| + if 32 <= c < 127:
|
| + if c in hex_bytes and last_was_hex:
|
| + out += "\"\""
|
| + if c != ord('"'):
|
| + out += chr(c)
|
| + else:
|
| + out += "\\\""
|
| + last_was_hex = False
|
| + else:
|
| + out += "\\x%02x" % c
|
| + last_was_hex = True
|
| + return out + "\""
|
|
|
| - def print_(self, *args, **kwargs):
|
| - sep = kwargs.get('sep', ' ')
|
| - end = kwargs.get('end', '\n')
|
| - stream = kwargs.get('stream', self.stdout)
|
| - stream.write(sep.join([str(arg) for arg in args]) + end)
|
| +done = set()
|
|
|
| - def exit(self, returncode):
|
| - sys.exit(returncode)
|
| +for message_length in range(0, 3):
|
| + for send_message_length in range(0, message_length + 1):
|
| + payload = [
|
| + 0,
|
| + (message_length >> 24) & 0xff,
|
| + (message_length >> 16) & 0xff,
|
| + (message_length >> 8) & 0xff,
|
| + (message_length) & 0xff
|
| + ] + send_message_length * [0]
|
| + for frame_length in range(0, len(payload) + 1):
|
| + is_end = frame_length == len(payload) and send_message_length == message_length
|
| + frame = [
|
| + (frame_length >> 16) & 0xff,
|
| + (frame_length >> 8) & 0xff,
|
| + (frame_length) & 0xff,
|
| + 0,
|
| + 1 if is_end else 0,
|
| + 0, 0, 0, 1
|
| + ] + payload[0:frame_length]
|
| + text = esc_c(frame)
|
| + if text not in done:
|
| + print 'GRPC_RUN_BAD_CLIENT_TEST(verifier_%s, PFX_STR %s, %s);' % (
|
| + 'succeeds' if is_end else 'fails',
|
| + text,
|
| + '0' if is_end else 'GRPC_BAD_CLIENT_DISCONNECT')
|
| + done.add(text)
|
|
|