no_op.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 <stdio.h>
20 #include <string.h>
21 
22 #include <grpc/byte_buffer.h>
23 #include <grpc/support/alloc.h>
24 #include <grpc/support/log.h>
25 #include <grpc/support/time.h>
26 
29 
30 static void* tag(intptr_t t) { return reinterpret_cast<void*>(t); }
31 
33  const char* test_name,
34  grpc_channel_args* client_args,
35  grpc_channel_args* server_args) {
37  gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name);
38  f = config.create_fixture(client_args, server_args);
39  config.init_server(&f, server_args);
40  config.init_client(&f, client_args);
41  return f;
42 }
43 
46 }
47 
49  return n_seconds_from_now(5);
50 }
51 
53  grpc_event ev;
54  do {
56  } while (ev.type != GRPC_QUEUE_SHUTDOWN);
57 }
58 
60  if (!f->server) return;
61  grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
62  grpc_event ev;
63  do {
65  nullptr);
66  } while (ev.type != GRPC_OP_COMPLETE || ev.tag != tag(1000));
67  grpc_server_destroy(f->server);
68  f->server = nullptr;
69 }
70 
72  if (!f->client) return;
73  grpc_channel_destroy(f->client);
74  f->client = nullptr;
75 }
76 
80 
82  drain_cq(f->cq);
84 }
85 
87  grpc_end2end_test_fixture f = begin_test(config, "no-op", nullptr, nullptr);
88  end_test(&f);
89  config.tear_down_data(&f);
90 }
91 
93 
94 void no_op_pre_init(void) {}
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
grpc_timeout_seconds_to_deadline
gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s)
Definition: test/core/util/test_config.cc:81
log.h
end_test
static void end_test(grpc_end2end_test_fixture *f)
Definition: no_op.cc:77
five_seconds_from_now
static gpr_timespec five_seconds_from_now(void)
Definition: no_op.cc:48
string.h
n_seconds_from_now
static gpr_timespec n_seconds_from_now(int n)
Definition: no_op.cc:44
no_op
void no_op(grpc_end2end_test_config config)
Definition: no_op.cc:92
GRPC_QUEUE_SHUTDOWN
@ GRPC_QUEUE_SHUTDOWN
Definition: grpc_types.h:554
GRPC_OP_COMPLETE
@ GRPC_OP_COMPLETE
Definition: grpc_types.h:558
time.h
grpc_end2end_test_config
Definition: end2end_tests.h:53
grpc_channel_args
Definition: grpc_types.h:132
drain_cq
static void drain_cq(grpc_completion_queue *cq)
Definition: no_op.cc:52
grpc_end2end_test_fixture
Definition: end2end_tests.h:46
shutdown_client
static void shutdown_client(grpc_end2end_test_fixture *f)
Definition: no_op.cc:71
autogen_x86imm.f
f
Definition: autogen_x86imm.py:9
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_event
Definition: grpc_types.h:564
grpc_completion_queue
Definition: completion_queue.cc:347
no_op_pre_init
void no_op_pre_init(void)
Definition: no_op.cc:94
intptr_t
_W64 signed int intptr_t
Definition: stdint-msvc2008.h:118
grpc_server_destroy
GRPCAPI void grpc_server_destroy(grpc_server *server)
Definition: src/core/lib/surface/server.cc:1519
test_no_op
static void test_no_op(grpc_end2end_test_config config)
Definition: no_op.cc:86
end2end_tests.h
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
begin_test
static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, grpc_channel_args *client_args, grpc_channel_args *server_args)
Definition: no_op.cc:32
cq_verifier.h
shutdown_server
static void shutdown_server(grpc_end2end_test_fixture *f)
Definition: no_op.cc:59
grpc_completion_queue_destroy
GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq)
Definition: completion_queue.cc:1424
alloc.h
grpc_server_shutdown_and_notify
GRPCAPI void grpc_server_shutdown_and_notify(grpc_server *server, grpc_completion_queue *cq, void *tag)
Definition: src/core/lib/surface/server.cc:1503
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
grpc_completion_queue_shutdown
GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq)
Definition: completion_queue.cc:1416
grpc_channel_destroy
GRPCAPI void grpc_channel_destroy(grpc_channel *channel)
Definition: channel.cc:437
config_s
Definition: bloaty/third_party/zlib/deflate.c:120
tag
static void * tag(intptr_t t)
Definition: no_op.cc:30
gpr_timespec
Definition: gpr_types.h:50
grpc_event::type
grpc_completion_type type
Definition: grpc_types.h:566
grpc_event::tag
void * tag
Definition: grpc_types.h:576
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:32