bad_client.h
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 #ifndef GRPC_TEST_CORE_BAD_CLIENT_BAD_CLIENT_H
20 #define GRPC_TEST_CORE_BAD_CLIENT_BAD_CLIENT_H
21 
22 #include <stdbool.h>
23 
24 #include <grpc/grpc.h>
25 
27 
28 #define GRPC_BAD_CLIENT_REGISTERED_METHOD "/registered/bar"
29 #define GRPC_BAD_CLIENT_REGISTERED_HOST "localhost"
30 
31 /* The server side validator function to run */
34  void* registered_method);
35 
36 /* Returns false if we need to read more data. */
39 
43  const char* client_payload;
45 };
46 
47 /* Flags for grpc_run_bad_client_test */
48 #define GRPC_BAD_CLIENT_DISCONNECT 1
49 #define GRPC_BAD_CLIENT_LARGE_REQUEST 2
50 
51 /* Test runner.
52  *
53  * Create a server, and for each arg in \a args send client_payload. For each
54  * payload, run client_validator to make sure that the response is as expected.
55  * Also execute \a server_validator in a separate thread to assert that the
56  * bytes are handled as expected.
57  *
58  * The flags are only applicable to the last validator in the array. (This can
59  * be changed in the future if necessary)
60  */
63  grpc_bad_client_arg args[], int num_args, uint32_t flags);
64 
65 /* A hack to let old tests work as before. In these tests, instead of an array,
66  * the tests provide a single client_validator and payload
67  */
68 #define COMBINE1(X, Y) X##Y
69 #define COMBINE(X, Y) COMBINE1(X, Y)
70 
71 #define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, \
72  flags) \
73  grpc_bad_client_arg COMBINE(bca, __LINE__) = {client_validator, nullptr, \
74  payload, sizeof(payload) - 1}; \
75  grpc_run_bad_client_test(server_validator, &COMBINE(bca, __LINE__), 1, flags)
76 
77 /* Helper validator functions */
78 /* Client side validator for connection preface from server. \a arg is unused */
80  void* arg);
81 
82 /* Client side validator for checking if reset stream is present at the end
83  * of the buffer. \a arg is unused.
84  */
86 
87 /* Helper grpc_bad_client_arg arguments for direct use */
88 /* Sends a connection preface from the client with an empty settings frame */
90 
91 /* Server side verifier function that performs a
92  * single grpc_server_request_call */
95  void* registered_method);
96 #endif /* GRPC_TEST_CORE_BAD_CLIENT_BAD_CLIENT_H */
incoming
static uv_pipe_t incoming[4]
Definition: test-pipe-sendmsg.c:38
server_verifier_request_call
void server_verifier_request_call(grpc_server *server, grpc_completion_queue *cq, void *registered_method)
Definition: bad_client.cc:320
bool
bool
Definition: setup_once.h:312
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
connection_preface_arg
grpc_bad_client_arg connection_preface_arg
Definition: bad_client.cc:282
server
std::unique_ptr< Server > server
Definition: channelz_service_test.cc:330
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_completion_queue
Definition: completion_queue.cc:347
grpc_bad_client_client_stream_validator
bool(* grpc_bad_client_client_stream_validator)(grpc_slice_buffer *incoming, void *arg)
Definition: bad_client.h:37
grpc.h
grpc_bad_client_server_side_validator
void(* grpc_bad_client_server_side_validator)(grpc_server *server, grpc_completion_queue *cq, void *registered_method)
Definition: bad_client.h:32
arg
Definition: cmdline.cc:40
grpc_server
struct grpc_server grpc_server
Definition: grpc_types.h:65
test_config.h
grpc_bad_client_arg::client_payload_length
size_t client_payload_length
Definition: bad_client.h:44
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
server
Definition: examples/python/async_streaming/server.py:1
grpc_bad_client_arg
Definition: bad_client.h:40
arg
struct arg arg
client_connection_preface_validator
bool client_connection_preface_validator(grpc_slice_buffer *incoming, void *arg)
Definition: bad_client.cc:262
grpc_bad_client_arg::client_payload
const char * client_payload
Definition: bad_client.h:43
rst_stream_client_validator
bool rst_stream_client_validator(grpc_slice_buffer *incoming, void *arg)
Definition: bad_client.cc:286
grpc_bad_client_arg::client_validator
grpc_bad_client_client_stream_validator client_validator
Definition: bad_client.h:41
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::client_validator_arg
void * client_validator_arg
Definition: bad_client.h:42
grpc_slice_buffer
Definition: include/grpc/impl/codegen/slice.h:83
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:35