gen_server_registered_method_bad_client_test_body.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # Copyright 2015 gRPC authors.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 def esc_c(line):
19  out = "\""
20  last_was_hex = False
21  for c in line:
22  if 32 <= c < 127:
23  if c in hex_bytes and last_was_hex:
24  out += "\"\""
25  if c != ord('"'):
26  out += chr(c)
27  else:
28  out += "\\\""
29  last_was_hex = False
30  else:
31  out += "\\x%02x" % c
32  last_was_hex = True
33  return out + "\""
34 
35 
36 done = set()
37 
38 for message_length in range(0, 3):
39  for send_message_length in range(0, message_length + 1):
40  payload = [
41  0, (message_length >> 24) & 0xff, (message_length >> 16) & 0xff,
42  (message_length >> 8) & 0xff, (message_length) & 0xff
43  ] + send_message_length * [0]
44  for frame_length in range(0, len(payload) + 1):
45  is_end = frame_length == len(
46  payload) and send_message_length == message_length
47  frame = [(frame_length >> 16) & 0xff, (frame_length >> 8) & 0xff,
48  (frame_length) & 0xff, 0, 1 if is_end else 0, 0, 0, 0, 1
49  ] + payload[0:frame_length]
50  text = esc_c(frame)
51  if text not in done:
52  print(
53  ('GRPC_RUN_BAD_CLIENT_TEST(verifier_%s, PFX_STR %s, %s);' %
54  ('succeeds' if is_end else 'fails', text,
55  '0' if is_end else 'GRPC_BAD_CLIENT_DISCONNECT')))
56  done.add(text)
absl::compare_internal::ord
ord
Definition: abseil-cpp/absl/types/compare.h:79
capstone.range
range
Definition: third_party/bloaty/third_party/capstone/bindings/python/capstone/__init__.py:6
gen_server_registered_method_bad_client_test_body.esc_c
def esc_c(line)
Definition: gen_server_registered_method_bad_client_test_body.py:18
cpp.gmock_class.set
set
Definition: bloaty/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class.py:44
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:25