unknown_frame.cc
Go to the documentation of this file.
1 /*
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 
19 #include <string>
20 
21 #include <gtest/gtest.h>
22 
24 
27 
29  void* /*registered_method*/) {
30  while (grpc_core::Server::FromC(server)->HasOpenConnections()) {
34  }
35 }
36 
37 #define APPEND_BUFFER(string, to_append) \
38  ((string).append((to_append), sizeof(to_append) - 1))
39 
40 namespace {
41 TEST(UnknownFrameType, Test) {
42  /* test that all invalid/unknown frame types are handled */
43  for (int i = 10; i <= 255; i++) {
44  std::string unknown_frame_string;
45  APPEND_BUFFER(unknown_frame_string, "\x00\x00\x00");
46  char frame_type = static_cast<char>(i);
47  unknown_frame_string.append(&frame_type, 1);
48  APPEND_BUFFER(unknown_frame_string, "\x00\x00\x00\x00\x01");
51  args[1].client_validator = nullptr;
52  args[1].client_payload = unknown_frame_string.c_str();
53  args[1].client_payload_length = unknown_frame_string.size();
55  }
56 }
57 } // namespace
58 
59 int main(int argc, char** argv) {
61  ::testing::InitGoogleTest(&argc, argv);
62  grpc_init();
63  int retval = RUN_ALL_TESTS();
64  grpc_shutdown();
65  return retval;
66 }
generate.env
env
Definition: generate.py:37
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
string_util.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
verifier
static void verifier(grpc_server *server, grpc_completion_queue *cq, void *)
Definition: unknown_frame.cc:28
TEST
#define TEST(name, init_size,...)
Definition: arena_test.cc:75
grpc_timeout_milliseconds_to_deadline
gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms)
Definition: test/core/util/test_config.cc:89
grpc_completion_queue
Definition: completion_queue.cc:347
grpc_server
struct grpc_server grpc_server
Definition: grpc_types.h:65
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
GRPC_BAD_CLIENT_DISCONNECT
#define GRPC_BAD_CLIENT_DISCONNECT
Definition: bad_client.h:48
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
main
int main(int argc, char **argv)
Definition: unknown_frame.cc:59
server
Definition: examples/python/async_streaming/server.py:1
grpc_run_bad_client_test
void grpc_run_bad_client_test(grpc_bad_client_server_side_validator server_validator, grpc_bad_client_arg args[], int num_args, uint32_t flags)
Definition: bad_client.cc:193
grpc_bad_client_arg
Definition: bad_client.h:40
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
grpc_completion_queue_next
GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved)
Definition: completion_queue.cc:1133
server.h
connection_preface_arg
grpc_bad_client_arg connection_preface_arg
Definition: bad_client.cc:282
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
grpc_core::CppImplOf< Server, grpc_server >::FromC
static Server * FromC(grpc_server *c_type)
Definition: cpp_impl_of.h:30
GRPC_QUEUE_TIMEOUT
@ GRPC_QUEUE_TIMEOUT
Definition: grpc_types.h:556
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Definition: init.cc:209
bad_client.h
Test
Definition: hpack_parser_test.cc:43
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
APPEND_BUFFER
#define APPEND_BUFFER(string, to_append)
Definition: unknown_frame.cc:37


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:44