fling_test.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 <string>
23 
24 #include "absl/strings/str_cat.h"
25 
26 #include <grpc/support/alloc.h>
27 #include <grpc/support/log.h>
28 
30 #include "test/core/util/port.h"
32 
33 int main(int /*argc*/, const char** argv) {
35  const char* me = argv[0];
36  const char* lslash = strrchr(me, '/');
37  char root[1024];
39  char* args[10];
40  int status;
41  gpr_subprocess *svr, *cli;
42  /* figure out where we are */
43  if (lslash) {
44  memcpy(root, me, static_cast<size_t>(lslash - me));
45  root[lslash - me] = 0;
46  } else {
47  strcpy(root, ".");
48  }
49  /* start the server */
52  args[0] = const_cast<char*>(command.c_str());
53  args[1] = const_cast<char*>("--bind");
55  args[2] = const_cast<char*>(joined.c_str());
56  args[3] = const_cast<char*>("--no-secure");
57  svr = gpr_subprocess_create(4, const_cast<const char**>(args));
58 
59  /* start the client */
60  command =
62  args[0] = const_cast<char*>(command.c_str());
63  args[1] = const_cast<char*>("--target");
64  joined = grpc_core::JoinHostPort("127.0.0.1", port);
65  args[2] = const_cast<char*>(joined.c_str());
66  args[3] = const_cast<char*>("--scenario=ping-pong-request");
67  args[4] = const_cast<char*>("--no-secure");
68  args[5] = nullptr;
69  cli = gpr_subprocess_create(6, const_cast<const char**>(args));
70 
71  /* wait for completion */
72  printf("waiting for client\n");
73  if ((status = gpr_subprocess_join(cli))) {
76  return status;
77  }
79 
83  return status;
84 }
log.h
port.h
gpr_log_verbosity_init
GPRAPI void gpr_log_verbosity_init(void)
Definition: log.cc:115
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
string.h
printf
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
Definition: cs_driver.c:91
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
gpr_subprocess_binary_extension
const char * gpr_subprocess_binary_extension()
status
absl::Status status
Definition: rls.cc:251
gpr_subprocess_interrupt
void gpr_subprocess_interrupt(gpr_subprocess *p)
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
root
RefCountedPtr< grpc_tls_certificate_provider > root
Definition: xds_server_config_fetcher.cc:223
grpc_core::JoinHostPort
std::string JoinHostPort(absl::string_view host, int port)
Definition: host_port.cc:32
host_port.h
grpc_pick_unused_port_or_die
int grpc_pick_unused_port_or_die(void)
gpr_subprocess
struct gpr_subprocess gpr_subprocess
Definition: test/core/util/subprocess.h:24
subprocess.h
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
gpr_subprocess_create
gpr_subprocess * gpr_subprocess_create(int argc, const char **argv)
alloc.h
main
int main(int, const char **argv)
Definition: fling_test.cc:33
gpr_subprocess_join
int gpr_subprocess_join(gpr_subprocess *p)
gpr_subprocess_destroy
void gpr_subprocess_destroy(gpr_subprocess *p)
command
const char * command
Definition: grpc_tool.cc:247


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