aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/grpc/test/core/util
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:43 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:43 +0300
commit397cbe258b9e064f49c4ca575279f02f39fef76e (patch)
treea0b0eb3cca6a14e4e8ea715393637672fa651284 /contrib/libs/grpc/test/core/util
parent43f5a35593ebc9f6bcea619bb170394ea7ae468e (diff)
downloadydb-397cbe258b9e064f49c4ca575279f02f39fef76e.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/test/core/util')
-rw-r--r--contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt136
-rw-r--r--contrib/libs/grpc/test/core/util/cmdline.cc42
-rw-r--r--contrib/libs/grpc/test/core/util/cmdline.h6
-rw-r--r--contrib/libs/grpc/test/core/util/cmdline_test.cc14
-rw-r--r--contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.cc236
-rw-r--r--contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.h62
-rw-r--r--contrib/libs/grpc/test/core/util/examine_stack.cc204
-rw-r--r--contrib/libs/grpc/test/core/util/examine_stack.h68
-rw-r--r--contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc78
-rw-r--r--contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl4
-rw-r--r--contrib/libs/grpc/test/core/util/mock_endpoint.cc30
-rw-r--r--contrib/libs/grpc/test/core/util/passthru_endpoint.cc36
-rw-r--r--contrib/libs/grpc/test/core/util/port.cc32
-rw-r--r--contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc28
-rw-r--r--contrib/libs/grpc/test/core/util/port_server_client.cc82
-rw-r--r--contrib/libs/grpc/test/core/util/reconnect_server.cc30
-rw-r--r--contrib/libs/grpc/test/core/util/reconnect_server.h2
-rw-r--r--contrib/libs/grpc/test/core/util/test_config.cc180
-rw-r--r--contrib/libs/grpc/test/core/util/test_config.h50
-rw-r--r--contrib/libs/grpc/test/core/util/test_lb_policies.cc484
-rw-r--r--contrib/libs/grpc/test/core/util/test_lb_policies.h60
-rw-r--r--contrib/libs/grpc/test/core/util/test_tcp_server.cc22
-rw-r--r--contrib/libs/grpc/test/core/util/test_tcp_server.h22
-rw-r--r--contrib/libs/grpc/test/core/util/trickle_endpoint.cc14
-rw-r--r--contrib/libs/grpc/test/core/util/ubsan_suppressions.txt4
-rw-r--r--contrib/libs/grpc/test/core/util/ya.make16
26 files changed, 971 insertions, 971 deletions
diff --git a/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt
index 8082dbe9c6..6e3a10d022 100644
--- a/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt
+++ b/contrib/libs/grpc/test/core/util/.yandex_meta/licenses.list.txt
@@ -1,68 +1,68 @@
-====================Apache-2.0====================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-
-
-====================Apache-2.0====================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-====================Apache-2.0====================
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-====================COPYRIGHT====================
- * Copyright 2015 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2015-2016 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2016 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2017 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2018 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2020 gRPC authors.
-
-
-====================COPYRIGHT====================
- * Copyright 2020 the gRPC authors.
+====================Apache-2.0====================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+
+====================Apache-2.0====================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+====================Apache-2.0====================
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+
+====================COPYRIGHT====================
+ * Copyright 2015 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2015-2016 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2016 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2017 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2018 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2020 gRPC authors.
+
+
+====================COPYRIGHT====================
+ * Copyright 2020 the gRPC authors.
diff --git a/contrib/libs/grpc/test/core/util/cmdline.cc b/contrib/libs/grpc/test/core/util/cmdline.cc
index 62b47f927a..0fd090e8e4 100644
--- a/contrib/libs/grpc/test/core/util/cmdline.cc
+++ b/contrib/libs/grpc/test/core/util/cmdline.cc
@@ -22,12 +22,12 @@
#include <stdio.h>
#include <string.h>
-#include <vector>
-
-#include "y_absl/strings/str_cat.h"
-#include "y_absl/strings/str_format.h"
-#include "y_absl/strings/str_join.h"
-
+#include <vector>
+
+#include "y_absl/strings/str_cat.h"
+#include "y_absl/strings/str_format.h"
+#include "y_absl/strings/str_join.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -130,42 +130,42 @@ void gpr_cmdline_on_extra_arg(
/* recursively descend argument list, adding the last element
to s first - so that arguments are added in the order they were
added to the list by api calls */
-static void add_args_to_usage(arg* a, std::vector<TString>* s) {
- if (a == nullptr) return;
- add_args_to_usage(a->next, s);
+static void add_args_to_usage(arg* a, std::vector<TString>* s) {
+ if (a == nullptr) return;
+ add_args_to_usage(a->next, s);
switch (a->type) {
case ARGTYPE_BOOL:
- s->push_back(y_absl::StrFormat(" [--%s|--no-%s]", a->name, a->name));
+ s->push_back(y_absl::StrFormat(" [--%s|--no-%s]", a->name, a->name));
break;
case ARGTYPE_STRING:
- s->push_back(y_absl::StrFormat(" [--%s=string]", a->name));
+ s->push_back(y_absl::StrFormat(" [--%s=string]", a->name));
break;
case ARGTYPE_INT:
- s->push_back(y_absl::StrFormat(" [--%s=int]", a->name));
+ s->push_back(y_absl::StrFormat(" [--%s=int]", a->name));
break;
}
}
-TString gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) {
+TString gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) {
const char* name = strrchr(argv0, '/');
- if (name != nullptr) {
+ if (name != nullptr) {
name++;
} else {
name = argv0;
}
- std::vector<TString> s;
- s.push_back(y_absl::StrCat("Usage: ", name));
- add_args_to_usage(cl->args, &s);
+ std::vector<TString> s;
+ s.push_back(y_absl::StrCat("Usage: ", name));
+ add_args_to_usage(cl->args, &s);
if (cl->extra_arg) {
- s.push_back(y_absl::StrFormat(" [%s...]", cl->extra_arg_name));
+ s.push_back(y_absl::StrFormat(" [%s...]", cl->extra_arg_name));
}
- s.push_back("\n");
- return y_absl::StrJoin(s, "");
+ s.push_back("\n");
+ return y_absl::StrJoin(s, "");
}
static int print_usage_and_die(gpr_cmdline* cl) {
- fprintf(stderr, "%s", gpr_cmdline_usage_string(cl, cl->argv0).c_str());
+ fprintf(stderr, "%s", gpr_cmdline_usage_string(cl, cl->argv0).c_str());
if (!cl->survive_failure) {
exit(1);
}
diff --git a/contrib/libs/grpc/test/core/util/cmdline.h b/contrib/libs/grpc/test/core/util/cmdline.h
index cc75a8974e..e808822485 100644
--- a/contrib/libs/grpc/test/core/util/cmdline.h
+++ b/contrib/libs/grpc/test/core/util/cmdline.h
@@ -21,8 +21,8 @@
#include <grpc/support/port_platform.h>
-#include <util/generic/string.h>
-
+#include <util/generic/string.h>
+
/** Simple command line parser.
Supports flags that can be specified as -foo, --foo, --no-foo, -no-foo, etc
@@ -77,6 +77,6 @@ int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv);
/** Destroy the parser */
void gpr_cmdline_destroy(gpr_cmdline* cl);
/** Get a string describing usage */
-TString gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0);
+TString gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0);
#endif /* GRPC_TEST_CORE_UTIL_CMDLINE_H */
diff --git a/contrib/libs/grpc/test/core/util/cmdline_test.cc b/contrib/libs/grpc/test/core/util/cmdline_test.cc
index b1b7da6b17..60d2354a0c 100644
--- a/contrib/libs/grpc/test/core/util/cmdline_test.cc
+++ b/contrib/libs/grpc/test/core/util/cmdline_test.cc
@@ -321,15 +321,15 @@ static void test_usage(void) {
gpr_cmdline_on_extra_arg(cl, "file", "filenames to process", extra_arg_cb,
nullptr);
- TString usage = gpr_cmdline_usage_string(cl, "test");
- GPR_ASSERT(usage ==
- "Usage: test [--str=string] [--x=int] "
- "[--flag|--no-flag] [file...]\n");
+ TString usage = gpr_cmdline_usage_string(cl, "test");
+ GPR_ASSERT(usage ==
+ "Usage: test [--str=string] [--x=int] "
+ "[--flag|--no-flag] [file...]\n");
usage = gpr_cmdline_usage_string(cl, "/foo/test");
- GPR_ASSERT(usage ==
- "Usage: test [--str=string] [--x=int] "
- "[--flag|--no-flag] [file...]\n");
+ GPR_ASSERT(usage ==
+ "Usage: test [--str=string] [--x=int] "
+ "[--flag|--no-flag] [file...]\n");
gpr_cmdline_destroy(cl);
}
diff --git a/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.cc b/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.cc
index 00d4056ba5..a61eee78b4 100644
--- a/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.cc
+++ b/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.cc
@@ -1,118 +1,118 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <grpc/support/port_platform.h>
-
-#include "test/core/util/eval_args_mock_endpoint.h"
-
-#include <inttypes.h>
-
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
-#include <grpc/support/alloc.h>
-#include <grpc/support/string_util.h>
-#include "src/core/lib/iomgr/sockaddr.h"
-#include "src/core/lib/iomgr/sockaddr_utils.h"
-
-namespace grpc_core {
-
-class EvalArgsMockEndpoint {
- public:
- EvalArgsMockEndpoint(y_absl::string_view local_uri, y_absl::string_view peer_uri)
- : local_address_(local_uri), peer_(peer_uri) {
- base_.vtable = &vtable_;
- }
- grpc_endpoint* base() const { return const_cast<grpc_endpoint*>(&base_); }
- static void Read(grpc_endpoint* ep, grpc_slice_buffer* slices,
- grpc_closure* cb, bool unused) {}
- static void Write(grpc_endpoint* ep, grpc_slice_buffer* slices,
- grpc_closure* cb, void* unused) {}
- static void AddToPollset(grpc_endpoint* ep, grpc_pollset* unused) {}
- static void AddToPollsetSet(grpc_endpoint* ep, grpc_pollset_set* unused) {}
- static void DeleteFromPollsetSet(grpc_endpoint* ep,
- grpc_pollset_set* unused) {}
- static void Shutdown(grpc_endpoint* ep, grpc_error* why) {}
- static void Destroy(grpc_endpoint* ep) {
- EvalArgsMockEndpoint* m = reinterpret_cast<EvalArgsMockEndpoint*>(ep);
- delete m;
- }
-
- static y_absl::string_view GetPeer(grpc_endpoint* ep) {
- EvalArgsMockEndpoint* m = reinterpret_cast<EvalArgsMockEndpoint*>(ep);
- return m->peer_;
- }
-
- static y_absl::string_view GetLocalAddress(grpc_endpoint* ep) {
- EvalArgsMockEndpoint* m = reinterpret_cast<EvalArgsMockEndpoint*>(ep);
- return m->local_address_;
- }
-
- static grpc_resource_user* GetResourceUser(grpc_endpoint* ep) {
- return nullptr;
- }
-
- static int GetFd(grpc_endpoint* unused) { return -1; }
- static bool CanTrackErr(grpc_endpoint* unused) { return false; }
-
- private:
- static constexpr grpc_endpoint_vtable vtable_ = {
- EvalArgsMockEndpoint::Read,
- EvalArgsMockEndpoint::Write,
- EvalArgsMockEndpoint::AddToPollset,
- EvalArgsMockEndpoint::AddToPollsetSet,
- EvalArgsMockEndpoint::DeleteFromPollsetSet,
- EvalArgsMockEndpoint::Shutdown,
- EvalArgsMockEndpoint::Destroy,
- EvalArgsMockEndpoint::GetResourceUser,
- EvalArgsMockEndpoint::GetPeer,
- EvalArgsMockEndpoint::GetLocalAddress,
- EvalArgsMockEndpoint::GetFd,
- EvalArgsMockEndpoint::CanTrackErr};
- grpc_endpoint base_;
- TString local_address_;
- TString peer_;
-};
-
-constexpr grpc_endpoint_vtable EvalArgsMockEndpoint::vtable_;
-
-namespace {
-
-TString NameAndPortToURI(const char* addr, const int port) {
- grpc_sockaddr_in address;
- memset(&address, 0, sizeof(address));
- address.sin_family = AF_INET;
- address.sin_port = htons(port);
- inet_pton(AF_INET, addr, &address.sin_addr);
- grpc_resolved_address resolved;
- memset(&resolved, 0, sizeof(resolved));
- memcpy(resolved.addr, &address, sizeof(address));
- resolved.len = sizeof(address);
- return grpc_sockaddr_to_uri(&resolved);
-}
-
-} // namespace
-
-grpc_endpoint* CreateEvalArgsMockEndpoint(const char* local_address,
- const int local_port,
- const char* peer_address,
- const int peer_port) {
- EvalArgsMockEndpoint* m =
- new EvalArgsMockEndpoint(NameAndPortToURI(local_address, local_port),
- NameAndPortToURI(peer_address, peer_port));
- return m->base();
-}
-
-} // namespace grpc_core
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <grpc/support/port_platform.h>
+
+#include "test/core/util/eval_args_mock_endpoint.h"
+
+#include <inttypes.h>
+
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/iomgr/sockaddr_utils.h"
+
+namespace grpc_core {
+
+class EvalArgsMockEndpoint {
+ public:
+ EvalArgsMockEndpoint(y_absl::string_view local_uri, y_absl::string_view peer_uri)
+ : local_address_(local_uri), peer_(peer_uri) {
+ base_.vtable = &vtable_;
+ }
+ grpc_endpoint* base() const { return const_cast<grpc_endpoint*>(&base_); }
+ static void Read(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb, bool unused) {}
+ static void Write(grpc_endpoint* ep, grpc_slice_buffer* slices,
+ grpc_closure* cb, void* unused) {}
+ static void AddToPollset(grpc_endpoint* ep, grpc_pollset* unused) {}
+ static void AddToPollsetSet(grpc_endpoint* ep, grpc_pollset_set* unused) {}
+ static void DeleteFromPollsetSet(grpc_endpoint* ep,
+ grpc_pollset_set* unused) {}
+ static void Shutdown(grpc_endpoint* ep, grpc_error* why) {}
+ static void Destroy(grpc_endpoint* ep) {
+ EvalArgsMockEndpoint* m = reinterpret_cast<EvalArgsMockEndpoint*>(ep);
+ delete m;
+ }
+
+ static y_absl::string_view GetPeer(grpc_endpoint* ep) {
+ EvalArgsMockEndpoint* m = reinterpret_cast<EvalArgsMockEndpoint*>(ep);
+ return m->peer_;
+ }
+
+ static y_absl::string_view GetLocalAddress(grpc_endpoint* ep) {
+ EvalArgsMockEndpoint* m = reinterpret_cast<EvalArgsMockEndpoint*>(ep);
+ return m->local_address_;
+ }
+
+ static grpc_resource_user* GetResourceUser(grpc_endpoint* ep) {
+ return nullptr;
+ }
+
+ static int GetFd(grpc_endpoint* unused) { return -1; }
+ static bool CanTrackErr(grpc_endpoint* unused) { return false; }
+
+ private:
+ static constexpr grpc_endpoint_vtable vtable_ = {
+ EvalArgsMockEndpoint::Read,
+ EvalArgsMockEndpoint::Write,
+ EvalArgsMockEndpoint::AddToPollset,
+ EvalArgsMockEndpoint::AddToPollsetSet,
+ EvalArgsMockEndpoint::DeleteFromPollsetSet,
+ EvalArgsMockEndpoint::Shutdown,
+ EvalArgsMockEndpoint::Destroy,
+ EvalArgsMockEndpoint::GetResourceUser,
+ EvalArgsMockEndpoint::GetPeer,
+ EvalArgsMockEndpoint::GetLocalAddress,
+ EvalArgsMockEndpoint::GetFd,
+ EvalArgsMockEndpoint::CanTrackErr};
+ grpc_endpoint base_;
+ TString local_address_;
+ TString peer_;
+};
+
+constexpr grpc_endpoint_vtable EvalArgsMockEndpoint::vtable_;
+
+namespace {
+
+TString NameAndPortToURI(const char* addr, const int port) {
+ grpc_sockaddr_in address;
+ memset(&address, 0, sizeof(address));
+ address.sin_family = AF_INET;
+ address.sin_port = htons(port);
+ inet_pton(AF_INET, addr, &address.sin_addr);
+ grpc_resolved_address resolved;
+ memset(&resolved, 0, sizeof(resolved));
+ memcpy(resolved.addr, &address, sizeof(address));
+ resolved.len = sizeof(address);
+ return grpc_sockaddr_to_uri(&resolved);
+}
+
+} // namespace
+
+grpc_endpoint* CreateEvalArgsMockEndpoint(const char* local_address,
+ const int local_port,
+ const char* peer_address,
+ const int peer_port) {
+ EvalArgsMockEndpoint* m =
+ new EvalArgsMockEndpoint(NameAndPortToURI(local_address, local_port),
+ NameAndPortToURI(peer_address, peer_port));
+ return m->base();
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.h b/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.h
index 68b32cc891..8b4f13dc06 100644
--- a/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.h
+++ b/contrib/libs/grpc/test/core/util/eval_args_mock_endpoint.h
@@ -1,31 +1,31 @@
-// Copyright 2020 gRPC authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef GRPC_TEST_CORE_UTIL_EVAL_ARGS_MOCK_ENDPOINT_H
-#define GRPC_TEST_CORE_UTIL_EVAL_ARGS_MOCK_ENDPOINT_H
-
-#include <grpc/support/port_platform.h>
-
-#include "src/core/lib/iomgr/endpoint.h"
-
-namespace grpc_core {
-
-grpc_endpoint* CreateEvalArgsMockEndpoint(const char* local_address,
- const int local_port,
- const char* peer_address,
- const int peer_port);
-
-} // namespace grpc_core
-
-#endif // GRPC_TEST_CORE_UTIL_EVAL_ARGS_MOCK_ENDPOINT_H
+// Copyright 2020 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_TEST_CORE_UTIL_EVAL_ARGS_MOCK_ENDPOINT_H
+#define GRPC_TEST_CORE_UTIL_EVAL_ARGS_MOCK_ENDPOINT_H
+
+#include <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/endpoint.h"
+
+namespace grpc_core {
+
+grpc_endpoint* CreateEvalArgsMockEndpoint(const char* local_address,
+ const int local_port,
+ const char* peer_address,
+ const int peer_port);
+
+} // namespace grpc_core
+
+#endif // GRPC_TEST_CORE_UTIL_EVAL_ARGS_MOCK_ENDPOINT_H
diff --git a/contrib/libs/grpc/test/core/util/examine_stack.cc b/contrib/libs/grpc/test/core/util/examine_stack.cc
index 4400a343b4..cc57735de2 100644
--- a/contrib/libs/grpc/test/core/util/examine_stack.cc
+++ b/contrib/libs/grpc/test/core/util/examine_stack.cc
@@ -1,102 +1,102 @@
-/*
- *
- * Copyright 2020 the gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/port_platform.h>
-
-#include "test/core/util/examine_stack.h"
-
-#include <cstdio>
-#include <util/generic/string.h>
-
-#include "y_absl/debugging/stacktrace.h"
-#include "y_absl/debugging/symbolize.h"
-
-namespace {
-
-static constexpr int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
-
-static void DumpPCAndFrameSizeAndSymbol(void (*writerfn)(const char*, void*),
- void* writerfn_arg, void* pc,
- void* symbolize_pc, int framesize,
- const char* const prefix) {
- char tmp[1024];
- const char* symbol = "(unknown)";
- if (y_absl::Symbolize(symbolize_pc, tmp, sizeof(tmp))) {
- symbol = tmp;
- }
- char buf[1024];
- if (framesize <= 0) {
- snprintf(buf, sizeof(buf), "%s@ %*p (unknown) %s\n", prefix,
- kPrintfPointerFieldWidth, pc, symbol);
- } else {
- snprintf(buf, sizeof(buf), "%s@ %*p %9d %s\n", prefix,
- kPrintfPointerFieldWidth, pc, framesize, symbol);
- }
- writerfn(buf, writerfn_arg);
-}
-
-static void DumpPCAndFrameSize(void (*writerfn)(const char*, void*),
- void* writerfn_arg, void* pc, int framesize,
- const char* const prefix) {
- char buf[100];
- if (framesize <= 0) {
- snprintf(buf, sizeof(buf), "%s@ %*p (unknown)\n", prefix,
- kPrintfPointerFieldWidth, pc);
- } else {
- snprintf(buf, sizeof(buf), "%s@ %*p %9d\n", prefix,
- kPrintfPointerFieldWidth, pc, framesize);
- }
- writerfn(buf, writerfn_arg);
-}
-
-static void DumpStackTrace(void* const stack[], int frame_sizes[], int depth,
- bool symbolize_stacktrace,
- void (*writerfn)(const char*, void*),
- void* writerfn_arg) {
- for (int i = 0; i < depth; i++) {
- if (symbolize_stacktrace) {
- DumpPCAndFrameSizeAndSymbol(writerfn, writerfn_arg, stack[i],
- reinterpret_cast<char*>(stack[i]) - 1,
- frame_sizes[i], " ");
- } else {
- DumpPCAndFrameSize(writerfn, writerfn_arg, stack[i], frame_sizes[i],
- " ");
- }
- }
-}
-
-static void DebugWriteToString(const char* data, void* str) {
- reinterpret_cast<TString*>(str)->append(data);
-}
-
-} // namespace
-
-namespace grpc_core {
-
-TString CurrentStackTrace() {
- TString result = "Stack trace:\n";
- constexpr int kNumStackFrames = 32;
- void* stack[kNumStackFrames];
- int frame_sizes[kNumStackFrames];
- int depth = y_absl::GetStackFrames(stack, frame_sizes, kNumStackFrames, 1);
- DumpStackTrace(stack, frame_sizes, depth, true, DebugWriteToString,
- (void*)&result);
- return result;
-}
-
-} // namespace grpc_core
+/*
+ *
+ * Copyright 2020 the gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+
+#include "test/core/util/examine_stack.h"
+
+#include <cstdio>
+#include <util/generic/string.h>
+
+#include "y_absl/debugging/stacktrace.h"
+#include "y_absl/debugging/symbolize.h"
+
+namespace {
+
+static constexpr int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
+
+static void DumpPCAndFrameSizeAndSymbol(void (*writerfn)(const char*, void*),
+ void* writerfn_arg, void* pc,
+ void* symbolize_pc, int framesize,
+ const char* const prefix) {
+ char tmp[1024];
+ const char* symbol = "(unknown)";
+ if (y_absl::Symbolize(symbolize_pc, tmp, sizeof(tmp))) {
+ symbol = tmp;
+ }
+ char buf[1024];
+ if (framesize <= 0) {
+ snprintf(buf, sizeof(buf), "%s@ %*p (unknown) %s\n", prefix,
+ kPrintfPointerFieldWidth, pc, symbol);
+ } else {
+ snprintf(buf, sizeof(buf), "%s@ %*p %9d %s\n", prefix,
+ kPrintfPointerFieldWidth, pc, framesize, symbol);
+ }
+ writerfn(buf, writerfn_arg);
+}
+
+static void DumpPCAndFrameSize(void (*writerfn)(const char*, void*),
+ void* writerfn_arg, void* pc, int framesize,
+ const char* const prefix) {
+ char buf[100];
+ if (framesize <= 0) {
+ snprintf(buf, sizeof(buf), "%s@ %*p (unknown)\n", prefix,
+ kPrintfPointerFieldWidth, pc);
+ } else {
+ snprintf(buf, sizeof(buf), "%s@ %*p %9d\n", prefix,
+ kPrintfPointerFieldWidth, pc, framesize);
+ }
+ writerfn(buf, writerfn_arg);
+}
+
+static void DumpStackTrace(void* const stack[], int frame_sizes[], int depth,
+ bool symbolize_stacktrace,
+ void (*writerfn)(const char*, void*),
+ void* writerfn_arg) {
+ for (int i = 0; i < depth; i++) {
+ if (symbolize_stacktrace) {
+ DumpPCAndFrameSizeAndSymbol(writerfn, writerfn_arg, stack[i],
+ reinterpret_cast<char*>(stack[i]) - 1,
+ frame_sizes[i], " ");
+ } else {
+ DumpPCAndFrameSize(writerfn, writerfn_arg, stack[i], frame_sizes[i],
+ " ");
+ }
+ }
+}
+
+static void DebugWriteToString(const char* data, void* str) {
+ reinterpret_cast<TString*>(str)->append(data);
+}
+
+} // namespace
+
+namespace grpc_core {
+
+TString CurrentStackTrace() {
+ TString result = "Stack trace:\n";
+ constexpr int kNumStackFrames = 32;
+ void* stack[kNumStackFrames];
+ int frame_sizes[kNumStackFrames];
+ int depth = y_absl::GetStackFrames(stack, frame_sizes, kNumStackFrames, 1);
+ DumpStackTrace(stack, frame_sizes, depth, true, DebugWriteToString,
+ (void*)&result);
+ return result;
+}
+
+} // namespace grpc_core
diff --git a/contrib/libs/grpc/test/core/util/examine_stack.h b/contrib/libs/grpc/test/core/util/examine_stack.h
index 1eaf95792d..784365d13a 100644
--- a/contrib/libs/grpc/test/core/util/examine_stack.h
+++ b/contrib/libs/grpc/test/core/util/examine_stack.h
@@ -1,34 +1,34 @@
-/*
- *
- * Copyright 2020 the gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_TEST_CORE_UTIL_EXAMINE_STACK_H
-#define GRPC_TEST_CORE_UTIL_EXAMINE_STACK_H
-
-#include <grpc/support/port_platform.h>
-
-#include <util/generic/string.h>
-
-namespace grpc_core {
-
-// Return the current stack trace as a string (on multiple lines, beginning with
-// "Stack trace:\n")
-TString CurrentStackTrace();
-
-} // namespace grpc_core
-
-#endif /* GRPC_TEST_CORE_UTIL_EXAMINE_STACK_H */
+/*
+ *
+ * Copyright 2020 the gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_TEST_CORE_UTIL_EXAMINE_STACK_H
+#define GRPC_TEST_CORE_UTIL_EXAMINE_STACK_H
+
+#include <grpc/support/port_platform.h>
+
+#include <util/generic/string.h>
+
+namespace grpc_core {
+
+// Return the current stack trace as a string (on multiple lines, beginning with
+// "Stack trace:\n")
+TString CurrentStackTrace();
+
+} // namespace grpc_core
+
+#endif /* GRPC_TEST_CORE_UTIL_EXAMINE_STACK_H */
diff --git a/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc b/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc
index 99ab45120d..f228d2d778 100644
--- a/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc
+++ b/contrib/libs/grpc/test/core/util/fuzzer_corpus_test.cc
@@ -26,8 +26,8 @@
#include <stdio.h>
#include <sys/types.h>
-#include <grpc/grpc.h>
-
+#include <grpc/grpc.h>
+
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/iomgr/load_file.h"
#include "test/core/util/test_config.h"
@@ -47,35 +47,35 @@ using namespace gflags;
DEFINE_string(file, "", "Use this file as test data");
DEFINE_string(directory, "", "Use this directory as test data");
-class FuzzerCorpusTest : public ::testing::TestWithParam<TString> {};
+class FuzzerCorpusTest : public ::testing::TestWithParam<TString> {};
TEST_P(FuzzerCorpusTest, RunOneExample) {
- // Need to call grpc_init() here to use a slice, but need to shut it
- // down before calling LLVMFuzzerTestOneInput(), because most
- // implementations of that function will initialize and shutdown gRPC
- // internally.
- grpc_init();
+ // Need to call grpc_init() here to use a slice, but need to shut it
+ // down before calling LLVMFuzzerTestOneInput(), because most
+ // implementations of that function will initialize and shutdown gRPC
+ // internally.
+ grpc_init();
gpr_log(GPR_DEBUG, "Example file: %s", GetParam().c_str());
grpc_slice buffer;
squelch = false;
leak_check = false;
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(GetParam().c_str(), 0, &buffer)));
- size_t length = GRPC_SLICE_LENGTH(buffer);
- void* data = gpr_malloc(length);
- memcpy(data, GPR_SLICE_START_PTR(buffer), length);
+ size_t length = GRPC_SLICE_LENGTH(buffer);
+ void* data = gpr_malloc(length);
+ memcpy(data, GPR_SLICE_START_PTR(buffer), length);
grpc_slice_unref(buffer);
- grpc_shutdown_blocking();
- LLVMFuzzerTestOneInput(static_cast<uint8_t*>(data), length);
- gpr_free(data);
+ grpc_shutdown_blocking();
+ LLVMFuzzerTestOneInput(static_cast<uint8_t*>(data), length);
+ gpr_free(data);
}
class ExampleGenerator
- : public ::testing::internal::ParamGeneratorInterface<TString> {
+ : public ::testing::internal::ParamGeneratorInterface<TString> {
public:
- virtual ::testing::internal::ParamIteratorInterface<TString>* Begin()
+ virtual ::testing::internal::ParamIteratorInterface<TString>* Begin()
const;
- virtual ::testing::internal::ParamIteratorInterface<TString>* End() const;
+ virtual ::testing::internal::ParamIteratorInterface<TString>* End() const;
private:
void Materialize() const {
@@ -83,21 +83,21 @@ class ExampleGenerator
if (!FLAGS_file.empty()) examples_.push_back(FLAGS_file);
if (!FLAGS_directory.empty()) {
char* test_srcdir = gpr_getenv("TEST_SRCDIR");
- gpr_log(GPR_DEBUG, "test_srcdir=\"%s\"", test_srcdir);
- TString directory = FLAGS_directory;
+ gpr_log(GPR_DEBUG, "test_srcdir=\"%s\"", test_srcdir);
+ TString directory = FLAGS_directory;
if (test_srcdir != nullptr) {
- directory =
- test_srcdir + TString("/com_github_grpc_grpc/") + directory;
+ directory =
+ test_srcdir + TString("/com_github_grpc_grpc/") + directory;
}
- gpr_log(GPR_DEBUG, "Using corpus directory: %s", directory.c_str());
+ gpr_log(GPR_DEBUG, "Using corpus directory: %s", directory.c_str());
DIR* dp;
struct dirent* ep;
- dp = opendir(directory.c_str());
+ dp = opendir(directory.c_str());
if (dp != nullptr) {
while ((ep = readdir(dp)) != nullptr) {
- if (strcmp(ep->d_name, ".") != 0 && strcmp(ep->d_name, "..") != 0) {
- examples_.push_back(directory + "/" + ep->d_name);
+ if (strcmp(ep->d_name, ".") != 0 && strcmp(ep->d_name, "..") != 0) {
+ examples_.push_back(directory + "/" + ep->d_name);
}
}
@@ -109,28 +109,28 @@ class ExampleGenerator
gpr_free(test_srcdir);
}
}
- // Make sure we don't succeed without doing anything, which caused
- // us to be blind to our fuzzers not running for 9 months.
- GPR_ASSERT(!examples_.empty());
+ // Make sure we don't succeed without doing anything, which caused
+ // us to be blind to our fuzzers not running for 9 months.
+ GPR_ASSERT(!examples_.empty());
}
- mutable std::vector<TString> examples_;
+ mutable std::vector<TString> examples_;
};
class ExampleIterator
- : public ::testing::internal::ParamIteratorInterface<TString> {
+ : public ::testing::internal::ParamIteratorInterface<TString> {
public:
ExampleIterator(const ExampleGenerator& base_,
- std::vector<TString>::const_iterator begin)
+ std::vector<TString>::const_iterator begin)
: base_(base_), begin_(begin), current_(begin) {}
virtual const ExampleGenerator* BaseGenerator() const { return &base_; }
virtual void Advance() { current_++; }
virtual ExampleIterator* Clone() const { return new ExampleIterator(*this); }
- virtual const TString* Current() const { return &*current_; }
+ virtual const TString* Current() const { return &*current_; }
- virtual bool Equals(const ParamIteratorInterface<TString>& other) const {
+ virtual bool Equals(const ParamIteratorInterface<TString>& other) const {
return &base_ == other.BaseGenerator() &&
current_ == dynamic_cast<const ExampleIterator*>(&other)->current_;
}
@@ -140,17 +140,17 @@ class ExampleIterator
: base_(other.base_), begin_(other.begin_), current_(other.current_) {}
const ExampleGenerator& base_;
- const std::vector<TString>::const_iterator begin_;
- std::vector<TString>::const_iterator current_;
+ const std::vector<TString>::const_iterator begin_;
+ std::vector<TString>::const_iterator current_;
};
-::testing::internal::ParamIteratorInterface<TString>*
+::testing::internal::ParamIteratorInterface<TString>*
ExampleGenerator::Begin() const {
Materialize();
return new ExampleIterator(*this, examples_.begin());
}
-::testing::internal::ParamIteratorInterface<TString>*
+::testing::internal::ParamIteratorInterface<TString>*
ExampleGenerator::End() const {
Materialize();
return new ExampleIterator(*this, examples_.end());
@@ -158,11 +158,11 @@ ExampleGenerator::End() const {
INSTANTIATE_TEST_SUITE_P(
CorpusExamples, FuzzerCorpusTest,
- ::testing::internal::ParamGenerator<TString>(new ExampleGenerator));
+ ::testing::internal::ParamGenerator<TString>(new ExampleGenerator));
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
- grpc::testing::InitTest(&argc, &argv, true);
+ grpc::testing::InitTest(&argc, &argv, true);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
diff --git a/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl b/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl
index 99594b29e1..df2a4aa22f 100644
--- a/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl
+++ b/contrib/libs/grpc/test/core/util/grpc_fuzzer.bzl
@@ -14,12 +14,12 @@
load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
-def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", **kwargs):
+def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", **kwargs):
grpc_cc_test(
name = name,
srcs = srcs,
deps = deps + ["//test/core/util:fuzzer_corpus_test"],
- data = data + native.glob([corpus + "/**"]),
+ data = data + native.glob([corpus + "/**"]),
external_deps = [
"gtest",
],
diff --git a/contrib/libs/grpc/test/core/util/mock_endpoint.cc b/contrib/libs/grpc/test/core/util/mock_endpoint.cc
index 3c2d6a3f8b..ad00b6baf5 100644
--- a/contrib/libs/grpc/test/core/util/mock_endpoint.cc
+++ b/contrib/libs/grpc/test/core/util/mock_endpoint.cc
@@ -22,12 +22,12 @@
headers. Therefore, sockaddr.h must always be included first */
#include "src/core/lib/iomgr/sockaddr.h"
-#include <inttypes.h>
-
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <inttypes.h>
+
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include "test/core/util/mock_endpoint.h"
#include <grpc/support/alloc.h>
@@ -98,14 +98,14 @@ static void me_destroy(grpc_endpoint* ep) {
gpr_free(m);
}
-static y_absl::string_view me_get_peer(grpc_endpoint* /*ep*/) {
- return "fake:mock_endpoint";
-}
-
-static y_absl::string_view me_get_local_address(grpc_endpoint* /*ep*/) {
- return "fake:mock_endpoint";
+static y_absl::string_view me_get_peer(grpc_endpoint* /*ep*/) {
+ return "fake:mock_endpoint";
}
+static y_absl::string_view me_get_local_address(grpc_endpoint* /*ep*/) {
+ return "fake:mock_endpoint";
+}
+
static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) {
mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
return m->resource_user;
@@ -124,7 +124,7 @@ static const grpc_endpoint_vtable vtable = {me_read,
me_destroy,
me_get_resource_user,
me_get_peer,
- me_get_local_address,
+ me_get_local_address,
me_get_fd,
me_can_track_err};
@@ -132,8 +132,8 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
grpc_resource_quota* resource_quota) {
mock_endpoint* m = static_cast<mock_endpoint*>(gpr_malloc(sizeof(*m)));
m->base.vtable = &vtable;
- TString name = y_absl::StrFormat("mock_endpoint_%" PRIxPTR, (intptr_t)m);
- m->resource_user = grpc_resource_user_create(resource_quota, name.c_str());
+ TString name = y_absl::StrFormat("mock_endpoint_%" PRIxPTR, (intptr_t)m);
+ m->resource_user = grpc_resource_user_create(resource_quota, name.c_str());
grpc_slice_buffer_init(&m->read_buffer);
gpr_mu_init(&m->mu);
m->on_write = on_write;
diff --git a/contrib/libs/grpc/test/core/util/passthru_endpoint.cc b/contrib/libs/grpc/test/core/util/passthru_endpoint.cc
index a5baafad02..d009195b0a 100644
--- a/contrib/libs/grpc/test/core/util/passthru_endpoint.cc
+++ b/contrib/libs/grpc/test/core/util/passthru_endpoint.cc
@@ -27,10 +27,10 @@
#include <inttypes.h>
#include <string.h>
-#include <util/generic/string.h>
-
-#include "y_absl/strings/str_format.h"
-
+#include <util/generic/string.h>
+
+#include "y_absl/strings/str_format.h"
+
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/iomgr/sockaddr.h"
@@ -152,20 +152,20 @@ static void me_destroy(grpc_endpoint* ep) {
}
}
-static y_absl::string_view me_get_peer(grpc_endpoint* ep) {
- passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent;
- return (reinterpret_cast<half*>(ep)) == &p->client
- ? "fake:mock_client_endpoint"
- : "fake:mock_server_endpoint";
-}
-
-static y_absl::string_view me_get_local_address(grpc_endpoint* ep) {
+static y_absl::string_view me_get_peer(grpc_endpoint* ep) {
passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent;
return (reinterpret_cast<half*>(ep)) == &p->client
- ? "fake:mock_client_endpoint"
- : "fake:mock_server_endpoint";
+ ? "fake:mock_client_endpoint"
+ : "fake:mock_server_endpoint";
}
+static y_absl::string_view me_get_local_address(grpc_endpoint* ep) {
+ passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent;
+ return (reinterpret_cast<half*>(ep)) == &p->client
+ ? "fake:mock_client_endpoint"
+ : "fake:mock_server_endpoint";
+}
+
static int me_get_fd(grpc_endpoint* /*ep*/) { return -1; }
static bool me_can_track_err(grpc_endpoint* /*ep*/) { return false; }
@@ -185,7 +185,7 @@ static const grpc_endpoint_vtable vtable = {
me_destroy,
me_get_resource_user,
me_get_peer,
- me_get_local_address,
+ me_get_local_address,
me_get_fd,
me_can_track_err,
};
@@ -197,9 +197,9 @@ static void half_init(half* m, passthru_endpoint* parent,
m->parent = parent;
grpc_slice_buffer_init(&m->read_buffer);
m->on_read = nullptr;
- TString name = y_absl::StrFormat("passthru_endpoint_%s_%" PRIxPTR,
- half_name, (intptr_t)parent);
- m->resource_user = grpc_resource_user_create(resource_quota, name.c_str());
+ TString name = y_absl::StrFormat("passthru_endpoint_%s_%" PRIxPTR,
+ half_name, (intptr_t)parent);
+ m->resource_user = grpc_resource_user_create(resource_quota, name.c_str());
}
void grpc_passthru_endpoint_create(grpc_endpoint** client,
diff --git a/contrib/libs/grpc/test/core/util/port.cc b/contrib/libs/grpc/test/core/util/port.cc
index 5a34b6026f..41732fb381 100644
--- a/contrib/libs/grpc/test/core/util/port.cc
+++ b/contrib/libs/grpc/test/core/util/port.cc
@@ -38,14 +38,14 @@
static int* chosen_ports = nullptr;
static size_t num_chosen_ports = 0;
-static grpc_core::Mutex* g_default_port_picker_mu;
-static gpr_once g_default_port_picker_init = GPR_ONCE_INIT;
-
-static void init_default_port_picker() {
- g_default_port_picker_mu = new grpc_core::Mutex();
-}
-
-static int free_chosen_port_locked(int port) {
+static grpc_core::Mutex* g_default_port_picker_mu;
+static gpr_once g_default_port_picker_init = GPR_ONCE_INIT;
+
+static void init_default_port_picker() {
+ g_default_port_picker_mu = new grpc_core::Mutex();
+}
+
+static int free_chosen_port_locked(int port) {
size_t i;
int found = 0;
size_t found_at = 0;
@@ -67,7 +67,7 @@ static int free_chosen_port_locked(int port) {
}
static void free_chosen_ports(void) {
- grpc_core::MutexLock lock(g_default_port_picker_mu);
+ grpc_core::MutexLock lock(g_default_port_picker_mu);
size_t i;
grpc_init();
for (i = 0; i < num_chosen_ports; i++) {
@@ -77,7 +77,7 @@ static void free_chosen_ports(void) {
gpr_free(chosen_ports);
}
-static void chose_port_locked(int port) {
+static void chose_port_locked(int port) {
if (chosen_ports == nullptr) {
atexit(free_chosen_ports);
}
@@ -88,11 +88,11 @@ static void chose_port_locked(int port) {
}
static int grpc_pick_unused_port_impl(void) {
- gpr_once_init(&g_default_port_picker_init, init_default_port_picker);
- grpc_core::MutexLock lock(g_default_port_picker_mu);
+ gpr_once_init(&g_default_port_picker_init, init_default_port_picker);
+ grpc_core::MutexLock lock(g_default_port_picker_mu);
int port = grpc_pick_port_using_server();
if (port != 0) {
- chose_port_locked(port);
+ chose_port_locked(port);
}
return port;
@@ -112,9 +112,9 @@ static int grpc_pick_unused_port_or_die_impl(void) {
}
static void grpc_recycle_unused_port_impl(int port) {
- gpr_once_init(&g_default_port_picker_init, init_default_port_picker);
- grpc_core::MutexLock lock(g_default_port_picker_mu);
- GPR_ASSERT(free_chosen_port_locked(port));
+ gpr_once_init(&g_default_port_picker_init, init_default_port_picker);
+ grpc_core::MutexLock lock(g_default_port_picker_mu);
+ GPR_ASSERT(free_chosen_port_locked(port));
}
static grpc_pick_port_functions g_pick_port_functions = {
diff --git a/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc b/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc
index 5e043e7f97..82d6b825d1 100644
--- a/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc
+++ b/contrib/libs/grpc/test/core/util/port_isolated_runtime_environment.cc
@@ -43,7 +43,7 @@ static int get_random_port_offset() {
static int s_initial_offset = get_random_port_offset();
static gpr_atm s_pick_counter = 0;
-static int grpc_pick_unused_port_or_die_impl(void) {
+static int grpc_pick_unused_port_or_die_impl(void) {
int orig_counter_val =
static_cast<int>(gpr_atm_full_fetch_add(&s_pick_counter, 1));
GPR_ASSERT(orig_counter_val < (MAX_PORT - MIN_PORT + 1));
@@ -51,19 +51,19 @@ static int grpc_pick_unused_port_or_die_impl(void) {
(s_initial_offset + orig_counter_val) % (MAX_PORT - MIN_PORT + 1);
}
-int grpc_pick_unused_port_or_die(void) {
- while (true) {
- int port = grpc_pick_unused_port_or_die_impl();
- // 5985 cannot be bound on Windows RBE and results in
- // WSA_ERROR 10013: "An attempt was made to access a socket in a way
- // forbidden by its access permissions."
- if (port == 5985) {
- continue;
- }
- return port;
- }
-}
-
+int grpc_pick_unused_port_or_die(void) {
+ while (true) {
+ int port = grpc_pick_unused_port_or_die_impl();
+ // 5985 cannot be bound on Windows RBE and results in
+ // WSA_ERROR 10013: "An attempt was made to access a socket in a way
+ // forbidden by its access permissions."
+ if (port == 5985) {
+ continue;
+ }
+ return port;
+ }
+}
+
void grpc_recycle_unused_port(int port) { (void)port; }
#endif /* GRPC_PORT_ISOLATED_RUNTIME */
diff --git a/contrib/libs/grpc/test/core/util/port_server_client.cc b/contrib/libs/grpc/test/core/util/port_server_client.cc
index 973068dcda..9101131441 100644
--- a/contrib/libs/grpc/test/core/util/port_server_client.cc
+++ b/contrib/libs/grpc/test/core/util/port_server_client.cc
@@ -66,54 +66,54 @@ void grpc_free_port_using_server(int port) {
grpc_closure* shutdown_closure;
grpc_init();
- {
- grpc_core::ExecCtx exec_ctx;
+ {
+ grpc_core::ExecCtx exec_ctx;
- pr = {};
- memset(&req, 0, sizeof(req));
- rsp = {};
+ pr = {};
+ memset(&req, 0, sizeof(req));
+ rsp = {};
- grpc_pollset* pollset =
- static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
- grpc_pollset_init(pollset, &pr.mu);
- pr.pops = grpc_polling_entity_create_from_pollset(pollset);
- shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
- grpc_schedule_on_exec_ctx);
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(pollset, &pr.mu);
+ pr.pops = grpc_polling_entity_create_from_pollset(pollset);
+ shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
+ grpc_schedule_on_exec_ctx);
- req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
- gpr_asprintf(&path, "/drop/%d", port);
- req.http.path = path;
+ req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
+ gpr_asprintf(&path, "/drop/%d", port);
+ req.http.path = path;
- grpc_httpcli_context_init(&context);
- grpc_resource_quota* resource_quota =
- grpc_resource_quota_create("port_server_client/free");
- grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
- grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
- GRPC_CLOSURE_CREATE(freed_port_from_server, &pr,
- grpc_schedule_on_exec_ctx),
- &rsp);
- grpc_resource_quota_unref_internal(resource_quota);
- grpc_core::ExecCtx::Get()->Flush();
- gpr_mu_lock(pr.mu);
- while (!pr.done) {
- grpc_pollset_worker* worker = nullptr;
- if (!GRPC_LOG_IF_ERROR(
- "pollset_work",
- grpc_pollset_work(
- grpc_polling_entity_pollset(&pr.pops), &worker,
- grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
- pr.done = 1;
- }
+ grpc_httpcli_context_init(&context);
+ grpc_resource_quota* resource_quota =
+ grpc_resource_quota_create("port_server_client/free");
+ grpc_httpcli_get(&context, &pr.pops, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
+ GRPC_CLOSURE_CREATE(freed_port_from_server, &pr,
+ grpc_schedule_on_exec_ctx),
+ &rsp);
+ grpc_resource_quota_unref_internal(resource_quota);
+ grpc_core::ExecCtx::Get()->Flush();
+ gpr_mu_lock(pr.mu);
+ while (!pr.done) {
+ grpc_pollset_worker* worker = nullptr;
+ if (!GRPC_LOG_IF_ERROR(
+ "pollset_work",
+ grpc_pollset_work(
+ grpc_polling_entity_pollset(&pr.pops), &worker,
+ grpc_core::ExecCtx::Get()->Now() + GPR_MS_PER_SEC))) {
+ pr.done = 1;
+ }
}
- gpr_mu_unlock(pr.mu);
+ gpr_mu_unlock(pr.mu);
- grpc_httpcli_context_destroy(&context);
- grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
- shutdown_closure);
+ grpc_httpcli_context_destroy(&context);
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
+ shutdown_closure);
- gpr_free(path);
- grpc_http_response_destroy(&rsp);
- }
+ gpr_free(path);
+ grpc_http_response_destroy(&rsp);
+ }
grpc_shutdown();
}
diff --git a/contrib/libs/grpc/test/core/util/reconnect_server.cc b/contrib/libs/grpc/test/core/util/reconnect_server.cc
index 070ab3fa0a..0509ac26c7 100644
--- a/contrib/libs/grpc/test/core/util/reconnect_server.cc
+++ b/contrib/libs/grpc/test/core/util/reconnect_server.cc
@@ -21,12 +21,12 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include <string.h>
-#include "y_absl/strings/string_view.h"
+#include "y_absl/strings/string_view.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/tcp_server.h"
@@ -61,8 +61,8 @@ static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_pollset* /*accepting_pollset*/,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- y_absl::string_view peer;
- int last_colon;
+ y_absl::string_view peer;
+ int last_colon;
reconnect_server* server = static_cast<reconnect_server*>(arg);
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
timestamp_list* new_tail;
@@ -70,16 +70,16 @@ static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(tcp);
- last_colon = peer.rfind(':');
- if (server->peer == nullptr) {
- server->peer = new TString(peer);
- } else {
- if (last_colon == TString::npos) {
- gpr_log(GPR_ERROR, "peer does not contain a ':'");
- } else if (peer.compare(0, static_cast<size_t>(last_colon),
- *server->peer) != 0) {
- gpr_log(GPR_ERROR, "mismatched peer! %s vs %s", server->peer->c_str(),
- TString(peer).c_str());
+ last_colon = peer.rfind(':');
+ if (server->peer == nullptr) {
+ server->peer = new TString(peer);
+ } else {
+ if (last_colon == TString::npos) {
+ gpr_log(GPR_ERROR, "peer does not contain a ':'");
+ } else if (peer.compare(0, static_cast<size_t>(last_colon),
+ *server->peer) != 0) {
+ gpr_log(GPR_ERROR, "mismatched peer! %s vs %s", server->peer->c_str(),
+ TString(peer).c_str());
}
}
new_tail = static_cast<timestamp_list*>(gpr_malloc(sizeof(timestamp_list)));
@@ -119,7 +119,7 @@ void reconnect_server_clear_timestamps(reconnect_server* server) {
server->head = new_head;
}
server->tail = nullptr;
- delete server->peer;
+ delete server->peer;
server->peer = nullptr;
}
diff --git a/contrib/libs/grpc/test/core/util/reconnect_server.h b/contrib/libs/grpc/test/core/util/reconnect_server.h
index 5fd03821f7..4572bf3726 100644
--- a/contrib/libs/grpc/test/core/util/reconnect_server.h
+++ b/contrib/libs/grpc/test/core/util/reconnect_server.h
@@ -32,7 +32,7 @@ typedef struct reconnect_server {
test_tcp_server tcp_server;
timestamp_list* head;
timestamp_list* tail;
- TString* peer;
+ TString* peer;
int max_reconnect_backoff_ms;
} reconnect_server;
diff --git a/contrib/libs/grpc/test/core/util/test_config.cc b/contrib/libs/grpc/test/core/util/test_config.cc
index 9e57a486b2..5facb59ed0 100644
--- a/contrib/libs/grpc/test/core/util/test_config.cc
+++ b/contrib/libs/grpc/test/core/util/test_config.cc
@@ -18,7 +18,7 @@
#include "test/core/util/test_config.h"
-#include <grpc/impl/codegen/gpr_types.h>
+#include <grpc/impl/codegen/gpr_types.h>
#include <inttypes.h>
#include <signal.h>
#include <stdbool.h>
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
-#include <grpc/grpc.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -34,9 +34,9 @@
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/surface/init.h"
-#include "y_absl/debugging/failure_signal_handler.h"
-#include "y_absl/debugging/symbolize.h"
-
+#include "y_absl/debugging/failure_signal_handler.h"
+#include "y_absl/debugging/symbolize.h"
+
int64_t g_fixture_slowdown_factor = 1;
int64_t g_poller_slowdown_factor = 1;
@@ -64,7 +64,7 @@ static unsigned seed(void) { return (unsigned)_getpid(); }
#pragma comment(lib, "dbghelp.lib")
#endif
-static void print_stack_from_context(HANDLE thread, CONTEXT c) {
+static void print_stack_from_context(HANDLE thread, CONTEXT c) {
STACKFRAME s; // in/out stackframe
memset(&s, 0, sizeof(s));
DWORD imageType;
@@ -106,45 +106,45 @@ static void print_stack_from_context(HANDLE thread, CONTEXT c) {
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFOW);
- const unsigned short MAX_CALLERS_SHOWN =
- 8192; // avoid flooding the stderr if stacktrace is way too long
- for (int frame = 0; frame < MAX_CALLERS_SHOWN &&
- StackWalk(imageType, process, thread, &s, &c, 0,
- SymFunctionTableAccess, SymGetModuleBase, 0);
- frame++) {
- PWSTR symbol_name = L"<<no symbol>>";
- DWORD64 symbol_address = 0;
- if (SymFromAddrW(process, (DWORD64)(s.AddrPC.Offset), 0, symbol)) {
- symbol_name = symbol->Name;
- symbol_address = (DWORD64)symbol->Address;
- }
-
- PWSTR file_name = L"<<no line info>>";
- int line_number = 0;
- IMAGEHLP_LINE64 line;
- line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
- DWORD displacement = 0;
- if (SymGetLineFromAddrW64(process, (DWORD64)(s.AddrPC.Offset),
- &displacement, &line)) {
- file_name = line.FileName;
- line_number = (int)line.LineNumber;
- }
-
- fwprintf(stderr, L"*** %d: %016I64X %ls - %016I64X (%ls:%d)\n", frame,
- (DWORD64)(s.AddrPC.Offset), symbol_name, symbol_address, file_name,
- line_number);
+ const unsigned short MAX_CALLERS_SHOWN =
+ 8192; // avoid flooding the stderr if stacktrace is way too long
+ for (int frame = 0; frame < MAX_CALLERS_SHOWN &&
+ StackWalk(imageType, process, thread, &s, &c, 0,
+ SymFunctionTableAccess, SymGetModuleBase, 0);
+ frame++) {
+ PWSTR symbol_name = L"<<no symbol>>";
+ DWORD64 symbol_address = 0;
+ if (SymFromAddrW(process, (DWORD64)(s.AddrPC.Offset), 0, symbol)) {
+ symbol_name = symbol->Name;
+ symbol_address = (DWORD64)symbol->Address;
+ }
+
+ PWSTR file_name = L"<<no line info>>";
+ int line_number = 0;
+ IMAGEHLP_LINE64 line;
+ line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
+ DWORD displacement = 0;
+ if (SymGetLineFromAddrW64(process, (DWORD64)(s.AddrPC.Offset),
+ &displacement, &line)) {
+ file_name = line.FileName;
+ line_number = (int)line.LineNumber;
+ }
+
+ fwprintf(stderr, L"*** %d: %016I64X %ls - %016I64X (%ls:%d)\n", frame,
+ (DWORD64)(s.AddrPC.Offset), symbol_name, symbol_address, file_name,
+ line_number);
fflush(stderr);
}
free(symbol);
}
-static void print_current_stack() {
- CONTEXT context;
- RtlCaptureContext(&context);
- print_stack_from_context(GetCurrentThread(), context);
-}
-
+static void print_current_stack() {
+ CONTEXT context;
+ RtlCaptureContext(&context);
+ print_stack_from_context(GetCurrentThread(), context);
+}
+
static LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) {
fprintf(stderr, "Exception handler called, dumping information\n");
bool try_to_print_stack = true;
@@ -158,7 +158,7 @@ static LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) {
exrec = exrec->ExceptionRecord;
}
if (try_to_print_stack) {
- print_stack_from_context(GetCurrentThread(), *ex_info->ContextRecord);
+ print_stack_from_context(GetCurrentThread(), *ex_info->ContextRecord);
}
if (IsDebuggerPresent()) {
__debugbreak();
@@ -371,17 +371,17 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms) {
GPR_TIMESPAN));
}
-void grpc_test_init(int argc, char** argv) {
-#if GPR_WINDOWS
- // Windows cannot use y_absl::InitializeSymbolizer until it fixes mysterious
- // SymInitialize failure using Bazel RBE on Windows
- // https://github.com/grpc/grpc/issues/24178
+void grpc_test_init(int argc, char** argv) {
+#if GPR_WINDOWS
+ // Windows cannot use y_absl::InitializeSymbolizer until it fixes mysterious
+ // SymInitialize failure using Bazel RBE on Windows
+ // https://github.com/grpc/grpc/issues/24178
install_crash_handler();
-#else
- y_absl::InitializeSymbolizer(argv[0]);
- y_absl::FailureSignalHandlerOptions options;
- y_absl::InstallFailureSignalHandler(options);
-#endif
+#else
+ y_absl::InitializeSymbolizer(argv[0]);
+ y_absl::FailureSignalHandlerOptions options;
+ y_absl::InstallFailureSignalHandler(options);
+#endif
gpr_log(GPR_DEBUG,
"test slowdown factor: sanitizer=%" PRId64 ", fixture=%" PRId64
", poller=%" PRId64 ", total=%" PRId64,
@@ -392,19 +392,19 @@ void grpc_test_init(int argc, char** argv) {
srand(seed());
}
-bool grpc_wait_until_shutdown(int64_t time_s) {
- gpr_timespec deadline = grpc_timeout_seconds_to_deadline(time_s);
- while (grpc_is_initialized()) {
- grpc_maybe_wait_for_async_shutdown();
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_millis(1, GPR_TIMESPAN)));
- if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) > 0) {
- return false;
- }
- }
- return true;
-}
-
+bool grpc_wait_until_shutdown(int64_t time_s) {
+ gpr_timespec deadline = grpc_timeout_seconds_to_deadline(time_s);
+ while (grpc_is_initialized()) {
+ grpc_maybe_wait_for_async_shutdown();
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(1, GPR_TIMESPAN)));
+ if (gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) > 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
namespace grpc {
namespace testing {
@@ -412,32 +412,32 @@ TestEnvironment::TestEnvironment(int argc, char** argv) {
grpc_test_init(argc, argv);
}
-TestEnvironment::~TestEnvironment() {
- // This will wait until gRPC shutdown has actually happened to make sure
- // no gRPC resources (such as thread) are active. (timeout = 10s)
- if (!grpc_wait_until_shutdown(10)) {
- gpr_log(GPR_ERROR, "Timeout in waiting for gRPC shutdown");
- }
- if (BuiltUnderMsan()) {
- // This is a workaround for MSAN. MSAN doesn't like having shutdown thread
- // running. Although the code above waits until shutdown is done, chances
- // are that thread itself is still alive. To workaround this problem, this
- // is going to wait for 0.5 sec to give a chance to the shutdown thread to
- // exit. https://github.com/grpc/grpc/issues/23695
- gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
- gpr_time_from_millis(500, GPR_TIMESPAN)));
- }
- gpr_log(GPR_INFO, "TestEnvironment ends");
-}
-
-TestGrpcScope::TestGrpcScope() { grpc_init(); }
-
-TestGrpcScope::~TestGrpcScope() {
- grpc_shutdown();
- if (!grpc_wait_until_shutdown(10)) {
- gpr_log(GPR_ERROR, "Timeout in waiting for gRPC shutdown");
- }
-}
-
+TestEnvironment::~TestEnvironment() {
+ // This will wait until gRPC shutdown has actually happened to make sure
+ // no gRPC resources (such as thread) are active. (timeout = 10s)
+ if (!grpc_wait_until_shutdown(10)) {
+ gpr_log(GPR_ERROR, "Timeout in waiting for gRPC shutdown");
+ }
+ if (BuiltUnderMsan()) {
+ // This is a workaround for MSAN. MSAN doesn't like having shutdown thread
+ // running. Although the code above waits until shutdown is done, chances
+ // are that thread itself is still alive. To workaround this problem, this
+ // is going to wait for 0.5 sec to give a chance to the shutdown thread to
+ // exit. https://github.com/grpc/grpc/issues/23695
+ gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
+ gpr_time_from_millis(500, GPR_TIMESPAN)));
+ }
+ gpr_log(GPR_INFO, "TestEnvironment ends");
+}
+
+TestGrpcScope::TestGrpcScope() { grpc_init(); }
+
+TestGrpcScope::~TestGrpcScope() {
+ grpc_shutdown();
+ if (!grpc_wait_until_shutdown(10)) {
+ gpr_log(GPR_ERROR, "Timeout in waiting for gRPC shutdown");
+ }
+}
+
} // namespace testing
} // namespace grpc
diff --git a/contrib/libs/grpc/test/core/util/test_config.h b/contrib/libs/grpc/test/core/util/test_config.h
index 6ac43de266..3c5ad5dfe1 100644
--- a/contrib/libs/grpc/test/core/util/test_config.h
+++ b/contrib/libs/grpc/test/core/util/test_config.h
@@ -37,25 +37,25 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms);
#define GRPC_TEST_PICK_PORT
#endif
-// Returns whether this is built under ThreadSanitizer
-bool BuiltUnderTsan();
-
-// Returns whether this is built under AddressSanitizer
-bool BuiltUnderAsan();
-
-// Returns whether this is built under MemorySanitizer
-bool BuiltUnderMsan();
-
-// Returns whether this is built under UndefinedBehaviorSanitizer
-bool BuiltUnderUbsan();
-
+// Returns whether this is built under ThreadSanitizer
+bool BuiltUnderTsan();
+
+// Returns whether this is built under AddressSanitizer
+bool BuiltUnderAsan();
+
+// Returns whether this is built under MemorySanitizer
+bool BuiltUnderMsan();
+
+// Returns whether this is built under UndefinedBehaviorSanitizer
+bool BuiltUnderUbsan();
+
// Prefer TestEnvironment below.
void grpc_test_init(int argc, char** argv);
-// Wait until gRPC is fully shut down.
-// Returns if grpc is shutdown
-bool grpc_wait_until_shutdown(int64_t time_s);
-
+// Wait until gRPC is fully shut down.
+// Returns if grpc is shutdown
+bool grpc_wait_until_shutdown(int64_t time_s);
+
namespace grpc {
namespace testing {
@@ -67,15 +67,15 @@ class TestEnvironment {
~TestEnvironment();
};
-// A TestGrpcScope makes sure that
-// - when it's created, gRPC will be initialized
-// - when it's destroyed, gRPC will shutdown and it waits until shutdown
-class TestGrpcScope {
- public:
- TestGrpcScope();
- ~TestGrpcScope();
-};
-
+// A TestGrpcScope makes sure that
+// - when it's created, gRPC will be initialized
+// - when it's destroyed, gRPC will shutdown and it waits until shutdown
+class TestGrpcScope {
+ public:
+ TestGrpcScope();
+ ~TestGrpcScope();
+};
+
} // namespace testing
} // namespace grpc
diff --git a/contrib/libs/grpc/test/core/util/test_lb_policies.cc b/contrib/libs/grpc/test/core/util/test_lb_policies.cc
index c1c1e9c56a..8e3084bd09 100644
--- a/contrib/libs/grpc/test/core/util/test_lb_policies.cc
+++ b/contrib/libs/grpc/test/core/util/test_lb_policies.cc
@@ -18,7 +18,7 @@
#include "test/core/util/test_lb_policies.h"
-#include <util/generic/string.h>
+#include <util/generic/string.h>
#include <grpc/support/log.h>
@@ -50,10 +50,10 @@ class ForwardingLoadBalancingPolicy : public LoadBalancingPolicy {
public:
ForwardingLoadBalancingPolicy(
std::unique_ptr<ChannelControlHelper> delegating_helper, Args args,
- const TString& delegate_policy_name, intptr_t initial_refcount = 1)
+ const TString& delegate_policy_name, intptr_t initial_refcount = 1)
: LoadBalancingPolicy(std::move(args), initial_refcount) {
Args delegate_args;
- delegate_args.work_serializer = work_serializer();
+ delegate_args.work_serializer = work_serializer();
delegate_args.channel_control_helper = std::move(delegating_helper);
delegate_args.args = args.args;
delegate_ = LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
@@ -79,118 +79,118 @@ class ForwardingLoadBalancingPolicy : public LoadBalancingPolicy {
};
//
-// CopyMetadataToVector()
-//
-
-MetadataVector CopyMetadataToVector(
- LoadBalancingPolicy::MetadataInterface* metadata) {
- MetadataVector result;
- for (const auto& p : *metadata) {
- result.push_back({TString(p.first), TString(p.second)});
- }
- return result;
-}
-
-//
-// TestPickArgsLb
-//
-
-constexpr char kTestPickArgsLbPolicyName[] = "test_pick_args_lb";
-
-class TestPickArgsLb : public ForwardingLoadBalancingPolicy {
- public:
- TestPickArgsLb(Args args, TestPickArgsCallback cb)
- : ForwardingLoadBalancingPolicy(
- y_absl::make_unique<Helper>(RefCountedPtr<TestPickArgsLb>(this), cb),
- std::move(args),
- /*delegate_lb_policy_name=*/"pick_first",
- /*initial_refcount=*/2) {}
-
- ~TestPickArgsLb() override = default;
-
- const char* name() const override { return kTestPickArgsLbPolicyName; }
-
- private:
- class Picker : public SubchannelPicker {
- public:
- Picker(std::unique_ptr<SubchannelPicker> delegate_picker,
- TestPickArgsCallback cb)
- : delegate_picker_(std::move(delegate_picker)), cb_(std::move(cb)) {}
-
- PickResult Pick(PickArgs args) override {
- // Report args seen.
- PickArgsSeen args_seen;
- args_seen.path = TString(args.path);
- args_seen.metadata = CopyMetadataToVector(args.initial_metadata);
- cb_(args_seen);
- // Do pick.
- return delegate_picker_->Pick(args);
- }
-
- private:
- std::unique_ptr<SubchannelPicker> delegate_picker_;
- TestPickArgsCallback cb_;
- };
-
- class Helper : public ChannelControlHelper {
- public:
- Helper(RefCountedPtr<TestPickArgsLb> parent, TestPickArgsCallback cb)
- : parent_(std::move(parent)), cb_(std::move(cb)) {}
-
- RefCountedPtr<SubchannelInterface> CreateSubchannel(
- ServerAddress address, const grpc_channel_args& args) override {
- return parent_->channel_control_helper()->CreateSubchannel(
- std::move(address), args);
- }
-
- void UpdateState(grpc_connectivity_state state, const y_absl::Status& status,
- std::unique_ptr<SubchannelPicker> picker) override {
- parent_->channel_control_helper()->UpdateState(
- state, status, y_absl::make_unique<Picker>(std::move(picker), cb_));
- }
-
- void RequestReresolution() override {
- parent_->channel_control_helper()->RequestReresolution();
- }
-
- void AddTraceEvent(TraceSeverity severity,
- y_absl::string_view message) override {
- parent_->channel_control_helper()->AddTraceEvent(severity, message);
- }
-
- private:
- RefCountedPtr<TestPickArgsLb> parent_;
- TestPickArgsCallback cb_;
- };
-};
-
-class TestPickArgsLbConfig : public LoadBalancingPolicy::Config {
- public:
- const char* name() const override { return kTestPickArgsLbPolicyName; }
-};
-
-class TestPickArgsLbFactory : public LoadBalancingPolicyFactory {
- public:
- explicit TestPickArgsLbFactory(TestPickArgsCallback cb)
- : cb_(std::move(cb)) {}
-
- OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
- LoadBalancingPolicy::Args args) const override {
- return MakeOrphanable<TestPickArgsLb>(std::move(args), cb_);
- }
-
- const char* name() const override { return kTestPickArgsLbPolicyName; }
-
- RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
- const Json& /*json*/, grpc_error** /*error*/) const override {
- return MakeRefCounted<TestPickArgsLbConfig>();
- }
-
- private:
- TestPickArgsCallback cb_;
-};
-
-//
+// CopyMetadataToVector()
+//
+
+MetadataVector CopyMetadataToVector(
+ LoadBalancingPolicy::MetadataInterface* metadata) {
+ MetadataVector result;
+ for (const auto& p : *metadata) {
+ result.push_back({TString(p.first), TString(p.second)});
+ }
+ return result;
+}
+
+//
+// TestPickArgsLb
+//
+
+constexpr char kTestPickArgsLbPolicyName[] = "test_pick_args_lb";
+
+class TestPickArgsLb : public ForwardingLoadBalancingPolicy {
+ public:
+ TestPickArgsLb(Args args, TestPickArgsCallback cb)
+ : ForwardingLoadBalancingPolicy(
+ y_absl::make_unique<Helper>(RefCountedPtr<TestPickArgsLb>(this), cb),
+ std::move(args),
+ /*delegate_lb_policy_name=*/"pick_first",
+ /*initial_refcount=*/2) {}
+
+ ~TestPickArgsLb() override = default;
+
+ const char* name() const override { return kTestPickArgsLbPolicyName; }
+
+ private:
+ class Picker : public SubchannelPicker {
+ public:
+ Picker(std::unique_ptr<SubchannelPicker> delegate_picker,
+ TestPickArgsCallback cb)
+ : delegate_picker_(std::move(delegate_picker)), cb_(std::move(cb)) {}
+
+ PickResult Pick(PickArgs args) override {
+ // Report args seen.
+ PickArgsSeen args_seen;
+ args_seen.path = TString(args.path);
+ args_seen.metadata = CopyMetadataToVector(args.initial_metadata);
+ cb_(args_seen);
+ // Do pick.
+ return delegate_picker_->Pick(args);
+ }
+
+ private:
+ std::unique_ptr<SubchannelPicker> delegate_picker_;
+ TestPickArgsCallback cb_;
+ };
+
+ class Helper : public ChannelControlHelper {
+ public:
+ Helper(RefCountedPtr<TestPickArgsLb> parent, TestPickArgsCallback cb)
+ : parent_(std::move(parent)), cb_(std::move(cb)) {}
+
+ RefCountedPtr<SubchannelInterface> CreateSubchannel(
+ ServerAddress address, const grpc_channel_args& args) override {
+ return parent_->channel_control_helper()->CreateSubchannel(
+ std::move(address), args);
+ }
+
+ void UpdateState(grpc_connectivity_state state, const y_absl::Status& status,
+ std::unique_ptr<SubchannelPicker> picker) override {
+ parent_->channel_control_helper()->UpdateState(
+ state, status, y_absl::make_unique<Picker>(std::move(picker), cb_));
+ }
+
+ void RequestReresolution() override {
+ parent_->channel_control_helper()->RequestReresolution();
+ }
+
+ void AddTraceEvent(TraceSeverity severity,
+ y_absl::string_view message) override {
+ parent_->channel_control_helper()->AddTraceEvent(severity, message);
+ }
+
+ private:
+ RefCountedPtr<TestPickArgsLb> parent_;
+ TestPickArgsCallback cb_;
+ };
+};
+
+class TestPickArgsLbConfig : public LoadBalancingPolicy::Config {
+ public:
+ const char* name() const override { return kTestPickArgsLbPolicyName; }
+};
+
+class TestPickArgsLbFactory : public LoadBalancingPolicyFactory {
+ public:
+ explicit TestPickArgsLbFactory(TestPickArgsCallback cb)
+ : cb_(std::move(cb)) {}
+
+ OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
+ LoadBalancingPolicy::Args args) const override {
+ return MakeOrphanable<TestPickArgsLb>(std::move(args), cb_);
+ }
+
+ const char* name() const override { return kTestPickArgsLbPolicyName; }
+
+ RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
+ const Json& /*json*/, grpc_error** /*error*/) const override {
+ return MakeRefCounted<TestPickArgsLbConfig>();
+ }
+
+ private:
+ TestPickArgsCallback cb_;
+};
+
+//
// InterceptRecvTrailingMetadataLoadBalancingPolicy
//
@@ -201,12 +201,12 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
: public ForwardingLoadBalancingPolicy {
public:
InterceptRecvTrailingMetadataLoadBalancingPolicy(
- Args args, InterceptRecvTrailingMetadataCallback cb)
+ Args args, InterceptRecvTrailingMetadataCallback cb)
: ForwardingLoadBalancingPolicy(
- y_absl::make_unique<Helper>(
+ y_absl::make_unique<Helper>(
RefCountedPtr<InterceptRecvTrailingMetadataLoadBalancingPolicy>(
this),
- std::move(cb)),
+ std::move(cb)),
std::move(args),
/*delegate_lb_policy_name=*/"pick_first",
/*initial_refcount=*/2) {}
@@ -220,9 +220,9 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
private:
class Picker : public SubchannelPicker {
public:
- Picker(std::unique_ptr<SubchannelPicker> delegate_picker,
- InterceptRecvTrailingMetadataCallback cb)
- : delegate_picker_(std::move(delegate_picker)), cb_(std::move(cb)) {}
+ Picker(std::unique_ptr<SubchannelPicker> delegate_picker,
+ InterceptRecvTrailingMetadataCallback cb)
+ : delegate_picker_(std::move(delegate_picker)), cb_(std::move(cb)) {}
PickResult Pick(PickArgs args) override {
// Do pick.
@@ -231,7 +231,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
if (result.type == PickResult::PICK_COMPLETE &&
result.subchannel != nullptr) {
new (args.call_state->Alloc(sizeof(TrailingMetadataHandler)))
- TrailingMetadataHandler(&result, cb_);
+ TrailingMetadataHandler(&result, cb_);
}
return result;
}
@@ -245,27 +245,27 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
public:
Helper(
RefCountedPtr<InterceptRecvTrailingMetadataLoadBalancingPolicy> parent,
- InterceptRecvTrailingMetadataCallback cb)
- : parent_(std::move(parent)), cb_(std::move(cb)) {}
+ InterceptRecvTrailingMetadataCallback cb)
+ : parent_(std::move(parent)), cb_(std::move(cb)) {}
RefCountedPtr<SubchannelInterface> CreateSubchannel(
- ServerAddress address, const grpc_channel_args& args) override {
- return parent_->channel_control_helper()->CreateSubchannel(
- std::move(address), args);
+ ServerAddress address, const grpc_channel_args& args) override {
+ return parent_->channel_control_helper()->CreateSubchannel(
+ std::move(address), args);
}
- void UpdateState(grpc_connectivity_state state, const y_absl::Status& status,
+ void UpdateState(grpc_connectivity_state state, const y_absl::Status& status,
std::unique_ptr<SubchannelPicker> picker) override {
parent_->channel_control_helper()->UpdateState(
- state, status, y_absl::make_unique<Picker>(std::move(picker), cb_));
+ state, status, y_absl::make_unique<Picker>(std::move(picker), cb_));
}
void RequestReresolution() override {
parent_->channel_control_helper()->RequestReresolution();
}
- void AddTraceEvent(TraceSeverity severity,
- y_absl::string_view message) override {
+ void AddTraceEvent(TraceSeverity severity,
+ y_absl::string_view message) override {
parent_->channel_control_helper()->AddTraceEvent(severity, message);
}
@@ -277,8 +277,8 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
class TrailingMetadataHandler {
public:
TrailingMetadataHandler(PickResult* result,
- InterceptRecvTrailingMetadataCallback cb)
- : cb_(std::move(cb)) {
+ InterceptRecvTrailingMetadataCallback cb)
+ : cb_(std::move(cb)) {
result->recv_trailing_metadata_ready = [this](grpc_error* error,
MetadataInterface* metadata,
CallState* call_state) {
@@ -290,11 +290,11 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
void RecordRecvTrailingMetadata(grpc_error* /*error*/,
MetadataInterface* recv_trailing_metadata,
CallState* call_state) {
- TrailingMetadataArgsSeen args_seen;
- args_seen.backend_metric_data = call_state->GetBackendMetricData();
+ TrailingMetadataArgsSeen args_seen;
+ args_seen.backend_metric_data = call_state->GetBackendMetricData();
GPR_ASSERT(recv_trailing_metadata != nullptr);
- args_seen.metadata = CopyMetadataToVector(recv_trailing_metadata);
- cb_(args_seen);
+ args_seen.metadata = CopyMetadataToVector(recv_trailing_metadata);
+ cb_(args_seen);
this->~TrailingMetadataHandler();
}
@@ -302,22 +302,22 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy
};
};
-class InterceptTrailingConfig : public LoadBalancingPolicy::Config {
- public:
- const char* name() const override {
- return kInterceptRecvTrailingMetadataLbPolicyName;
- }
-};
-
+class InterceptTrailingConfig : public LoadBalancingPolicy::Config {
+ public:
+ const char* name() const override {
+ return kInterceptRecvTrailingMetadataLbPolicyName;
+ }
+};
+
class InterceptTrailingFactory : public LoadBalancingPolicyFactory {
public:
- explicit InterceptTrailingFactory(InterceptRecvTrailingMetadataCallback cb)
- : cb_(std::move(cb)) {}
+ explicit InterceptTrailingFactory(InterceptRecvTrailingMetadataCallback cb)
+ : cb_(std::move(cb)) {}
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
LoadBalancingPolicy::Args args) const override {
return MakeOrphanable<InterceptRecvTrailingMetadataLoadBalancingPolicy>(
- std::move(args), cb_);
+ std::move(args), cb_);
}
const char* name() const override {
@@ -325,111 +325,111 @@ class InterceptTrailingFactory : public LoadBalancingPolicyFactory {
}
RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
- const Json& /*json*/, grpc_error** /*error*/) const override {
- return MakeRefCounted<InterceptTrailingConfig>();
+ const Json& /*json*/, grpc_error** /*error*/) const override {
+ return MakeRefCounted<InterceptTrailingConfig>();
}
private:
InterceptRecvTrailingMetadataCallback cb_;
};
-//
-// AddressTestLoadBalancingPolicy
-//
-
-constexpr char kAddressTestLbPolicyName[] = "address_test_lb";
-
-class AddressTestLoadBalancingPolicy : public ForwardingLoadBalancingPolicy {
- public:
- AddressTestLoadBalancingPolicy(Args args, AddressTestCallback cb)
- : ForwardingLoadBalancingPolicy(
- y_absl::make_unique<Helper>(
- RefCountedPtr<AddressTestLoadBalancingPolicy>(this),
- std::move(cb)),
- std::move(args),
- /*delegate_lb_policy_name=*/"pick_first",
- /*initial_refcount=*/2) {}
-
- ~AddressTestLoadBalancingPolicy() override = default;
-
- const char* name() const override { return kAddressTestLbPolicyName; }
-
- private:
- class Helper : public ChannelControlHelper {
- public:
- Helper(RefCountedPtr<AddressTestLoadBalancingPolicy> parent,
- AddressTestCallback cb)
- : parent_(std::move(parent)), cb_(std::move(cb)) {}
-
- RefCountedPtr<SubchannelInterface> CreateSubchannel(
- ServerAddress address, const grpc_channel_args& args) override {
- cb_(address);
- return parent_->channel_control_helper()->CreateSubchannel(
- std::move(address), args);
- }
-
- void UpdateState(grpc_connectivity_state state, const y_absl::Status& status,
- std::unique_ptr<SubchannelPicker> picker) override {
- parent_->channel_control_helper()->UpdateState(state, status,
- std::move(picker));
- }
-
- void RequestReresolution() override {
- parent_->channel_control_helper()->RequestReresolution();
- }
-
- void AddTraceEvent(TraceSeverity severity,
- y_absl::string_view message) override {
- parent_->channel_control_helper()->AddTraceEvent(severity, message);
- }
-
- private:
- RefCountedPtr<AddressTestLoadBalancingPolicy> parent_;
- AddressTestCallback cb_;
- };
-};
-
-class AddressTestConfig : public LoadBalancingPolicy::Config {
- public:
- const char* name() const override { return kAddressTestLbPolicyName; }
-};
-
-class AddressTestFactory : public LoadBalancingPolicyFactory {
- public:
- explicit AddressTestFactory(AddressTestCallback cb) : cb_(std::move(cb)) {}
-
- OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
- LoadBalancingPolicy::Args args) const override {
- return MakeOrphanable<AddressTestLoadBalancingPolicy>(std::move(args), cb_);
- }
-
- const char* name() const override { return kAddressTestLbPolicyName; }
-
- RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
- const Json& /*json*/, grpc_error** /*error*/) const override {
- return MakeRefCounted<AddressTestConfig>();
- }
-
- private:
- AddressTestCallback cb_;
-};
-
+//
+// AddressTestLoadBalancingPolicy
+//
+
+constexpr char kAddressTestLbPolicyName[] = "address_test_lb";
+
+class AddressTestLoadBalancingPolicy : public ForwardingLoadBalancingPolicy {
+ public:
+ AddressTestLoadBalancingPolicy(Args args, AddressTestCallback cb)
+ : ForwardingLoadBalancingPolicy(
+ y_absl::make_unique<Helper>(
+ RefCountedPtr<AddressTestLoadBalancingPolicy>(this),
+ std::move(cb)),
+ std::move(args),
+ /*delegate_lb_policy_name=*/"pick_first",
+ /*initial_refcount=*/2) {}
+
+ ~AddressTestLoadBalancingPolicy() override = default;
+
+ const char* name() const override { return kAddressTestLbPolicyName; }
+
+ private:
+ class Helper : public ChannelControlHelper {
+ public:
+ Helper(RefCountedPtr<AddressTestLoadBalancingPolicy> parent,
+ AddressTestCallback cb)
+ : parent_(std::move(parent)), cb_(std::move(cb)) {}
+
+ RefCountedPtr<SubchannelInterface> CreateSubchannel(
+ ServerAddress address, const grpc_channel_args& args) override {
+ cb_(address);
+ return parent_->channel_control_helper()->CreateSubchannel(
+ std::move(address), args);
+ }
+
+ void UpdateState(grpc_connectivity_state state, const y_absl::Status& status,
+ std::unique_ptr<SubchannelPicker> picker) override {
+ parent_->channel_control_helper()->UpdateState(state, status,
+ std::move(picker));
+ }
+
+ void RequestReresolution() override {
+ parent_->channel_control_helper()->RequestReresolution();
+ }
+
+ void AddTraceEvent(TraceSeverity severity,
+ y_absl::string_view message) override {
+ parent_->channel_control_helper()->AddTraceEvent(severity, message);
+ }
+
+ private:
+ RefCountedPtr<AddressTestLoadBalancingPolicy> parent_;
+ AddressTestCallback cb_;
+ };
+};
+
+class AddressTestConfig : public LoadBalancingPolicy::Config {
+ public:
+ const char* name() const override { return kAddressTestLbPolicyName; }
+};
+
+class AddressTestFactory : public LoadBalancingPolicyFactory {
+ public:
+ explicit AddressTestFactory(AddressTestCallback cb) : cb_(std::move(cb)) {}
+
+ OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
+ LoadBalancingPolicy::Args args) const override {
+ return MakeOrphanable<AddressTestLoadBalancingPolicy>(std::move(args), cb_);
+ }
+
+ const char* name() const override { return kAddressTestLbPolicyName; }
+
+ RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig(
+ const Json& /*json*/, grpc_error** /*error*/) const override {
+ return MakeRefCounted<AddressTestConfig>();
+ }
+
+ private:
+ AddressTestCallback cb_;
+};
+
} // namespace
-void RegisterTestPickArgsLoadBalancingPolicy(TestPickArgsCallback cb) {
- LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
- y_absl::make_unique<TestPickArgsLbFactory>(std::move(cb)));
-}
-
+void RegisterTestPickArgsLoadBalancingPolicy(TestPickArgsCallback cb) {
+ LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
+ y_absl::make_unique<TestPickArgsLbFactory>(std::move(cb)));
+}
+
void RegisterInterceptRecvTrailingMetadataLoadBalancingPolicy(
- InterceptRecvTrailingMetadataCallback cb) {
- LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
- y_absl::make_unique<InterceptTrailingFactory>(std::move(cb)));
-}
-
-void RegisterAddressTestLoadBalancingPolicy(AddressTestCallback cb) {
+ InterceptRecvTrailingMetadataCallback cb) {
LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
- y_absl::make_unique<AddressTestFactory>(std::move(cb)));
+ y_absl::make_unique<InterceptTrailingFactory>(std::move(cb)));
}
+void RegisterAddressTestLoadBalancingPolicy(AddressTestCallback cb) {
+ LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
+ y_absl::make_unique<AddressTestFactory>(std::move(cb)));
+}
+
} // namespace grpc_core
diff --git a/contrib/libs/grpc/test/core/util/test_lb_policies.h b/contrib/libs/grpc/test/core/util/test_lb_policies.h
index 9e14c707a3..4d4b405084 100644
--- a/contrib/libs/grpc/test/core/util/test_lb_policies.h
+++ b/contrib/libs/grpc/test/core/util/test_lb_policies.h
@@ -23,38 +23,38 @@
namespace grpc_core {
-using MetadataVector = std::vector<std::pair<TString, TString>>;
-
-struct PickArgsSeen {
- TString path;
- MetadataVector metadata;
-};
-
-using TestPickArgsCallback = std::function<void(const PickArgsSeen&)>;
-
-// Registers an LB policy called "test_pick_args_lb" that checks the args
-// passed to SubchannelPicker::Pick().
-void RegisterTestPickArgsLoadBalancingPolicy(TestPickArgsCallback cb);
-
-struct TrailingMetadataArgsSeen {
- const LoadBalancingPolicy::BackendMetricData* backend_metric_data;
- MetadataVector metadata;
-};
-
-using InterceptRecvTrailingMetadataCallback =
- std::function<void(const TrailingMetadataArgsSeen&)>;
-
+using MetadataVector = std::vector<std::pair<TString, TString>>;
+
+struct PickArgsSeen {
+ TString path;
+ MetadataVector metadata;
+};
+
+using TestPickArgsCallback = std::function<void(const PickArgsSeen&)>;
+
+// Registers an LB policy called "test_pick_args_lb" that checks the args
+// passed to SubchannelPicker::Pick().
+void RegisterTestPickArgsLoadBalancingPolicy(TestPickArgsCallback cb);
+
+struct TrailingMetadataArgsSeen {
+ const LoadBalancingPolicy::BackendMetricData* backend_metric_data;
+ MetadataVector metadata;
+};
+
+using InterceptRecvTrailingMetadataCallback =
+ std::function<void(const TrailingMetadataArgsSeen&)>;
+
// Registers an LB policy called "intercept_trailing_metadata_lb" that
-// invokes cb when trailing metadata is received for each call.
+// invokes cb when trailing metadata is received for each call.
void RegisterInterceptRecvTrailingMetadataLoadBalancingPolicy(
- InterceptRecvTrailingMetadataCallback cb);
-
-using AddressTestCallback = std::function<void(const ServerAddress&)>;
-
-// Registers an LB policy called "address_test_lb" that invokes cb for each
-// address used to create a subchannel.
-void RegisterAddressTestLoadBalancingPolicy(AddressTestCallback cb);
-
+ InterceptRecvTrailingMetadataCallback cb);
+
+using AddressTestCallback = std::function<void(const ServerAddress&)>;
+
+// Registers an LB policy called "address_test_lb" that invokes cb for each
+// address used to create a subchannel.
+void RegisterAddressTestLoadBalancingPolicy(AddressTestCallback cb);
+
} // namespace grpc_core
#endif // GRPC_TEST_CORE_UTIL_TEST_LB_POLICIES_H
diff --git a/contrib/libs/grpc/test/core/util/test_tcp_server.cc b/contrib/libs/grpc/test/core/util/test_tcp_server.cc
index 9dd1e2af36..7d6e1f47c3 100644
--- a/contrib/libs/grpc/test/core/util/test_tcp_server.cc
+++ b/contrib/libs/grpc/test/core/util/test_tcp_server.cc
@@ -36,7 +36,7 @@
static void on_server_destroyed(void* data, grpc_error* /*error*/) {
test_tcp_server* server = static_cast<test_tcp_server*>(data);
- server->shutdown = true;
+ server->shutdown = true;
}
void test_tcp_server_init(test_tcp_server* server,
@@ -44,11 +44,11 @@ void test_tcp_server_init(test_tcp_server* server,
grpc_init();
GRPC_CLOSURE_INIT(&server->shutdown_complete, on_server_destroyed, server,
grpc_schedule_on_exec_ctx);
-
- grpc_pollset* pollset =
- static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
- grpc_pollset_init(pollset, &server->mu);
- server->pollset.push_back(pollset);
+
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
+ grpc_pollset_init(pollset, &server->mu);
+ server->pollset.push_back(pollset);
server->on_connect = on_connect;
server->cb_data = user_data;
}
@@ -72,7 +72,7 @@ void test_tcp_server_start(test_tcp_server* server, int port) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(port_added == port);
- grpc_tcp_server_start(server->tcp_server, &server->pollset,
+ grpc_tcp_server_start(server->tcp_server, &server->pollset,
server->on_connect, server->cb_data);
gpr_log(GPR_INFO, "test tcp server listening on 0.0.0.0:%d", port);
}
@@ -84,7 +84,7 @@ void test_tcp_server_poll(test_tcp_server* server, int milliseconds) {
grpc_timeout_milliseconds_to_deadline(milliseconds));
gpr_mu_lock(server->mu);
GRPC_LOG_IF_ERROR("pollset_work",
- grpc_pollset_work(server->pollset[0], &worker, deadline));
+ grpc_pollset_work(server->pollset[0], &worker, deadline));
gpr_mu_unlock(server->mu);
}
@@ -107,10 +107,10 @@ void test_tcp_server_destroy(test_tcp_server* server) {
gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) {
test_tcp_server_poll(server, 1000);
}
- grpc_pollset_shutdown(server->pollset[0],
- GRPC_CLOSURE_CREATE(finish_pollset, server->pollset[0],
+ grpc_pollset_shutdown(server->pollset[0],
+ GRPC_CLOSURE_CREATE(finish_pollset, server->pollset[0],
grpc_schedule_on_exec_ctx));
grpc_core::ExecCtx::Get()->Flush();
- gpr_free(server->pollset[0]);
+ gpr_free(server->pollset[0]);
grpc_shutdown();
}
diff --git a/contrib/libs/grpc/test/core/util/test_tcp_server.h b/contrib/libs/grpc/test/core/util/test_tcp_server.h
index 8765ea9a22..e45fd2f16d 100644
--- a/contrib/libs/grpc/test/core/util/test_tcp_server.h
+++ b/contrib/libs/grpc/test/core/util/test_tcp_server.h
@@ -19,24 +19,24 @@
#ifndef GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H
#define GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H
-#include <vector>
-
+#include <vector>
+
#include <grpc/support/sync.h>
#include "src/core/lib/iomgr/tcp_server.h"
-// test_tcp_server should be stack-allocated or new'ed, never gpr_malloc'ed
-// since it contains C++ objects.
-struct test_tcp_server {
- grpc_tcp_server* tcp_server = nullptr;
+// test_tcp_server should be stack-allocated or new'ed, never gpr_malloc'ed
+// since it contains C++ objects.
+struct test_tcp_server {
+ grpc_tcp_server* tcp_server = nullptr;
grpc_closure shutdown_complete;
- bool shutdown = false;
- // mu is filled in by grpc_pollset_init and controls the pollset.
- // TODO: Switch this to a Mutex once pollset_init can provide a Mutex
+ bool shutdown = false;
+ // mu is filled in by grpc_pollset_init and controls the pollset.
+ // TODO: Switch this to a Mutex once pollset_init can provide a Mutex
gpr_mu* mu;
- std::vector<grpc_pollset*> pollset;
+ std::vector<grpc_pollset*> pollset;
grpc_tcp_server_cb on_connect;
void* cb_data;
-};
+};
void test_tcp_server_init(test_tcp_server* server,
grpc_tcp_server_cb on_connect, void* user_data);
diff --git a/contrib/libs/grpc/test/core/util/trickle_endpoint.cc b/contrib/libs/grpc/test/core/util/trickle_endpoint.cc
index 28ffb0e3e7..b02f671220 100644
--- a/contrib/libs/grpc/test/core/util/trickle_endpoint.cc
+++ b/contrib/libs/grpc/test/core/util/trickle_endpoint.cc
@@ -122,16 +122,16 @@ static grpc_resource_user* te_get_resource_user(grpc_endpoint* ep) {
return grpc_endpoint_get_resource_user(te->wrapped);
}
-static y_absl::string_view te_get_peer(grpc_endpoint* ep) {
+static y_absl::string_view te_get_peer(grpc_endpoint* ep) {
trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_peer(te->wrapped);
}
-static y_absl::string_view te_get_local_address(grpc_endpoint* ep) {
- trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
- return grpc_endpoint_get_local_address(te->wrapped);
-}
-
+static y_absl::string_view te_get_local_address(grpc_endpoint* ep) {
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
+ return grpc_endpoint_get_local_address(te->wrapped);
+}
+
static int te_get_fd(grpc_endpoint* ep) {
trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_fd(te->wrapped);
@@ -156,7 +156,7 @@ static const grpc_endpoint_vtable vtable = {te_read,
te_destroy,
te_get_resource_user,
te_get_peer,
- te_get_local_address,
+ te_get_local_address,
te_get_fd,
te_can_track_err};
diff --git a/contrib/libs/grpc/test/core/util/ubsan_suppressions.txt b/contrib/libs/grpc/test/core/util/ubsan_suppressions.txt
index ca233b8a28..863ce9297f 100644
--- a/contrib/libs/grpc/test/core/util/ubsan_suppressions.txt
+++ b/contrib/libs/grpc/test/core/util/ubsan_suppressions.txt
@@ -14,8 +14,8 @@ nonnull-attribute:gsec_test_random_encrypt_decrypt
nonnull-attribute:gsec_test_multiple_random_encrypt_decrypt
nonnull-attribute:gsec_test_copy
nonnull-attribute:gsec_test_encrypt_decrypt_test_vector
-alignment:y_absl::little_endian::Store64
-alignment:y_absl::little_endian::Load64
+alignment:y_absl::little_endian::Store64
+alignment:y_absl::little_endian::Load64
float-divide-by-zero:grpc::testing::postprocess_scenario_result
enum:grpc_op_string
signed-integer-overflow:chrono
diff --git a/contrib/libs/grpc/test/core/util/ya.make b/contrib/libs/grpc/test/core/util/ya.make
index fbaad80cad..93c48e528a 100644
--- a/contrib/libs/grpc/test/core/util/ya.make
+++ b/contrib/libs/grpc/test/core/util/ya.make
@@ -2,19 +2,19 @@ LIBRARY()
LICENSE(Apache-2.0)
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-OWNER(dvshkurko)
+LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
+OWNER(dvshkurko)
+
PEERDIR(
contrib/libs/grpc
- contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler
+ contrib/restricted/abseil-cpp-tstring/y_absl/debugging/failure_signal_handler
)
-ADDINCL(
- ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc
- contrib/libs/grpc
-)
+ADDINCL(
+ ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc
+ contrib/libs/grpc
+)
NO_COMPILER_WARNINGS()