diff options
Diffstat (limited to 'test')
262 files changed, 7812 insertions, 5912 deletions
diff --git a/test/core/avl/BUILD b/test/core/avl/BUILD new file mode 100644 index 0000000000..48f5baeb1a --- /dev/null +++ b/test/core/avl/BUILD @@ -0,0 +1,30 @@ +# Copyright 2018 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. + +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary", "grpc_package") + +licenses(["notice"]) # Apache v2 + +grpc_package(name = "test/core/avl") + +grpc_cc_test( + name = "avl_test", + srcs = ["avl_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:gpr_test_util", + ], +) diff --git a/test/core/avl/avl_test.cc b/test/core/avl/avl_test.cc new file mode 100644 index 0000000000..ac1ab5c8e9 --- /dev/null +++ b/test/core/avl/avl_test.cc @@ -0,0 +1,3659 @@ +/* + * + * Copyright 2015 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 "src/core/lib/avl/avl.h" + +#include <stdio.h> +#include <string.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> + +#include "src/core/lib/gpr/useful.h" +#include "test/core/util/test_config.h" + +static int* box(int x) { + int* b = static_cast<int*>(gpr_malloc(sizeof(*b))); + *b = x; + return b; +} + +static long int_compare(void* int1, void* int2, void* unused) { + return (*(int*)int1) - (*(int*)int2); +} +static void* int_copy(void* p, void* unused) { return box(*(int*)p); } + +static void destroy(void* p, void* unused) { gpr_free(p); } + +static const grpc_avl_vtable int_int_vtable = {destroy, int_copy, int_compare, + destroy, int_copy}; + +static void check_get(grpc_avl avl, int key, int value) { + int* k = box(key); + GPR_ASSERT(*(int*)grpc_avl_get(avl, k, nullptr) == value); + gpr_free(k); +} + +static void check_negget(grpc_avl avl, int key) { + int* k = box(key); + GPR_ASSERT(grpc_avl_get(avl, k, nullptr) == nullptr); + gpr_free(k); +} + +static grpc_avl remove_int(grpc_avl avl, int key) { + int* k = box(key); + avl = grpc_avl_remove(avl, k, nullptr); + gpr_free(k); + return avl; +} + +static void test_get(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_get"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(1), box(11), nullptr); + avl = grpc_avl_add(avl, box(2), box(22), nullptr); + avl = grpc_avl_add(avl, box(3), box(33), nullptr); + check_get(avl, 1, 11); + check_get(avl, 2, 22); + check_get(avl, 3, 33); + check_negget(avl, 4); + grpc_avl_unref(avl, nullptr); +} + +static void test_ll(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_ll"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(5), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(3), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_lr(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_lr"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(5), box(1), nullptr); + avl = grpc_avl_add(avl, box(3), box(2), nullptr); + avl = grpc_avl_add(avl, box(4), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_rr(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_rr"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(3), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(5), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_rl(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_rl"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(3), box(1), nullptr); + avl = grpc_avl_add(avl, box(5), box(2), nullptr); + avl = grpc_avl_add(avl, box(4), box(3), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_unbalanced(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_unbalanced"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(5), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(3), box(3), nullptr); + avl = grpc_avl_add(avl, box(2), box(4), nullptr); + avl = grpc_avl_add(avl, box(1), box(5), nullptr); + GPR_ASSERT(*(int*)avl.root->key == 4); + GPR_ASSERT(*(int*)avl.root->left->key == 2); + GPR_ASSERT(*(int*)avl.root->left->left->key == 1); + GPR_ASSERT(*(int*)avl.root->left->right->key == 3); + GPR_ASSERT(*(int*)avl.root->right->key == 5); + grpc_avl_unref(avl, nullptr); +} + +static void test_replace(void) { + grpc_avl avl; + gpr_log(GPR_DEBUG, "test_replace"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(1), box(1), nullptr); + avl = grpc_avl_add(avl, box(1), box(2), nullptr); + check_get(avl, 1, 2); + check_negget(avl, 2); + grpc_avl_unref(avl, nullptr); +} + +static void test_remove(void) { + grpc_avl avl; + grpc_avl avl3, avl4, avl5, avln; + gpr_log(GPR_DEBUG, "test_remove"); + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(3), box(1), nullptr); + avl = grpc_avl_add(avl, box(4), box(2), nullptr); + avl = grpc_avl_add(avl, box(5), box(3), nullptr); + + avl3 = remove_int(grpc_avl_ref(avl, nullptr), 3); + avl4 = remove_int(grpc_avl_ref(avl, nullptr), 4); + avl5 = remove_int(grpc_avl_ref(avl, nullptr), 5); + avln = remove_int(grpc_avl_ref(avl, nullptr), 1); + + grpc_avl_unref(avl, nullptr); + + check_negget(avl3, 3); + check_get(avl3, 4, 2); + check_get(avl3, 5, 3); + grpc_avl_unref(avl3, nullptr); + + check_get(avl4, 3, 1); + check_negget(avl4, 4); + check_get(avl4, 5, 3); + grpc_avl_unref(avl4, nullptr); + + check_get(avl5, 3, 1); + check_get(avl5, 4, 2); + check_negget(avl5, 5); + grpc_avl_unref(avl5, nullptr); + + check_get(avln, 3, 1); + check_get(avln, 4, 2); + check_get(avln, 5, 3); + grpc_avl_unref(avln, nullptr); +} + +static void test_badcase1(void) { + grpc_avl avl; + + gpr_log(GPR_DEBUG, "test_badcase1"); + + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(88), box(1), nullptr); + avl = remove_int(avl, 643); + avl = remove_int(avl, 983); + avl = grpc_avl_add(avl, box(985), box(4), nullptr); + avl = grpc_avl_add(avl, box(640), box(5), nullptr); + avl = grpc_avl_add(avl, box(41), box(6), nullptr); + avl = grpc_avl_add(avl, box(112), box(7), nullptr); + avl = grpc_avl_add(avl, box(342), box(8), nullptr); + avl = remove_int(avl, 1013); + avl = grpc_avl_add(avl, box(434), box(10), nullptr); + avl = grpc_avl_add(avl, box(520), box(11), nullptr); + avl = grpc_avl_add(avl, box(231), box(12), nullptr); + avl = grpc_avl_add(avl, box(852), box(13), nullptr); + avl = remove_int(avl, 461); + avl = grpc_avl_add(avl, box(108), box(15), nullptr); + avl = grpc_avl_add(avl, box(806), box(16), nullptr); + avl = grpc_avl_add(avl, box(827), box(17), nullptr); + avl = remove_int(avl, 796); + avl = grpc_avl_add(avl, box(340), box(19), nullptr); + avl = grpc_avl_add(avl, box(498), box(20), nullptr); + avl = grpc_avl_add(avl, box(203), box(21), nullptr); + avl = grpc_avl_add(avl, box(751), box(22), nullptr); + avl = grpc_avl_add(avl, box(150), box(23), nullptr); + avl = remove_int(avl, 237); + avl = grpc_avl_add(avl, box(830), box(25), nullptr); + avl = remove_int(avl, 1007); + avl = remove_int(avl, 394); + avl = grpc_avl_add(avl, box(65), box(28), nullptr); + avl = remove_int(avl, 904); + avl = remove_int(avl, 123); + avl = grpc_avl_add(avl, box(238), box(31), nullptr); + avl = grpc_avl_add(avl, box(184), box(32), nullptr); + avl = remove_int(avl, 331); + avl = grpc_avl_add(avl, box(827), box(34), nullptr); + + check_get(avl, 830, 25); + + grpc_avl_unref(avl, nullptr); +} + +static void test_badcase2(void) { + grpc_avl avl; + + gpr_log(GPR_DEBUG, "test_badcase2"); + + avl = grpc_avl_create(&int_int_vtable); + avl = grpc_avl_add(avl, box(288), box(1), nullptr); + avl = remove_int(avl, 415); + avl = grpc_avl_add(avl, box(953), box(3), nullptr); + avl = grpc_avl_add(avl, box(101), box(4), nullptr); + avl = grpc_avl_add(avl, box(516), box(5), nullptr); + avl = grpc_avl_add(avl, box(547), box(6), nullptr); + avl = grpc_avl_add(avl, box(467), box(7), nullptr); + avl = grpc_avl_add(avl, box(793), box(8), nullptr); + avl = remove_int(avl, 190); + avl = grpc_avl_add(avl, box(687), box(10), nullptr); + avl = grpc_avl_add(avl, box(242), box(11), nullptr); + avl = grpc_avl_add(avl, box(142), box(12), nullptr); + avl = remove_int(avl, 705); + avl = remove_int(avl, 578); + avl = remove_int(avl, 767); + avl = remove_int(avl, 183); + avl = grpc_avl_add(avl, box(950), box(17), nullptr); + avl = grpc_avl_add(avl, box(622), box(18), nullptr); + avl = remove_int(avl, 513); + avl = remove_int(avl, 429); + avl = grpc_avl_add(avl, box(205), box(21), nullptr); + avl = remove_int(avl, 663); + avl = remove_int(avl, 953); + avl = remove_int(avl, 892); + avl = grpc_avl_add(avl, box(236), box(25), nullptr); + avl = remove_int(avl, 982); + avl = remove_int(avl, 201); + avl = remove_int(avl, 684); + avl = grpc_avl_add(avl, box(572), box(29), nullptr); + avl = remove_int(avl, 817); + avl = grpc_avl_add(avl, box(970), box(31), nullptr); + avl = remove_int(avl, 347); + avl = remove_int(avl, 574); + avl = grpc_avl_add(avl, box(752), box(34), nullptr); + avl = grpc_avl_add(avl, box(670), box(35), nullptr); + avl = grpc_avl_add(avl, box(69), box(36), nullptr); + avl = remove_int(avl, 111); + avl = remove_int(avl, 523); + avl = grpc_avl_add(avl, box(141), box(39), nullptr); + avl = remove_int(avl, 159); + avl = grpc_avl_add(avl, box(947), box(41), nullptr); + avl = grpc_avl_add(avl, box(855), box(42), nullptr); + avl = remove_int(avl, 218); + avl = remove_int(avl, 6); + avl = grpc_avl_add(avl, box(753), box(45), nullptr); + avl = remove_int(avl, 82); + avl = remove_int(avl, 799); + avl = grpc_avl_add(avl, box(572), box(48), nullptr); + avl = remove_int(avl, 376); + avl = remove_int(avl, 413); + avl = grpc_avl_add(avl, box(458), box(51), nullptr); + avl = remove_int(avl, 897); + avl = grpc_avl_add(avl, box(191), box(53), nullptr); + avl = grpc_avl_add(avl, box(609), box(54), nullptr); + avl = remove_int(avl, 787); + avl = remove_int(avl, 710); + avl = remove_int(avl, 886); + avl = remove_int(avl, 835); + avl = remove_int(avl, 33); + avl = grpc_avl_add(avl, box(871), box(60), nullptr); + avl = remove_int(avl, 641); + avl = grpc_avl_add(avl, box(462), box(62), nullptr); + avl = remove_int(avl, 359); + avl = remove_int(avl, 767); + avl = grpc_avl_add(avl, box(310), box(65), nullptr); + avl = remove_int(avl, 757); + avl = remove_int(avl, 639); + avl = remove_int(avl, 314); + avl = grpc_avl_add(avl, box(2), box(69), nullptr); + avl = remove_int(avl, 138); + avl = grpc_avl_add(avl, box(669), box(71), nullptr); + avl = remove_int(avl, 477); + avl = grpc_avl_add(avl, box(366), box(73), nullptr); + avl = grpc_avl_add(avl, box(612), box(74), nullptr); + avl = grpc_avl_add(avl, box(106), box(75), nullptr); + avl = remove_int(avl, 161); + avl = grpc_avl_add(avl, box(388), box(77), nullptr); + avl = grpc_avl_add(avl, box(141), box(78), nullptr); + avl = remove_int(avl, 633); + avl = remove_int(avl, 459); + avl = grpc_avl_add(avl, box(40), box(81), nullptr); + avl = remove_int(avl, 689); + avl = grpc_avl_add(avl, box(823), box(83), nullptr); + avl = remove_int(avl, 485); + avl = grpc_avl_add(avl, box(903), box(85), nullptr); + avl = grpc_avl_add(avl, box(592), box(86), nullptr); + avl = remove_int(avl, 448); + avl = grpc_avl_add(avl, box(56), box(88), nullptr); + avl = remove_int(avl, 333); + avl = grpc_avl_add(avl, box(189), box(90), nullptr); + avl = grpc_avl_add(avl, box(103), box(91), nullptr); + avl = remove_int(avl, 164); + avl = remove_int(avl, 974); + avl = grpc_avl_add(avl, box(215), box(94), nullptr); + avl = remove_int(avl, 189); + avl = remove_int(avl, 504); + avl = grpc_avl_add(avl, box(868), box(97), nullptr); + avl = remove_int(avl, 909); + avl = remove_int(avl, 148); + avl = remove_int(avl, 469); + avl = grpc_avl_add(avl, box(994), box(101), nullptr); + avl = grpc_avl_add(avl, box(576), box(102), nullptr); + avl = remove_int(avl, 82); + avl = remove_int(avl, 209); + avl = grpc_avl_add(avl, box(276), box(105), nullptr); + avl = remove_int(avl, 856); + avl = grpc_avl_add(avl, box(750), box(107), nullptr); + avl = remove_int(avl, 871); + avl = grpc_avl_add(avl, box(301), box(109), nullptr); + avl = remove_int(avl, 260); + avl = remove_int(avl, 737); + avl = remove_int(avl, 719); + avl = grpc_avl_add(avl, box(933), box(113), nullptr); + avl = grpc_avl_add(avl, box(225), box(114), nullptr); + avl = grpc_avl_add(avl, box(975), box(115), nullptr); + avl = grpc_avl_add(avl, box(86), box(116), nullptr); + avl = remove_int(avl, 732); + avl = grpc_avl_add(avl, box(340), box(118), nullptr); + avl = grpc_avl_add(avl, box(271), box(119), nullptr); + avl = remove_int(avl, 206); + avl = grpc_avl_add(avl, box(949), box(121), nullptr); + avl = grpc_avl_add(avl, box(927), box(122), nullptr); + avl = grpc_avl_add(avl, box(34), box(123), nullptr); + avl = grpc_avl_add(avl, box(351), box(124), nullptr); + avl = remove_int(avl, 836); + avl = grpc_avl_add(avl, box(825), box(126), nullptr); + avl = grpc_avl_add(avl, box(352), box(127), nullptr); + avl = remove_int(avl, 107); + avl = remove_int(avl, 101); + avl = grpc_avl_add(avl, box(320), box(130), nullptr); + avl = grpc_avl_add(avl, box(3), box(131), nullptr); + avl = remove_int(avl, 998); + avl = remove_int(avl, 44); + avl = grpc_avl_add(avl, box(525), box(134), nullptr); + avl = grpc_avl_add(avl, box(864), box(135), nullptr); + avl = grpc_avl_add(avl, box(863), box(136), nullptr); + avl = remove_int(avl, 770); + avl = grpc_avl_add(avl, box(440), box(138), nullptr); + avl = remove_int(avl, 516); + avl = grpc_avl_add(avl, box(116), box(140), nullptr); + avl = remove_int(avl, 380); + avl = grpc_avl_add(avl, box(878), box(142), nullptr); + avl = remove_int(avl, 439); + avl = grpc_avl_add(avl, box(994), box(144), nullptr); + avl = remove_int(avl, 294); + avl = remove_int(avl, 593); + avl = grpc_avl_add(avl, box(696), box(147), nullptr); + avl = remove_int(avl, 8); + avl = grpc_avl_add(avl, box(881), box(149), nullptr); + avl = remove_int(avl, 32); + avl = remove_int(avl, 242); + avl = grpc_avl_add(avl, box(487), box(152), nullptr); + avl = grpc_avl_add(avl, box(637), box(153), nullptr); + avl = grpc_avl_add(avl, box(793), box(154), nullptr); + avl = grpc_avl_add(avl, box(696), box(155), nullptr); + avl = remove_int(avl, 458); + avl = grpc_avl_add(avl, box(828), box(157), nullptr); + avl = remove_int(avl, 784); + avl = remove_int(avl, 274); + avl = grpc_avl_add(avl, box(783), box(160), nullptr); + avl = remove_int(avl, 21); + avl = grpc_avl_add(avl, box(866), box(162), nullptr); + avl = remove_int(avl, 919); + avl = grpc_avl_add(avl, box(435), box(164), nullptr); + avl = remove_int(avl, 385); + avl = grpc_avl_add(avl, box(475), box(166), nullptr); + avl = remove_int(avl, 339); + avl = grpc_avl_add(avl, box(615), box(168), nullptr); + avl = remove_int(avl, 866); + avl = remove_int(avl, 82); + avl = remove_int(avl, 271); + avl = grpc_avl_add(avl, box(590), box(172), nullptr); + avl = grpc_avl_add(avl, box(852), box(173), nullptr); + avl = remove_int(avl, 318); + avl = remove_int(avl, 82); + avl = grpc_avl_add(avl, box(672), box(176), nullptr); + avl = remove_int(avl, 430); + avl = grpc_avl_add(avl, box(821), box(178), nullptr); + avl = grpc_avl_add(avl, box(365), box(179), nullptr); + avl = remove_int(avl, 78); + avl = grpc_avl_add(avl, box(700), box(181), nullptr); + avl = grpc_avl_add(avl, box(353), box(182), nullptr); + avl = remove_int(avl, 492); + avl = grpc_avl_add(avl, box(991), box(184), nullptr); + avl = remove_int(avl, 330); + avl = grpc_avl_add(avl, box(873), box(186), nullptr); + avl = remove_int(avl, 589); + avl = grpc_avl_add(avl, box(676), box(188), nullptr); + avl = grpc_avl_add(avl, box(790), box(189), nullptr); + avl = remove_int(avl, 521); + avl = remove_int(avl, 47); + avl = grpc_avl_add(avl, box(976), box(192), nullptr); + avl = grpc_avl_add(avl, box(683), box(193), nullptr); + avl = remove_int(avl, 803); + avl = remove_int(avl, 1006); + avl = grpc_avl_add(avl, box(775), box(196), nullptr); + avl = grpc_avl_add(avl, box(411), box(197), nullptr); + avl = grpc_avl_add(avl, box(697), box(198), nullptr); + avl = remove_int(avl, 50); + avl = grpc_avl_add(avl, box(213), box(200), nullptr); + avl = remove_int(avl, 714); + avl = grpc_avl_add(avl, box(981), box(202), nullptr); + avl = grpc_avl_add(avl, box(502), box(203), nullptr); + avl = grpc_avl_add(avl, box(697), box(204), nullptr); + avl = grpc_avl_add(avl, box(603), box(205), nullptr); + avl = grpc_avl_add(avl, box(117), box(206), nullptr); + avl = remove_int(avl, 363); + avl = grpc_avl_add(avl, box(104), box(208), nullptr); + avl = remove_int(avl, 842); + avl = grpc_avl_add(avl, box(48), box(210), nullptr); + avl = remove_int(avl, 764); + avl = grpc_avl_add(avl, box(482), box(212), nullptr); + avl = grpc_avl_add(avl, box(928), box(213), nullptr); + avl = grpc_avl_add(avl, box(30), box(214), nullptr); + avl = grpc_avl_add(avl, box(820), box(215), nullptr); + avl = grpc_avl_add(avl, box(334), box(216), nullptr); + avl = remove_int(avl, 306); + avl = grpc_avl_add(avl, box(789), box(218), nullptr); + avl = remove_int(avl, 924); + avl = grpc_avl_add(avl, box(53), box(220), nullptr); + avl = remove_int(avl, 657); + avl = grpc_avl_add(avl, box(130), box(222), nullptr); + avl = grpc_avl_add(avl, box(239), box(223), nullptr); + avl = remove_int(avl, 20); + avl = grpc_avl_add(avl, box(117), box(225), nullptr); + avl = remove_int(avl, 882); + avl = remove_int(avl, 891); + avl = grpc_avl_add(avl, box(9), box(228), nullptr); + avl = grpc_avl_add(avl, box(496), box(229), nullptr); + avl = grpc_avl_add(avl, box(750), box(230), nullptr); + avl = grpc_avl_add(avl, box(283), box(231), nullptr); + avl = grpc_avl_add(avl, box(802), box(232), nullptr); + avl = remove_int(avl, 352); + avl = grpc_avl_add(avl, box(374), box(234), nullptr); + avl = grpc_avl_add(avl, box(6), box(235), nullptr); + avl = grpc_avl_add(avl, box(756), box(236), nullptr); + avl = grpc_avl_add(avl, box(597), box(237), nullptr); + avl = grpc_avl_add(avl, box(661), box(238), nullptr); + avl = remove_int(avl, 96); + avl = grpc_avl_add(avl, box(894), box(240), nullptr); + avl = remove_int(avl, 749); + avl = grpc_avl_add(avl, box(71), box(242), nullptr); + avl = remove_int(avl, 68); + avl = grpc_avl_add(avl, box(388), box(244), nullptr); + avl = remove_int(avl, 119); + avl = remove_int(avl, 856); + avl = grpc_avl_add(avl, box(176), box(247), nullptr); + avl = grpc_avl_add(avl, box(993), box(248), nullptr); + avl = remove_int(avl, 178); + avl = remove_int(avl, 781); + avl = remove_int(avl, 771); + avl = remove_int(avl, 848); + avl = remove_int(avl, 376); + avl = remove_int(avl, 157); + avl = remove_int(avl, 142); + avl = remove_int(avl, 686); + avl = grpc_avl_add(avl, box(779), box(257), nullptr); + avl = grpc_avl_add(avl, box(484), box(258), nullptr); + avl = remove_int(avl, 837); + avl = grpc_avl_add(avl, box(388), box(260), nullptr); + avl = remove_int(avl, 987); + avl = grpc_avl_add(avl, box(336), box(262), nullptr); + avl = remove_int(avl, 855); + avl = grpc_avl_add(avl, box(668), box(264), nullptr); + avl = remove_int(avl, 648); + avl = grpc_avl_add(avl, box(193), box(266), nullptr); + avl = remove_int(avl, 939); + avl = grpc_avl_add(avl, box(740), box(268), nullptr); + avl = grpc_avl_add(avl, box(503), box(269), nullptr); + avl = grpc_avl_add(avl, box(765), box(270), nullptr); + avl = remove_int(avl, 924); + avl = remove_int(avl, 513); + avl = grpc_avl_add(avl, box(161), box(273), nullptr); + avl = grpc_avl_add(avl, box(502), box(274), nullptr); + avl = grpc_avl_add(avl, box(846), box(275), nullptr); + avl = remove_int(avl, 931); + avl = grpc_avl_add(avl, box(87), box(277), nullptr); + avl = grpc_avl_add(avl, box(949), box(278), nullptr); + avl = grpc_avl_add(avl, box(548), box(279), nullptr); + avl = grpc_avl_add(avl, box(951), box(280), nullptr); + avl = remove_int(avl, 1018); + avl = remove_int(avl, 568); + avl = grpc_avl_add(avl, box(138), box(283), nullptr); + avl = grpc_avl_add(avl, box(202), box(284), nullptr); + avl = grpc_avl_add(avl, box(157), box(285), nullptr); + avl = grpc_avl_add(avl, box(264), box(286), nullptr); + avl = grpc_avl_add(avl, box(370), box(287), nullptr); + avl = remove_int(avl, 736); + avl = remove_int(avl, 751); + avl = remove_int(avl, 506); + avl = remove_int(avl, 81); + avl = remove_int(avl, 358); + avl = remove_int(avl, 657); + avl = remove_int(avl, 86); + avl = grpc_avl_add(avl, box(876), box(295), nullptr); + avl = remove_int(avl, 354); + avl = grpc_avl_add(avl, box(134), box(297), nullptr); + avl = remove_int(avl, 781); + avl = remove_int(avl, 183); + avl = grpc_avl_add(avl, box(914), box(300), nullptr); + avl = remove_int(avl, 926); + avl = remove_int(avl, 398); + avl = remove_int(avl, 932); + avl = remove_int(avl, 804); + avl = remove_int(avl, 326); + avl = grpc_avl_add(avl, box(208), box(306), nullptr); + avl = grpc_avl_add(avl, box(699), box(307), nullptr); + avl = remove_int(avl, 576); + avl = remove_int(avl, 850); + avl = remove_int(avl, 514); + avl = remove_int(avl, 676); + avl = remove_int(avl, 549); + avl = remove_int(avl, 767); + avl = grpc_avl_add(avl, box(58), box(314), nullptr); + avl = grpc_avl_add(avl, box(265), box(315), nullptr); + avl = grpc_avl_add(avl, box(268), box(316), nullptr); + avl = grpc_avl_add(avl, box(103), box(317), nullptr); + avl = grpc_avl_add(avl, box(440), box(318), nullptr); + avl = remove_int(avl, 777); + avl = grpc_avl_add(avl, box(670), box(320), nullptr); + avl = remove_int(avl, 506); + avl = remove_int(avl, 487); + avl = grpc_avl_add(avl, box(421), box(323), nullptr); + avl = remove_int(avl, 514); + avl = grpc_avl_add(avl, box(701), box(325), nullptr); + avl = remove_int(avl, 949); + avl = remove_int(avl, 872); + avl = remove_int(avl, 139); + avl = grpc_avl_add(avl, box(781), box(329), nullptr); + avl = grpc_avl_add(avl, box(543), box(330), nullptr); + avl = grpc_avl_add(avl, box(147), box(331), nullptr); + avl = remove_int(avl, 190); + avl = grpc_avl_add(avl, box(453), box(333), nullptr); + avl = remove_int(avl, 262); + avl = remove_int(avl, 850); + avl = remove_int(avl, 286); + avl = remove_int(avl, 787); + avl = grpc_avl_add(avl, box(514), box(338), nullptr); + avl = remove_int(avl, 812); + avl = grpc_avl_add(avl, box(431), box(340), nullptr); + avl = grpc_avl_add(avl, box(8), box(341), nullptr); + avl = remove_int(avl, 843); + avl = grpc_avl_add(avl, box(831), box(343), nullptr); + avl = remove_int(avl, 472); + avl = remove_int(avl, 157); + avl = grpc_avl_add(avl, box(612), box(346), nullptr); + avl = grpc_avl_add(avl, box(802), box(347), nullptr); + avl = remove_int(avl, 554); + avl = grpc_avl_add(avl, box(409), box(349), nullptr); + avl = grpc_avl_add(avl, box(439), box(350), nullptr); + avl = grpc_avl_add(avl, box(725), box(351), nullptr); + avl = grpc_avl_add(avl, box(568), box(352), nullptr); + avl = remove_int(avl, 475); + avl = remove_int(avl, 672); + avl = remove_int(avl, 62); + avl = remove_int(avl, 753); + avl = grpc_avl_add(avl, box(435), box(357), nullptr); + avl = grpc_avl_add(avl, box(950), box(358), nullptr); + avl = grpc_avl_add(avl, box(532), box(359), nullptr); + avl = grpc_avl_add(avl, box(832), box(360), nullptr); + avl = remove_int(avl, 390); + avl = grpc_avl_add(avl, box(993), box(362), nullptr); + avl = remove_int(avl, 198); + avl = remove_int(avl, 401); + avl = grpc_avl_add(avl, box(316), box(365), nullptr); + avl = remove_int(avl, 843); + avl = grpc_avl_add(avl, box(541), box(367), nullptr); + avl = grpc_avl_add(avl, box(505), box(368), nullptr); + avl = remove_int(avl, 445); + avl = remove_int(avl, 256); + avl = grpc_avl_add(avl, box(232), box(371), nullptr); + avl = remove_int(avl, 577); + avl = remove_int(avl, 558); + avl = grpc_avl_add(avl, box(910), box(374), nullptr); + avl = remove_int(avl, 902); + avl = remove_int(avl, 755); + avl = remove_int(avl, 114); + avl = remove_int(avl, 438); + avl = remove_int(avl, 224); + avl = grpc_avl_add(avl, box(920), box(380), nullptr); + avl = grpc_avl_add(avl, box(655), box(381), nullptr); + avl = remove_int(avl, 557); + avl = remove_int(avl, 102); + avl = remove_int(avl, 165); + avl = grpc_avl_add(avl, box(191), box(385), nullptr); + avl = remove_int(avl, 30); + avl = grpc_avl_add(avl, box(406), box(387), nullptr); + avl = grpc_avl_add(avl, box(66), box(388), nullptr); + avl = grpc_avl_add(avl, box(87), box(389), nullptr); + avl = remove_int(avl, 7); + avl = remove_int(avl, 671); + avl = grpc_avl_add(avl, box(234), box(392), nullptr); + avl = remove_int(avl, 463); + avl = grpc_avl_add(avl, box(75), box(394), nullptr); + avl = grpc_avl_add(avl, box(487), box(395), nullptr); + avl = remove_int(avl, 203); + avl = grpc_avl_add(avl, box(711), box(397), nullptr); + avl = remove_int(avl, 291); + avl = remove_int(avl, 798); + avl = remove_int(avl, 337); + avl = grpc_avl_add(avl, box(877), box(401), nullptr); + avl = grpc_avl_add(avl, box(388), box(402), nullptr); + avl = remove_int(avl, 975); + avl = grpc_avl_add(avl, box(200), box(404), nullptr); + avl = grpc_avl_add(avl, box(408), box(405), nullptr); + avl = grpc_avl_add(avl, box(3), box(406), nullptr); + avl = grpc_avl_add(avl, box(971), box(407), nullptr); + avl = remove_int(avl, 841); + avl = remove_int(avl, 910); + avl = remove_int(avl, 74); + avl = remove_int(avl, 888); + avl = grpc_avl_add(avl, box(492), box(412), nullptr); + avl = remove_int(avl, 14); + avl = remove_int(avl, 364); + avl = grpc_avl_add(avl, box(215), box(415), nullptr); + avl = remove_int(avl, 778); + avl = remove_int(avl, 45); + avl = grpc_avl_add(avl, box(328), box(418), nullptr); + avl = grpc_avl_add(avl, box(597), box(419), nullptr); + avl = remove_int(avl, 34); + avl = grpc_avl_add(avl, box(736), box(421), nullptr); + avl = remove_int(avl, 37); + avl = grpc_avl_add(avl, box(275), box(423), nullptr); + avl = grpc_avl_add(avl, box(70), box(424), nullptr); + avl = grpc_avl_add(avl, box(771), box(425), nullptr); + avl = remove_int(avl, 536); + avl = remove_int(avl, 421); + avl = grpc_avl_add(avl, box(186), box(428), nullptr); + avl = grpc_avl_add(avl, box(788), box(429), nullptr); + avl = grpc_avl_add(avl, box(224), box(430), nullptr); + avl = remove_int(avl, 228); + avl = grpc_avl_add(avl, box(48), box(432), nullptr); + avl = grpc_avl_add(avl, box(120), box(433), nullptr); + avl = grpc_avl_add(avl, box(269), box(434), nullptr); + avl = grpc_avl_add(avl, box(904), box(435), nullptr); + avl = remove_int(avl, 699); + avl = grpc_avl_add(avl, box(340), box(437), nullptr); + avl = remove_int(avl, 276); + avl = grpc_avl_add(avl, box(591), box(439), nullptr); + avl = grpc_avl_add(avl, box(778), box(440), nullptr); + avl = remove_int(avl, 490); + avl = remove_int(avl, 973); + avl = grpc_avl_add(avl, box(294), box(443), nullptr); + avl = grpc_avl_add(avl, box(323), box(444), nullptr); + avl = remove_int(avl, 685); + avl = grpc_avl_add(avl, box(38), box(446), nullptr); + avl = grpc_avl_add(avl, box(525), box(447), nullptr); + avl = remove_int(avl, 162); + avl = grpc_avl_add(avl, box(462), box(449), nullptr); + avl = grpc_avl_add(avl, box(340), box(450), nullptr); + avl = remove_int(avl, 734); + avl = remove_int(avl, 959); + avl = grpc_avl_add(avl, box(752), box(453), nullptr); + avl = grpc_avl_add(avl, box(667), box(454), nullptr); + avl = remove_int(avl, 558); + avl = remove_int(avl, 657); + avl = grpc_avl_add(avl, box(711), box(457), nullptr); + avl = remove_int(avl, 937); + avl = grpc_avl_add(avl, box(741), box(459), nullptr); + avl = grpc_avl_add(avl, box(40), box(460), nullptr); + avl = remove_int(avl, 784); + avl = grpc_avl_add(avl, box(292), box(462), nullptr); + avl = remove_int(avl, 164); + avl = remove_int(avl, 931); + avl = remove_int(avl, 886); + avl = grpc_avl_add(avl, box(968), box(466), nullptr); + avl = remove_int(avl, 263); + avl = grpc_avl_add(avl, box(647), box(468), nullptr); + avl = grpc_avl_add(avl, box(92), box(469), nullptr); + avl = remove_int(avl, 310); + avl = grpc_avl_add(avl, box(711), box(471), nullptr); + avl = grpc_avl_add(avl, box(675), box(472), nullptr); + avl = remove_int(avl, 549); + avl = grpc_avl_add(avl, box(380), box(474), nullptr); + avl = remove_int(avl, 825); + avl = grpc_avl_add(avl, box(668), box(476), nullptr); + avl = remove_int(avl, 498); + avl = grpc_avl_add(avl, box(870), box(478), nullptr); + avl = grpc_avl_add(avl, box(391), box(479), nullptr); + avl = grpc_avl_add(avl, box(264), box(480), nullptr); + avl = remove_int(avl, 1); + avl = remove_int(avl, 849); + avl = remove_int(avl, 88); + avl = remove_int(avl, 255); + avl = remove_int(avl, 763); + avl = remove_int(avl, 831); + avl = grpc_avl_add(avl, box(508), box(487), nullptr); + avl = remove_int(avl, 849); + avl = remove_int(avl, 47); + avl = grpc_avl_add(avl, box(299), box(490), nullptr); + avl = remove_int(avl, 625); + avl = remove_int(avl, 433); + avl = remove_int(avl, 904); + avl = remove_int(avl, 761); + avl = grpc_avl_add(avl, box(33), box(495), nullptr); + avl = grpc_avl_add(avl, box(524), box(496), nullptr); + avl = remove_int(avl, 210); + avl = remove_int(avl, 299); + avl = grpc_avl_add(avl, box(823), box(499), nullptr); + avl = remove_int(avl, 479); + avl = remove_int(avl, 96); + avl = remove_int(avl, 1013); + avl = grpc_avl_add(avl, box(768), box(503), nullptr); + avl = remove_int(avl, 638); + avl = remove_int(avl, 20); + avl = grpc_avl_add(avl, box(663), box(506), nullptr); + avl = remove_int(avl, 882); + avl = grpc_avl_add(avl, box(745), box(508), nullptr); + avl = remove_int(avl, 352); + avl = grpc_avl_add(avl, box(10), box(510), nullptr); + avl = remove_int(avl, 484); + avl = grpc_avl_add(avl, box(420), box(512), nullptr); + avl = grpc_avl_add(avl, box(884), box(513), nullptr); + avl = grpc_avl_add(avl, box(993), box(514), nullptr); + avl = grpc_avl_add(avl, box(251), box(515), nullptr); + avl = remove_int(avl, 222); + avl = grpc_avl_add(avl, box(734), box(517), nullptr); + avl = grpc_avl_add(avl, box(952), box(518), nullptr); + avl = remove_int(avl, 26); + avl = remove_int(avl, 270); + avl = remove_int(avl, 481); + avl = remove_int(avl, 693); + avl = remove_int(avl, 1006); + avl = grpc_avl_add(avl, box(77), box(524), nullptr); + avl = remove_int(avl, 897); + avl = grpc_avl_add(avl, box(719), box(526), nullptr); + avl = grpc_avl_add(avl, box(622), box(527), nullptr); + avl = remove_int(avl, 28); + avl = remove_int(avl, 836); + avl = remove_int(avl, 142); + avl = grpc_avl_add(avl, box(445), box(531), nullptr); + avl = grpc_avl_add(avl, box(410), box(532), nullptr); + avl = remove_int(avl, 575); + avl = grpc_avl_add(avl, box(634), box(534), nullptr); + avl = grpc_avl_add(avl, box(906), box(535), nullptr); + avl = remove_int(avl, 649); + avl = grpc_avl_add(avl, box(813), box(537), nullptr); + avl = remove_int(avl, 702); + avl = remove_int(avl, 732); + avl = grpc_avl_add(avl, box(105), box(540), nullptr); + avl = grpc_avl_add(avl, box(867), box(541), nullptr); + avl = remove_int(avl, 964); + avl = remove_int(avl, 941); + avl = grpc_avl_add(avl, box(947), box(544), nullptr); + avl = remove_int(avl, 990); + avl = grpc_avl_add(avl, box(816), box(546), nullptr); + avl = remove_int(avl, 429); + avl = remove_int(avl, 567); + avl = remove_int(avl, 541); + avl = remove_int(avl, 583); + avl = grpc_avl_add(avl, box(57), box(551), nullptr); + avl = grpc_avl_add(avl, box(786), box(552), nullptr); + avl = grpc_avl_add(avl, box(526), box(553), nullptr); + avl = remove_int(avl, 642); + avl = remove_int(avl, 220); + avl = remove_int(avl, 840); + avl = remove_int(avl, 548); + avl = grpc_avl_add(avl, box(528), box(558), nullptr); + avl = grpc_avl_add(avl, box(749), box(559), nullptr); + avl = grpc_avl_add(avl, box(194), box(560), nullptr); + avl = remove_int(avl, 517); + avl = grpc_avl_add(avl, box(102), box(562), nullptr); + avl = remove_int(avl, 189); + avl = grpc_avl_add(avl, box(927), box(564), nullptr); + avl = remove_int(avl, 846); + avl = remove_int(avl, 130); + avl = grpc_avl_add(avl, box(694), box(567), nullptr); + avl = remove_int(avl, 750); + avl = grpc_avl_add(avl, box(357), box(569), nullptr); + avl = remove_int(avl, 431); + avl = remove_int(avl, 91); + avl = grpc_avl_add(avl, box(640), box(572), nullptr); + avl = remove_int(avl, 4); + avl = grpc_avl_add(avl, box(81), box(574), nullptr); + avl = grpc_avl_add(avl, box(595), box(575), nullptr); + avl = remove_int(avl, 444); + avl = remove_int(avl, 262); + avl = remove_int(avl, 11); + avl = grpc_avl_add(avl, box(192), box(579), nullptr); + avl = grpc_avl_add(avl, box(158), box(580), nullptr); + avl = remove_int(avl, 401); + avl = remove_int(avl, 918); + avl = grpc_avl_add(avl, box(180), box(583), nullptr); + avl = remove_int(avl, 268); + avl = grpc_avl_add(avl, box(1012), box(585), nullptr); + avl = grpc_avl_add(avl, box(90), box(586), nullptr); + avl = grpc_avl_add(avl, box(946), box(587), nullptr); + avl = remove_int(avl, 719); + avl = grpc_avl_add(avl, box(874), box(589), nullptr); + avl = grpc_avl_add(avl, box(679), box(590), nullptr); + avl = remove_int(avl, 53); + avl = remove_int(avl, 534); + avl = grpc_avl_add(avl, box(646), box(593), nullptr); + avl = grpc_avl_add(avl, box(767), box(594), nullptr); + avl = grpc_avl_add(avl, box(460), box(595), nullptr); + avl = grpc_avl_add(avl, box(852), box(596), nullptr); + avl = grpc_avl_add(avl, box(189), box(597), nullptr); + avl = remove_int(avl, 932); + avl = remove_int(avl, 366); + avl = remove_int(avl, 907); + avl = grpc_avl_add(avl, box(875), box(601), nullptr); + avl = grpc_avl_add(avl, box(434), box(602), nullptr); + avl = grpc_avl_add(avl, box(704), box(603), nullptr); + avl = grpc_avl_add(avl, box(724), box(604), nullptr); + avl = grpc_avl_add(avl, box(930), box(605), nullptr); + avl = grpc_avl_add(avl, box(1000), box(606), nullptr); + avl = remove_int(avl, 479); + avl = grpc_avl_add(avl, box(275), box(608), nullptr); + avl = remove_int(avl, 32); + avl = grpc_avl_add(avl, box(939), box(610), nullptr); + avl = remove_int(avl, 943); + avl = remove_int(avl, 329); + avl = grpc_avl_add(avl, box(490), box(613), nullptr); + avl = remove_int(avl, 477); + avl = remove_int(avl, 414); + avl = remove_int(avl, 187); + avl = remove_int(avl, 334); + avl = grpc_avl_add(avl, box(40), box(618), nullptr); + avl = remove_int(avl, 751); + avl = grpc_avl_add(avl, box(568), box(620), nullptr); + avl = grpc_avl_add(avl, box(120), box(621), nullptr); + avl = grpc_avl_add(avl, box(617), box(622), nullptr); + avl = grpc_avl_add(avl, box(32), box(623), nullptr); + avl = remove_int(avl, 701); + avl = grpc_avl_add(avl, box(910), box(625), nullptr); + avl = remove_int(avl, 557); + avl = remove_int(avl, 361); + avl = remove_int(avl, 937); + avl = remove_int(avl, 100); + avl = remove_int(avl, 684); + avl = grpc_avl_add(avl, box(751), box(631), nullptr); + avl = remove_int(avl, 781); + avl = remove_int(avl, 469); + avl = remove_int(avl, 75); + avl = remove_int(avl, 561); + avl = grpc_avl_add(avl, box(854), box(636), nullptr); + avl = remove_int(avl, 164); + avl = remove_int(avl, 258); + avl = remove_int(avl, 315); + avl = remove_int(avl, 261); + avl = grpc_avl_add(avl, box(552), box(641), nullptr); + avl = grpc_avl_add(avl, box(6), box(642), nullptr); + avl = grpc_avl_add(avl, box(680), box(643), nullptr); + avl = remove_int(avl, 741); + avl = remove_int(avl, 309); + avl = remove_int(avl, 272); + avl = grpc_avl_add(avl, box(249), box(647), nullptr); + avl = remove_int(avl, 97); + avl = remove_int(avl, 850); + avl = grpc_avl_add(avl, box(915), box(650), nullptr); + avl = grpc_avl_add(avl, box(816), box(651), nullptr); + avl = grpc_avl_add(avl, box(45), box(652), nullptr); + avl = grpc_avl_add(avl, box(168), box(653), nullptr); + avl = remove_int(avl, 153); + avl = remove_int(avl, 239); + avl = grpc_avl_add(avl, box(684), box(656), nullptr); + avl = grpc_avl_add(avl, box(208), box(657), nullptr); + avl = grpc_avl_add(avl, box(681), box(658), nullptr); + avl = grpc_avl_add(avl, box(609), box(659), nullptr); + avl = grpc_avl_add(avl, box(645), box(660), nullptr); + avl = remove_int(avl, 799); + avl = grpc_avl_add(avl, box(955), box(662), nullptr); + avl = grpc_avl_add(avl, box(946), box(663), nullptr); + avl = grpc_avl_add(avl, box(744), box(664), nullptr); + avl = grpc_avl_add(avl, box(201), box(665), nullptr); + avl = grpc_avl_add(avl, box(136), box(666), nullptr); + avl = remove_int(avl, 357); + avl = grpc_avl_add(avl, box(974), box(668), nullptr); + avl = remove_int(avl, 485); + avl = grpc_avl_add(avl, box(1009), box(670), nullptr); + avl = grpc_avl_add(avl, box(517), box(671), nullptr); + avl = remove_int(avl, 491); + avl = grpc_avl_add(avl, box(336), box(673), nullptr); + avl = grpc_avl_add(avl, box(589), box(674), nullptr); + avl = remove_int(avl, 546); + avl = remove_int(avl, 840); + avl = remove_int(avl, 104); + avl = remove_int(avl, 347); + avl = grpc_avl_add(avl, box(801), box(679), nullptr); + avl = remove_int(avl, 799); + avl = remove_int(avl, 702); + avl = remove_int(avl, 996); + avl = remove_int(avl, 93); + avl = grpc_avl_add(avl, box(561), box(684), nullptr); + avl = grpc_avl_add(avl, box(25), box(685), nullptr); + avl = remove_int(avl, 278); + avl = grpc_avl_add(avl, box(191), box(687), nullptr); + avl = remove_int(avl, 243); + avl = remove_int(avl, 918); + avl = remove_int(avl, 449); + avl = grpc_avl_add(avl, box(19), box(691), nullptr); + avl = grpc_avl_add(avl, box(762), box(692), nullptr); + avl = grpc_avl_add(avl, box(13), box(693), nullptr); + avl = grpc_avl_add(avl, box(151), box(694), nullptr); + avl = grpc_avl_add(avl, box(152), box(695), nullptr); + avl = grpc_avl_add(avl, box(793), box(696), nullptr); + avl = remove_int(avl, 862); + avl = remove_int(avl, 890); + avl = grpc_avl_add(avl, box(687), box(699), nullptr); + avl = grpc_avl_add(avl, box(509), box(700), nullptr); + avl = grpc_avl_add(avl, box(973), box(701), nullptr); + avl = remove_int(avl, 230); + avl = grpc_avl_add(avl, box(532), box(703), nullptr); + avl = remove_int(avl, 668); + avl = grpc_avl_add(avl, box(281), box(705), nullptr); + avl = grpc_avl_add(avl, box(867), box(706), nullptr); + avl = grpc_avl_add(avl, box(359), box(707), nullptr); + avl = remove_int(avl, 425); + avl = grpc_avl_add(avl, box(691), box(709), nullptr); + avl = grpc_avl_add(avl, box(163), box(710), nullptr); + avl = grpc_avl_add(avl, box(502), box(711), nullptr); + avl = remove_int(avl, 674); + avl = grpc_avl_add(avl, box(697), box(713), nullptr); + avl = remove_int(avl, 271); + avl = grpc_avl_add(avl, box(968), box(715), nullptr); + avl = grpc_avl_add(avl, box(48), box(716), nullptr); + avl = remove_int(avl, 543); + avl = grpc_avl_add(avl, box(35), box(718), nullptr); + avl = grpc_avl_add(avl, box(751), box(719), nullptr); + avl = grpc_avl_add(avl, box(478), box(720), nullptr); + avl = remove_int(avl, 797); + avl = remove_int(avl, 309); + avl = grpc_avl_add(avl, box(927), box(723), nullptr); + avl = remove_int(avl, 504); + avl = grpc_avl_add(avl, box(286), box(725), nullptr); + avl = grpc_avl_add(avl, box(413), box(726), nullptr); + avl = grpc_avl_add(avl, box(599), box(727), nullptr); + avl = remove_int(avl, 105); + avl = remove_int(avl, 605); + avl = grpc_avl_add(avl, box(632), box(730), nullptr); + avl = grpc_avl_add(avl, box(133), box(731), nullptr); + avl = remove_int(avl, 443); + avl = grpc_avl_add(avl, box(958), box(733), nullptr); + avl = grpc_avl_add(avl, box(729), box(734), nullptr); + avl = remove_int(avl, 158); + avl = grpc_avl_add(avl, box(694), box(736), nullptr); + avl = grpc_avl_add(avl, box(505), box(737), nullptr); + avl = remove_int(avl, 63); + avl = remove_int(avl, 714); + avl = grpc_avl_add(avl, box(1002), box(740), nullptr); + avl = remove_int(avl, 211); + avl = grpc_avl_add(avl, box(765), box(742), nullptr); + avl = grpc_avl_add(avl, box(455), box(743), nullptr); + avl = remove_int(avl, 59); + avl = remove_int(avl, 224); + avl = grpc_avl_add(avl, box(586), box(746), nullptr); + avl = grpc_avl_add(avl, box(348), box(747), nullptr); + avl = remove_int(avl, 10); + avl = remove_int(avl, 484); + avl = grpc_avl_add(avl, box(968), box(750), nullptr); + avl = grpc_avl_add(avl, box(923), box(751), nullptr); + avl = remove_int(avl, 573); + avl = remove_int(avl, 617); + avl = grpc_avl_add(avl, box(812), box(754), nullptr); + avl = grpc_avl_add(avl, box(179), box(755), nullptr); + avl = remove_int(avl, 284); + avl = remove_int(avl, 157); + avl = remove_int(avl, 177); + avl = remove_int(avl, 896); + avl = grpc_avl_add(avl, box(649), box(760), nullptr); + avl = grpc_avl_add(avl, box(927), box(761), nullptr); + avl = grpc_avl_add(avl, box(454), box(762), nullptr); + avl = grpc_avl_add(avl, box(217), box(763), nullptr); + avl = remove_int(avl, 534); + avl = grpc_avl_add(avl, box(180), box(765), nullptr); + avl = grpc_avl_add(avl, box(319), box(766), nullptr); + avl = remove_int(avl, 92); + avl = grpc_avl_add(avl, box(483), box(768), nullptr); + avl = remove_int(avl, 504); + avl = remove_int(avl, 1017); + avl = remove_int(avl, 37); + avl = remove_int(avl, 50); + avl = grpc_avl_add(avl, box(302), box(773), nullptr); + avl = remove_int(avl, 807); + avl = grpc_avl_add(avl, box(463), box(775), nullptr); + avl = grpc_avl_add(avl, box(271), box(776), nullptr); + avl = grpc_avl_add(avl, box(644), box(777), nullptr); + avl = remove_int(avl, 618); + avl = grpc_avl_add(avl, box(166), box(779), nullptr); + avl = grpc_avl_add(avl, box(538), box(780), nullptr); + avl = remove_int(avl, 606); + avl = grpc_avl_add(avl, box(425), box(782), nullptr); + avl = remove_int(avl, 725); + avl = remove_int(avl, 383); + avl = grpc_avl_add(avl, box(155), box(785), nullptr); + avl = remove_int(avl, 889); + avl = grpc_avl_add(avl, box(653), box(787), nullptr); + avl = remove_int(avl, 386); + avl = grpc_avl_add(avl, box(142), box(789), nullptr); + avl = remove_int(avl, 107); + avl = remove_int(avl, 603); + avl = remove_int(avl, 971); + avl = grpc_avl_add(avl, box(80), box(793), nullptr); + avl = grpc_avl_add(avl, box(61), box(794), nullptr); + avl = grpc_avl_add(avl, box(693), box(795), nullptr); + avl = grpc_avl_add(avl, box(592), box(796), nullptr); + avl = grpc_avl_add(avl, box(433), box(797), nullptr); + avl = grpc_avl_add(avl, box(973), box(798), nullptr); + avl = remove_int(avl, 901); + avl = remove_int(avl, 340); + avl = remove_int(avl, 709); + avl = grpc_avl_add(avl, box(224), box(802), nullptr); + avl = remove_int(avl, 120); + avl = remove_int(avl, 271); + avl = grpc_avl_add(avl, box(780), box(805), nullptr); + avl = grpc_avl_add(avl, box(867), box(806), nullptr); + avl = grpc_avl_add(avl, box(756), box(807), nullptr); + avl = grpc_avl_add(avl, box(583), box(808), nullptr); + avl = grpc_avl_add(avl, box(356), box(809), nullptr); + avl = grpc_avl_add(avl, box(58), box(810), nullptr); + avl = remove_int(avl, 219); + avl = grpc_avl_add(avl, box(301), box(812), nullptr); + avl = remove_int(avl, 643); + avl = remove_int(avl, 787); + avl = remove_int(avl, 583); + avl = remove_int(avl, 552); + avl = remove_int(avl, 308); + avl = remove_int(avl, 608); + avl = remove_int(avl, 363); + avl = remove_int(avl, 690); + avl = grpc_avl_add(avl, box(233), box(821), nullptr); + avl = grpc_avl_add(avl, box(479), box(822), nullptr); + avl = grpc_avl_add(avl, box(323), box(823), nullptr); + avl = grpc_avl_add(avl, box(802), box(824), nullptr); + avl = remove_int(avl, 682); + avl = remove_int(avl, 705); + avl = remove_int(avl, 487); + avl = grpc_avl_add(avl, box(530), box(828), nullptr); + avl = grpc_avl_add(avl, box(232), box(829), nullptr); + avl = remove_int(avl, 627); + avl = grpc_avl_add(avl, box(396), box(831), nullptr); + avl = grpc_avl_add(avl, box(61), box(832), nullptr); + avl = grpc_avl_add(avl, box(932), box(833), nullptr); + avl = grpc_avl_add(avl, box(108), box(834), nullptr); + avl = grpc_avl_add(avl, box(524), box(835), nullptr); + avl = remove_int(avl, 390); + avl = remove_int(avl, 307); + avl = grpc_avl_add(avl, box(722), box(838), nullptr); + avl = grpc_avl_add(avl, box(907), box(839), nullptr); + avl = remove_int(avl, 286); + avl = remove_int(avl, 337); + avl = remove_int(avl, 443); + avl = grpc_avl_add(avl, box(973), box(843), nullptr); + avl = remove_int(avl, 930); + avl = remove_int(avl, 242); + avl = grpc_avl_add(avl, box(997), box(846), nullptr); + avl = grpc_avl_add(avl, box(689), box(847), nullptr); + avl = remove_int(avl, 318); + avl = grpc_avl_add(avl, box(703), box(849), nullptr); + avl = grpc_avl_add(avl, box(868), box(850), nullptr); + avl = grpc_avl_add(avl, box(200), box(851), nullptr); + avl = grpc_avl_add(avl, box(960), box(852), nullptr); + avl = grpc_avl_add(avl, box(80), box(853), nullptr); + avl = remove_int(avl, 113); + avl = grpc_avl_add(avl, box(135), box(855), nullptr); + avl = remove_int(avl, 529); + avl = grpc_avl_add(avl, box(366), box(857), nullptr); + avl = remove_int(avl, 272); + avl = grpc_avl_add(avl, box(921), box(859), nullptr); + avl = remove_int(avl, 497); + avl = grpc_avl_add(avl, box(712), box(861), nullptr); + avl = remove_int(avl, 777); + avl = remove_int(avl, 505); + avl = remove_int(avl, 974); + avl = remove_int(avl, 497); + avl = grpc_avl_add(avl, box(388), box(866), nullptr); + avl = grpc_avl_add(avl, box(29), box(867), nullptr); + avl = grpc_avl_add(avl, box(180), box(868), nullptr); + avl = grpc_avl_add(avl, box(983), box(869), nullptr); + avl = grpc_avl_add(avl, box(72), box(870), nullptr); + avl = grpc_avl_add(avl, box(693), box(871), nullptr); + avl = grpc_avl_add(avl, box(567), box(872), nullptr); + avl = remove_int(avl, 549); + avl = remove_int(avl, 351); + avl = grpc_avl_add(avl, box(1019), box(875), nullptr); + avl = remove_int(avl, 585); + avl = remove_int(avl, 294); + avl = remove_int(avl, 61); + avl = grpc_avl_add(avl, box(409), box(879), nullptr); + avl = grpc_avl_add(avl, box(984), box(880), nullptr); + avl = grpc_avl_add(avl, box(830), box(881), nullptr); + avl = remove_int(avl, 579); + avl = grpc_avl_add(avl, box(672), box(883), nullptr); + avl = remove_int(avl, 968); + + grpc_avl_unref(avl, nullptr); +} + +static void test_badcase3(void) { + grpc_avl avl; + + gpr_log(GPR_DEBUG, "test_badcase3"); + + avl = grpc_avl_create(&int_int_vtable); + avl = remove_int(avl, 624); + avl = grpc_avl_add(avl, box(59), box(2), nullptr); + avl = grpc_avl_add(avl, box(494), box(3), nullptr); + avl = grpc_avl_add(avl, box(226), box(4), nullptr); + avl = remove_int(avl, 524); + avl = grpc_avl_add(avl, box(540), box(6), nullptr); + avl = remove_int(avl, 1008); + avl = grpc_avl_add(avl, box(502), box(8), nullptr); + avl = remove_int(avl, 267); + avl = remove_int(avl, 764); + avl = remove_int(avl, 443); + avl = grpc_avl_add(avl, box(8), box(12), nullptr); + avl = remove_int(avl, 291); + avl = remove_int(avl, 796); + avl = remove_int(avl, 1002); + avl = grpc_avl_add(avl, box(778), box(16), nullptr); + avl = remove_int(avl, 621); + avl = remove_int(avl, 891); + avl = remove_int(avl, 880); + avl = grpc_avl_add(avl, box(197), box(20), nullptr); + avl = grpc_avl_add(avl, box(441), box(21), nullptr); + avl = grpc_avl_add(avl, box(719), box(22), nullptr); + avl = remove_int(avl, 109); + avl = grpc_avl_add(avl, box(458), box(24), nullptr); + avl = remove_int(avl, 86); + avl = grpc_avl_add(avl, box(897), box(26), nullptr); + avl = grpc_avl_add(avl, box(997), box(27), nullptr); + avl = remove_int(avl, 235); + avl = remove_int(avl, 425); + avl = remove_int(avl, 186); + avl = grpc_avl_add(avl, box(887), box(31), nullptr); + avl = grpc_avl_add(avl, box(1005), box(32), nullptr); + avl = grpc_avl_add(avl, box(778), box(33), nullptr); + avl = grpc_avl_add(avl, box(575), box(34), nullptr); + avl = remove_int(avl, 966); + avl = remove_int(avl, 1015); + avl = grpc_avl_add(avl, box(486), box(37), nullptr); + avl = grpc_avl_add(avl, box(809), box(38), nullptr); + avl = grpc_avl_add(avl, box(907), box(39), nullptr); + avl = grpc_avl_add(avl, box(971), box(40), nullptr); + avl = remove_int(avl, 441); + avl = remove_int(avl, 498); + avl = grpc_avl_add(avl, box(727), box(43), nullptr); + avl = remove_int(avl, 679); + avl = remove_int(avl, 740); + avl = remove_int(avl, 532); + avl = grpc_avl_add(avl, box(805), box(47), nullptr); + avl = remove_int(avl, 64); + avl = grpc_avl_add(avl, box(362), box(49), nullptr); + avl = grpc_avl_add(avl, box(170), box(50), nullptr); + avl = grpc_avl_add(avl, box(389), box(51), nullptr); + avl = grpc_avl_add(avl, box(689), box(52), nullptr); + avl = remove_int(avl, 871); + avl = grpc_avl_add(avl, box(447), box(54), nullptr); + avl = remove_int(avl, 718); + avl = grpc_avl_add(avl, box(724), box(56), nullptr); + avl = remove_int(avl, 215); + avl = grpc_avl_add(avl, box(550), box(58), nullptr); + avl = remove_int(avl, 932); + avl = grpc_avl_add(avl, box(47), box(60), nullptr); + avl = remove_int(avl, 46); + avl = remove_int(avl, 229); + avl = grpc_avl_add(avl, box(68), box(63), nullptr); + avl = grpc_avl_add(avl, box(387), box(64), nullptr); + avl = remove_int(avl, 933); + avl = remove_int(avl, 736); + avl = remove_int(avl, 719); + avl = grpc_avl_add(avl, box(150), box(68), nullptr); + avl = remove_int(avl, 875); + avl = remove_int(avl, 298); + avl = grpc_avl_add(avl, box(991), box(71), nullptr); + avl = remove_int(avl, 705); + avl = grpc_avl_add(avl, box(197), box(73), nullptr); + avl = grpc_avl_add(avl, box(101), box(74), nullptr); + avl = remove_int(avl, 436); + avl = grpc_avl_add(avl, box(755), box(76), nullptr); + avl = grpc_avl_add(avl, box(727), box(77), nullptr); + avl = remove_int(avl, 309); + avl = remove_int(avl, 253); + avl = grpc_avl_add(avl, box(203), box(80), nullptr); + avl = remove_int(avl, 231); + avl = grpc_avl_add(avl, box(461), box(82), nullptr); + avl = remove_int(avl, 316); + avl = remove_int(avl, 493); + avl = grpc_avl_add(avl, box(184), box(85), nullptr); + avl = remove_int(avl, 737); + avl = grpc_avl_add(avl, box(790), box(87), nullptr); + avl = grpc_avl_add(avl, box(335), box(88), nullptr); + avl = remove_int(avl, 649); + avl = grpc_avl_add(avl, box(69), box(90), nullptr); + avl = remove_int(avl, 585); + avl = remove_int(avl, 543); + avl = grpc_avl_add(avl, box(784), box(93), nullptr); + avl = grpc_avl_add(avl, box(60), box(94), nullptr); + avl = grpc_avl_add(avl, box(525), box(95), nullptr); + avl = grpc_avl_add(avl, box(177), box(96), nullptr); + avl = grpc_avl_add(avl, box(178), box(97), nullptr); + avl = grpc_avl_add(avl, box(683), box(98), nullptr); + avl = grpc_avl_add(avl, box(226), box(99), nullptr); + avl = grpc_avl_add(avl, box(662), box(100), nullptr); + avl = remove_int(avl, 944); + avl = grpc_avl_add(avl, box(562), box(102), nullptr); + avl = grpc_avl_add(avl, box(793), box(103), nullptr); + avl = remove_int(avl, 673); + avl = grpc_avl_add(avl, box(310), box(105), nullptr); + avl = remove_int(avl, 479); + avl = remove_int(avl, 543); + avl = remove_int(avl, 159); + avl = remove_int(avl, 850); + avl = grpc_avl_add(avl, box(318), box(110), nullptr); + avl = grpc_avl_add(avl, box(483), box(111), nullptr); + avl = grpc_avl_add(avl, box(84), box(112), nullptr); + avl = remove_int(avl, 109); + avl = grpc_avl_add(avl, box(132), box(114), nullptr); + avl = grpc_avl_add(avl, box(920), box(115), nullptr); + avl = remove_int(avl, 746); + avl = grpc_avl_add(avl, box(145), box(117), nullptr); + avl = grpc_avl_add(avl, box(526), box(118), nullptr); + avl = remove_int(avl, 158); + avl = grpc_avl_add(avl, box(332), box(120), nullptr); + avl = grpc_avl_add(avl, box(918), box(121), nullptr); + avl = remove_int(avl, 339); + avl = grpc_avl_add(avl, box(809), box(123), nullptr); + avl = grpc_avl_add(avl, box(742), box(124), nullptr); + avl = grpc_avl_add(avl, box(718), box(125), nullptr); + avl = remove_int(avl, 988); + avl = remove_int(avl, 531); + avl = remove_int(avl, 840); + avl = grpc_avl_add(avl, box(816), box(129), nullptr); + avl = grpc_avl_add(avl, box(976), box(130), nullptr); + avl = remove_int(avl, 743); + avl = remove_int(avl, 528); + avl = remove_int(avl, 982); + avl = grpc_avl_add(avl, box(803), box(134), nullptr); + avl = grpc_avl_add(avl, box(205), box(135), nullptr); + avl = grpc_avl_add(avl, box(584), box(136), nullptr); + avl = remove_int(avl, 923); + avl = remove_int(avl, 538); + avl = remove_int(avl, 398); + avl = remove_int(avl, 320); + avl = remove_int(avl, 292); + avl = grpc_avl_add(avl, box(270), box(142), nullptr); + avl = grpc_avl_add(avl, box(333), box(143), nullptr); + avl = remove_int(avl, 439); + avl = grpc_avl_add(avl, box(35), box(145), nullptr); + avl = grpc_avl_add(avl, box(837), box(146), nullptr); + avl = remove_int(avl, 65); + avl = remove_int(avl, 642); + avl = remove_int(avl, 371); + avl = remove_int(avl, 140); + avl = remove_int(avl, 533); + avl = remove_int(avl, 676); + avl = grpc_avl_add(avl, box(624), box(153), nullptr); + avl = grpc_avl_add(avl, box(116), box(154), nullptr); + avl = grpc_avl_add(avl, box(446), box(155), nullptr); + avl = remove_int(avl, 91); + avl = remove_int(avl, 721); + avl = remove_int(avl, 537); + avl = grpc_avl_add(avl, box(448), box(159), nullptr); + avl = remove_int(avl, 155); + avl = remove_int(avl, 344); + avl = remove_int(avl, 237); + avl = grpc_avl_add(avl, box(309), box(163), nullptr); + avl = grpc_avl_add(avl, box(434), box(164), nullptr); + avl = grpc_avl_add(avl, box(277), box(165), nullptr); + avl = remove_int(avl, 233); + avl = grpc_avl_add(avl, box(275), box(167), nullptr); + avl = grpc_avl_add(avl, box(218), box(168), nullptr); + avl = grpc_avl_add(avl, box(76), box(169), nullptr); + avl = grpc_avl_add(avl, box(898), box(170), nullptr); + avl = remove_int(avl, 771); + avl = grpc_avl_add(avl, box(237), box(172), nullptr); + avl = remove_int(avl, 327); + avl = grpc_avl_add(avl, box(499), box(174), nullptr); + avl = remove_int(avl, 727); + avl = remove_int(avl, 234); + avl = remove_int(avl, 623); + avl = remove_int(avl, 458); + avl = remove_int(avl, 326); + avl = remove_int(avl, 589); + avl = grpc_avl_add(avl, box(442), box(181), nullptr); + avl = remove_int(avl, 389); + avl = grpc_avl_add(avl, box(708), box(183), nullptr); + avl = grpc_avl_add(avl, box(594), box(184), nullptr); + avl = grpc_avl_add(avl, box(942), box(185), nullptr); + avl = grpc_avl_add(avl, box(282), box(186), nullptr); + avl = remove_int(avl, 434); + avl = remove_int(avl, 134); + avl = remove_int(avl, 270); + avl = remove_int(avl, 512); + avl = remove_int(avl, 265); + avl = remove_int(avl, 21); + avl = remove_int(avl, 193); + avl = remove_int(avl, 797); + avl = remove_int(avl, 347); + avl = grpc_avl_add(avl, box(99), box(196), nullptr); + avl = grpc_avl_add(avl, box(161), box(197), nullptr); + avl = remove_int(avl, 484); + avl = grpc_avl_add(avl, box(72), box(199), nullptr); + avl = remove_int(avl, 629); + avl = grpc_avl_add(avl, box(522), box(201), nullptr); + avl = remove_int(avl, 679); + avl = grpc_avl_add(avl, box(407), box(203), nullptr); + avl = remove_int(avl, 693); + avl = grpc_avl_add(avl, box(424), box(205), nullptr); + avl = grpc_avl_add(avl, box(651), box(206), nullptr); + avl = grpc_avl_add(avl, box(927), box(207), nullptr); + avl = remove_int(avl, 553); + avl = grpc_avl_add(avl, box(128), box(209), nullptr); + avl = grpc_avl_add(avl, box(616), box(210), nullptr); + avl = grpc_avl_add(avl, box(690), box(211), nullptr); + avl = remove_int(avl, 241); + avl = remove_int(avl, 179); + avl = grpc_avl_add(avl, box(697), box(214), nullptr); + avl = remove_int(avl, 779); + avl = grpc_avl_add(avl, box(241), box(216), nullptr); + avl = remove_int(avl, 190); + avl = remove_int(avl, 210); + avl = grpc_avl_add(avl, box(711), box(219), nullptr); + avl = remove_int(avl, 251); + avl = remove_int(avl, 61); + avl = grpc_avl_add(avl, box(800), box(222), nullptr); + avl = remove_int(avl, 551); + avl = grpc_avl_add(avl, box(61), box(224), nullptr); + avl = grpc_avl_add(avl, box(656), box(225), nullptr); + avl = remove_int(avl, 130); + avl = remove_int(avl, 368); + avl = remove_int(avl, 150); + avl = remove_int(avl, 73); + avl = grpc_avl_add(avl, box(799), box(230), nullptr); + avl = grpc_avl_add(avl, box(125), box(231), nullptr); + avl = remove_int(avl, 107); + avl = grpc_avl_add(avl, box(938), box(233), nullptr); + avl = grpc_avl_add(avl, box(914), box(234), nullptr); + avl = grpc_avl_add(avl, box(197), box(235), nullptr); + avl = remove_int(avl, 736); + avl = grpc_avl_add(avl, box(20), box(237), nullptr); + avl = remove_int(avl, 224); + avl = remove_int(avl, 841); + avl = grpc_avl_add(avl, box(226), box(240), nullptr); + avl = remove_int(avl, 963); + avl = remove_int(avl, 796); + avl = remove_int(avl, 728); + avl = grpc_avl_add(avl, box(855), box(244), nullptr); + avl = grpc_avl_add(avl, box(769), box(245), nullptr); + avl = grpc_avl_add(avl, box(631), box(246), nullptr); + avl = remove_int(avl, 648); + avl = grpc_avl_add(avl, box(187), box(248), nullptr); + avl = grpc_avl_add(avl, box(31), box(249), nullptr); + avl = remove_int(avl, 163); + avl = grpc_avl_add(avl, box(218), box(251), nullptr); + avl = grpc_avl_add(avl, box(488), box(252), nullptr); + avl = grpc_avl_add(avl, box(387), box(253), nullptr); + avl = grpc_avl_add(avl, box(809), box(254), nullptr); + avl = grpc_avl_add(avl, box(997), box(255), nullptr); + avl = remove_int(avl, 678); + avl = grpc_avl_add(avl, box(368), box(257), nullptr); + avl = grpc_avl_add(avl, box(220), box(258), nullptr); + avl = grpc_avl_add(avl, box(373), box(259), nullptr); + avl = remove_int(avl, 874); + avl = remove_int(avl, 682); + avl = remove_int(avl, 1014); + avl = remove_int(avl, 195); + avl = grpc_avl_add(avl, box(868), box(264), nullptr); + avl = remove_int(avl, 254); + avl = remove_int(avl, 456); + avl = grpc_avl_add(avl, box(906), box(267), nullptr); + avl = remove_int(avl, 711); + avl = grpc_avl_add(avl, box(632), box(269), nullptr); + avl = remove_int(avl, 474); + avl = grpc_avl_add(avl, box(508), box(271), nullptr); + avl = grpc_avl_add(avl, box(518), box(272), nullptr); + avl = remove_int(avl, 579); + avl = remove_int(avl, 948); + avl = grpc_avl_add(avl, box(789), box(275), nullptr); + avl = grpc_avl_add(avl, box(48), box(276), nullptr); + avl = grpc_avl_add(avl, box(256), box(277), nullptr); + avl = grpc_avl_add(avl, box(754), box(278), nullptr); + avl = remove_int(avl, 215); + avl = grpc_avl_add(avl, box(679), box(280), nullptr); + avl = grpc_avl_add(avl, box(606), box(281), nullptr); + avl = remove_int(avl, 941); + avl = remove_int(avl, 31); + avl = grpc_avl_add(avl, box(758), box(284), nullptr); + avl = remove_int(avl, 101); + avl = grpc_avl_add(avl, box(244), box(286), nullptr); + avl = grpc_avl_add(avl, box(337), box(287), nullptr); + avl = grpc_avl_add(avl, box(461), box(288), nullptr); + avl = remove_int(avl, 476); + avl = grpc_avl_add(avl, box(845), box(290), nullptr); + avl = remove_int(avl, 160); + avl = grpc_avl_add(avl, box(690), box(292), nullptr); + avl = remove_int(avl, 931); + avl = grpc_avl_add(avl, box(869), box(294), nullptr); + avl = grpc_avl_add(avl, box(1019), box(295), nullptr); + avl = remove_int(avl, 591); + avl = remove_int(avl, 635); + avl = remove_int(avl, 67); + avl = grpc_avl_add(avl, box(113), box(299), nullptr); + avl = remove_int(avl, 305); + avl = grpc_avl_add(avl, box(10), box(301), nullptr); + avl = remove_int(avl, 823); + avl = remove_int(avl, 288); + avl = remove_int(avl, 239); + avl = grpc_avl_add(avl, box(646), box(305), nullptr); + avl = grpc_avl_add(avl, box(1006), box(306), nullptr); + avl = grpc_avl_add(avl, box(954), box(307), nullptr); + avl = grpc_avl_add(avl, box(199), box(308), nullptr); + avl = grpc_avl_add(avl, box(69), box(309), nullptr); + avl = grpc_avl_add(avl, box(984), box(310), nullptr); + avl = remove_int(avl, 568); + avl = remove_int(avl, 666); + avl = remove_int(avl, 37); + avl = grpc_avl_add(avl, box(845), box(314), nullptr); + avl = remove_int(avl, 535); + avl = remove_int(avl, 365); + avl = remove_int(avl, 676); + avl = remove_int(avl, 892); + avl = remove_int(avl, 425); + avl = remove_int(avl, 704); + avl = remove_int(avl, 168); + avl = grpc_avl_add(avl, box(853), box(322), nullptr); + avl = grpc_avl_add(avl, box(335), box(323), nullptr); + avl = grpc_avl_add(avl, box(961), box(324), nullptr); + avl = grpc_avl_add(avl, box(73), box(325), nullptr); + avl = remove_int(avl, 469); + avl = grpc_avl_add(avl, box(449), box(327), nullptr); + avl = remove_int(avl, 821); + avl = grpc_avl_add(avl, box(845), box(329), nullptr); + avl = remove_int(avl, 637); + avl = grpc_avl_add(avl, box(769), box(331), nullptr); + avl = grpc_avl_add(avl, box(901), box(332), nullptr); + avl = remove_int(avl, 142); + avl = remove_int(avl, 361); + avl = remove_int(avl, 876); + avl = grpc_avl_add(avl, box(614), box(336), nullptr); + avl = grpc_avl_add(avl, box(729), box(337), nullptr); + avl = remove_int(avl, 120); + avl = remove_int(avl, 473); + avl = remove_int(avl, 445); + avl = grpc_avl_add(avl, box(978), box(341), nullptr); + avl = grpc_avl_add(avl, box(164), box(342), nullptr); + avl = grpc_avl_add(avl, box(1), box(343), nullptr); + avl = remove_int(avl, 890); + avl = grpc_avl_add(avl, box(605), box(345), nullptr); + avl = grpc_avl_add(avl, box(178), box(346), nullptr); + avl = grpc_avl_add(avl, box(481), box(347), nullptr); + avl = grpc_avl_add(avl, box(772), box(348), nullptr); + avl = remove_int(avl, 824); + avl = remove_int(avl, 167); + avl = remove_int(avl, 151); + avl = grpc_avl_add(avl, box(698), box(352), nullptr); + avl = grpc_avl_add(avl, box(202), box(353), nullptr); + avl = grpc_avl_add(avl, box(921), box(354), nullptr); + avl = grpc_avl_add(avl, box(875), box(355), nullptr); + avl = remove_int(avl, 197); + avl = remove_int(avl, 232); + avl = grpc_avl_add(avl, box(209), box(358), nullptr); + avl = remove_int(avl, 324); + avl = remove_int(avl, 56); + avl = remove_int(avl, 579); + avl = remove_int(avl, 255); + avl = remove_int(avl, 290); + avl = grpc_avl_add(avl, box(661), box(364), nullptr); + avl = grpc_avl_add(avl, box(113), box(365), nullptr); + avl = remove_int(avl, 767); + avl = grpc_avl_add(avl, box(586), box(367), nullptr); + avl = grpc_avl_add(avl, box(121), box(368), nullptr); + avl = remove_int(avl, 235); + avl = remove_int(avl, 439); + avl = remove_int(avl, 360); + avl = grpc_avl_add(avl, box(916), box(372), nullptr); + avl = remove_int(avl, 999); + avl = grpc_avl_add(avl, box(825), box(374), nullptr); + avl = grpc_avl_add(avl, box(177), box(375), nullptr); + avl = remove_int(avl, 204); + avl = remove_int(avl, 92); + avl = grpc_avl_add(avl, box(794), box(378), nullptr); + avl = grpc_avl_add(avl, box(463), box(379), nullptr); + avl = grpc_avl_add(avl, box(472), box(380), nullptr); + avl = remove_int(avl, 235); + avl = grpc_avl_add(avl, box(840), box(382), nullptr); + avl = remove_int(avl, 657); + avl = grpc_avl_add(avl, box(586), box(384), nullptr); + avl = grpc_avl_add(avl, box(979), box(385), nullptr); + avl = remove_int(avl, 979); + avl = grpc_avl_add(avl, box(639), box(387), nullptr); + avl = remove_int(avl, 907); + avl = remove_int(avl, 973); + avl = grpc_avl_add(avl, box(913), box(390), nullptr); + avl = grpc_avl_add(avl, box(566), box(391), nullptr); + avl = grpc_avl_add(avl, box(883), box(392), nullptr); + avl = grpc_avl_add(avl, box(552), box(393), nullptr); + avl = grpc_avl_add(avl, box(16), box(394), nullptr); + avl = remove_int(avl, 60); + avl = grpc_avl_add(avl, box(567), box(396), nullptr); + avl = grpc_avl_add(avl, box(705), box(397), nullptr); + avl = grpc_avl_add(avl, box(94), box(398), nullptr); + avl = remove_int(avl, 321); + avl = grpc_avl_add(avl, box(207), box(400), nullptr); + avl = grpc_avl_add(avl, box(682), box(401), nullptr); + avl = grpc_avl_add(avl, box(592), box(402), nullptr); + avl = grpc_avl_add(avl, box(10), box(403), nullptr); + avl = remove_int(avl, 911); + avl = remove_int(avl, 161); + avl = grpc_avl_add(avl, box(86), box(406), nullptr); + avl = remove_int(avl, 893); + avl = remove_int(avl, 362); + avl = grpc_avl_add(avl, box(599), box(409), nullptr); + avl = remove_int(avl, 413); + avl = grpc_avl_add(avl, box(867), box(411), nullptr); + avl = remove_int(avl, 955); + avl = grpc_avl_add(avl, box(341), box(413), nullptr); + avl = grpc_avl_add(avl, box(887), box(414), nullptr); + avl = remove_int(avl, 706); + avl = grpc_avl_add(avl, box(939), box(416), nullptr); + avl = remove_int(avl, 233); + avl = remove_int(avl, 662); + avl = remove_int(avl, 984); + avl = remove_int(avl, 203); + avl = grpc_avl_add(avl, box(326), box(421), nullptr); + avl = remove_int(avl, 848); + avl = grpc_avl_add(avl, box(235), box(423), nullptr); + avl = remove_int(avl, 617); + avl = grpc_avl_add(avl, box(565), box(425), nullptr); + avl = remove_int(avl, 469); + avl = grpc_avl_add(avl, box(988), box(427), nullptr); + avl = remove_int(avl, 957); + avl = grpc_avl_add(avl, box(426), box(429), nullptr); + avl = remove_int(avl, 967); + avl = grpc_avl_add(avl, box(890), box(431), nullptr); + avl = grpc_avl_add(avl, box(473), box(432), nullptr); + avl = remove_int(avl, 367); + avl = remove_int(avl, 344); + avl = remove_int(avl, 660); + avl = remove_int(avl, 448); + avl = remove_int(avl, 837); + avl = remove_int(avl, 158); + avl = grpc_avl_add(avl, box(459), box(439), nullptr); + avl = remove_int(avl, 882); + avl = remove_int(avl, 782); + avl = grpc_avl_add(avl, box(408), box(442), nullptr); + avl = grpc_avl_add(avl, box(728), box(443), nullptr); + avl = remove_int(avl, 27); + avl = grpc_avl_add(avl, box(137), box(445), nullptr); + avl = grpc_avl_add(avl, box(239), box(446), nullptr); + avl = remove_int(avl, 854); + avl = grpc_avl_add(avl, box(104), box(448), nullptr); + avl = grpc_avl_add(avl, box(823), box(449), nullptr); + avl = grpc_avl_add(avl, box(524), box(450), nullptr); + avl = grpc_avl_add(avl, box(995), box(451), nullptr); + avl = remove_int(avl, 422); + avl = remove_int(avl, 220); + avl = grpc_avl_add(avl, box(856), box(454), nullptr); + avl = remove_int(avl, 332); + avl = grpc_avl_add(avl, box(679), box(456), nullptr); + avl = remove_int(avl, 18); + avl = grpc_avl_add(avl, box(837), box(458), nullptr); + avl = remove_int(avl, 405); + avl = remove_int(avl, 877); + avl = remove_int(avl, 835); + avl = grpc_avl_add(avl, box(547), box(462), nullptr); + avl = remove_int(avl, 805); + avl = remove_int(avl, 862); + avl = grpc_avl_add(avl, box(75), box(465), nullptr); + avl = remove_int(avl, 41); + avl = grpc_avl_add(avl, box(310), box(467), nullptr); + avl = remove_int(avl, 855); + avl = grpc_avl_add(avl, box(20), box(469), nullptr); + avl = remove_int(avl, 186); + avl = remove_int(avl, 378); + avl = remove_int(avl, 442); + avl = remove_int(avl, 930); + avl = grpc_avl_add(avl, box(118), box(474), nullptr); + avl = grpc_avl_add(avl, box(96), box(475), nullptr); + avl = remove_int(avl, 854); + avl = grpc_avl_add(avl, box(65), box(477), nullptr); + avl = grpc_avl_add(avl, box(573), box(478), nullptr); + avl = grpc_avl_add(avl, box(4), box(479), nullptr); + avl = grpc_avl_add(avl, box(451), box(480), nullptr); + avl = grpc_avl_add(avl, box(774), box(481), nullptr); + avl = grpc_avl_add(avl, box(126), box(482), nullptr); + avl = remove_int(avl, 956); + avl = remove_int(avl, 591); + avl = remove_int(avl, 644); + avl = grpc_avl_add(avl, box(304), box(486), nullptr); + avl = remove_int(avl, 620); + avl = remove_int(avl, 394); + avl = grpc_avl_add(avl, box(1002), box(489), nullptr); + avl = grpc_avl_add(avl, box(837), box(490), nullptr); + avl = remove_int(avl, 485); + avl = grpc_avl_add(avl, box(1005), box(492), nullptr); + avl = remove_int(avl, 21); + avl = grpc_avl_add(avl, box(396), box(494), nullptr); + avl = remove_int(avl, 966); + avl = grpc_avl_add(avl, box(105), box(496), nullptr); + avl = grpc_avl_add(avl, box(316), box(497), nullptr); + avl = remove_int(avl, 776); + avl = grpc_avl_add(avl, box(188), box(499), nullptr); + avl = remove_int(avl, 200); + avl = grpc_avl_add(avl, box(98), box(501), nullptr); + avl = grpc_avl_add(avl, box(831), box(502), nullptr); + avl = grpc_avl_add(avl, box(227), box(503), nullptr); + avl = grpc_avl_add(avl, box(220), box(504), nullptr); + avl = remove_int(avl, 715); + avl = remove_int(avl, 279); + avl = grpc_avl_add(avl, box(701), box(507), nullptr); + avl = grpc_avl_add(avl, box(726), box(508), nullptr); + avl = grpc_avl_add(avl, box(815), box(509), nullptr); + avl = grpc_avl_add(avl, box(749), box(510), nullptr); + avl = remove_int(avl, 946); + avl = remove_int(avl, 449); + avl = remove_int(avl, 62); + avl = remove_int(avl, 487); + avl = grpc_avl_add(avl, box(545), box(515), nullptr); + avl = remove_int(avl, 59); + avl = grpc_avl_add(avl, box(168), box(517), nullptr); + avl = remove_int(avl, 337); + avl = grpc_avl_add(avl, box(69), box(519), nullptr); + avl = remove_int(avl, 600); + avl = grpc_avl_add(avl, box(591), box(521), nullptr); + avl = grpc_avl_add(avl, box(960), box(522), nullptr); + avl = grpc_avl_add(avl, box(116), box(523), nullptr); + avl = remove_int(avl, 991); + avl = grpc_avl_add(avl, box(760), box(525), nullptr); + avl = grpc_avl_add(avl, box(664), box(526), nullptr); + avl = grpc_avl_add(avl, box(547), box(527), nullptr); + avl = remove_int(avl, 922); + avl = grpc_avl_add(avl, box(290), box(529), nullptr); + avl = grpc_avl_add(avl, box(859), box(530), nullptr); + avl = grpc_avl_add(avl, box(49), box(531), nullptr); + avl = remove_int(avl, 455); + avl = remove_int(avl, 786); + avl = grpc_avl_add(avl, box(613), box(534), nullptr); + avl = grpc_avl_add(avl, box(326), box(535), nullptr); + avl = remove_int(avl, 615); + avl = grpc_avl_add(avl, box(45), box(537), nullptr); + avl = grpc_avl_add(avl, box(162), box(538), nullptr); + avl = grpc_avl_add(avl, box(189), box(539), nullptr); + avl = remove_int(avl, 68); + avl = remove_int(avl, 846); + avl = grpc_avl_add(avl, box(608), box(542), nullptr); + avl = remove_int(avl, 821); + avl = grpc_avl_add(avl, box(978), box(544), nullptr); + avl = grpc_avl_add(avl, box(892), box(545), nullptr); + avl = remove_int(avl, 924); + avl = grpc_avl_add(avl, box(708), box(547), nullptr); + avl = remove_int(avl, 135); + avl = remove_int(avl, 124); + avl = grpc_avl_add(avl, box(301), box(550), nullptr); + avl = grpc_avl_add(avl, box(939), box(551), nullptr); + avl = grpc_avl_add(avl, box(344), box(552), nullptr); + avl = remove_int(avl, 443); + avl = remove_int(avl, 122); + avl = grpc_avl_add(avl, box(636), box(555), nullptr); + avl = remove_int(avl, 558); + avl = grpc_avl_add(avl, box(923), box(557), nullptr); + avl = remove_int(avl, 827); + avl = grpc_avl_add(avl, box(649), box(559), nullptr); + avl = grpc_avl_add(avl, box(808), box(560), nullptr); + avl = remove_int(avl, 570); + avl = remove_int(avl, 434); + avl = grpc_avl_add(avl, box(40), box(563), nullptr); + avl = grpc_avl_add(avl, box(725), box(564), nullptr); + avl = remove_int(avl, 295); + avl = remove_int(avl, 615); + avl = remove_int(avl, 919); + avl = remove_int(avl, 170); + avl = remove_int(avl, 442); + avl = remove_int(avl, 971); + avl = grpc_avl_add(avl, box(483), box(571), nullptr); + avl = grpc_avl_add(avl, box(512), box(572), nullptr); + avl = remove_int(avl, 648); + avl = remove_int(avl, 78); + avl = remove_int(avl, 72); + avl = remove_int(avl, 790); + avl = remove_int(avl, 571); + avl = grpc_avl_add(avl, box(898), box(578), nullptr); + avl = remove_int(avl, 770); + avl = remove_int(avl, 776); + avl = grpc_avl_add(avl, box(602), box(581), nullptr); + avl = remove_int(avl, 251); + avl = grpc_avl_add(avl, box(303), box(583), nullptr); + avl = remove_int(avl, 837); + avl = grpc_avl_add(avl, box(714), box(585), nullptr); + avl = remove_int(avl, 800); + avl = grpc_avl_add(avl, box(266), box(587), nullptr); + avl = grpc_avl_add(avl, box(555), box(588), nullptr); + avl = remove_int(avl, 604); + avl = remove_int(avl, 163); + avl = remove_int(avl, 497); + avl = grpc_avl_add(avl, box(296), box(592), nullptr); + avl = remove_int(avl, 129); + avl = grpc_avl_add(avl, box(656), box(594), nullptr); + avl = remove_int(avl, 769); + avl = remove_int(avl, 941); + avl = grpc_avl_add(avl, box(775), box(597), nullptr); + avl = grpc_avl_add(avl, box(846), box(598), nullptr); + avl = remove_int(avl, 591); + avl = remove_int(avl, 801); + avl = remove_int(avl, 419); + avl = remove_int(avl, 455); + avl = grpc_avl_add(avl, box(866), box(603), nullptr); + avl = grpc_avl_add(avl, box(575), box(604), nullptr); + avl = grpc_avl_add(avl, box(620), box(605), nullptr); + avl = remove_int(avl, 100); + avl = remove_int(avl, 667); + avl = grpc_avl_add(avl, box(138), box(608), nullptr); + avl = grpc_avl_add(avl, box(566), box(609), nullptr); + avl = grpc_avl_add(avl, box(673), box(610), nullptr); + avl = grpc_avl_add(avl, box(178), box(611), nullptr); + avl = remove_int(avl, 659); + avl = grpc_avl_add(avl, box(759), box(613), nullptr); + avl = grpc_avl_add(avl, box(1008), box(614), nullptr); + avl = remove_int(avl, 116); + avl = grpc_avl_add(avl, box(608), box(616), nullptr); + avl = grpc_avl_add(avl, box(339), box(617), nullptr); + avl = grpc_avl_add(avl, box(197), box(618), nullptr); + avl = remove_int(avl, 25); + avl = remove_int(avl, 628); + avl = grpc_avl_add(avl, box(487), box(621), nullptr); + avl = remove_int(avl, 739); + avl = remove_int(avl, 100); + avl = remove_int(avl, 928); + avl = grpc_avl_add(avl, box(647), box(625), nullptr); + avl = remove_int(avl, 978); + avl = remove_int(avl, 143); + avl = remove_int(avl, 755); + avl = grpc_avl_add(avl, box(71), box(629), nullptr); + avl = remove_int(avl, 205); + avl = grpc_avl_add(avl, box(501), box(631), nullptr); + avl = remove_int(avl, 723); + avl = remove_int(avl, 852); + avl = remove_int(avl, 1021); + avl = remove_int(avl, 670); + avl = remove_int(avl, 500); + avl = grpc_avl_add(avl, box(330), box(637), nullptr); + avl = remove_int(avl, 264); + avl = grpc_avl_add(avl, box(69), box(639), nullptr); + avl = remove_int(avl, 73); + avl = grpc_avl_add(avl, box(745), box(641), nullptr); + avl = remove_int(avl, 518); + avl = remove_int(avl, 641); + avl = remove_int(avl, 768); + avl = grpc_avl_add(avl, box(988), box(645), nullptr); + avl = grpc_avl_add(avl, box(899), box(646), nullptr); + avl = remove_int(avl, 763); + avl = remove_int(avl, 281); + avl = remove_int(avl, 496); + avl = grpc_avl_add(avl, box(445), box(650), nullptr); + avl = remove_int(avl, 905); + avl = grpc_avl_add(avl, box(275), box(652), nullptr); + avl = grpc_avl_add(avl, box(137), box(653), nullptr); + avl = remove_int(avl, 642); + avl = grpc_avl_add(avl, box(708), box(655), nullptr); + avl = remove_int(avl, 922); + avl = grpc_avl_add(avl, box(743), box(657), nullptr); + avl = remove_int(avl, 295); + avl = remove_int(avl, 665); + avl = remove_int(avl, 48); + avl = grpc_avl_add(avl, box(1012), box(661), nullptr); + avl = remove_int(avl, 71); + avl = remove_int(avl, 523); + avl = grpc_avl_add(avl, box(319), box(664), nullptr); + avl = remove_int(avl, 632); + avl = grpc_avl_add(avl, box(137), box(666), nullptr); + avl = grpc_avl_add(avl, box(686), box(667), nullptr); + avl = grpc_avl_add(avl, box(724), box(668), nullptr); + avl = grpc_avl_add(avl, box(952), box(669), nullptr); + avl = grpc_avl_add(avl, box(5), box(670), nullptr); + avl = remove_int(avl, 35); + avl = grpc_avl_add(avl, box(43), box(672), nullptr); + avl = grpc_avl_add(avl, box(320), box(673), nullptr); + avl = grpc_avl_add(avl, box(115), box(674), nullptr); + avl = remove_int(avl, 377); + avl = remove_int(avl, 591); + avl = remove_int(avl, 87); + avl = remove_int(avl, 93); + avl = grpc_avl_add(avl, box(1016), box(679), nullptr); + avl = grpc_avl_add(avl, box(605), box(680), nullptr); + avl = grpc_avl_add(avl, box(152), box(681), nullptr); + avl = grpc_avl_add(avl, box(113), box(682), nullptr); + avl = remove_int(avl, 131); + avl = remove_int(avl, 637); + avl = grpc_avl_add(avl, box(156), box(685), nullptr); + avl = remove_int(avl, 696); + avl = grpc_avl_add(avl, box(546), box(687), nullptr); + avl = remove_int(avl, 970); + avl = remove_int(avl, 53); + avl = remove_int(avl, 827); + avl = remove_int(avl, 224); + avl = remove_int(avl, 796); + avl = remove_int(avl, 34); + avl = remove_int(avl, 922); + avl = remove_int(avl, 277); + avl = remove_int(avl, 650); + avl = remove_int(avl, 222); + avl = remove_int(avl, 244); + avl = remove_int(avl, 576); + avl = remove_int(avl, 413); + avl = grpc_avl_add(avl, box(500), box(701), nullptr); + avl = remove_int(avl, 924); + avl = grpc_avl_add(avl, box(825), box(703), nullptr); + avl = remove_int(avl, 888); + avl = remove_int(avl, 931); + avl = grpc_avl_add(avl, box(285), box(706), nullptr); + avl = remove_int(avl, 62); + avl = remove_int(avl, 444); + avl = remove_int(avl, 946); + avl = grpc_avl_add(avl, box(122), box(710), nullptr); + avl = grpc_avl_add(avl, box(846), box(711), nullptr); + avl = remove_int(avl, 628); + avl = grpc_avl_add(avl, box(511), box(713), nullptr); + avl = grpc_avl_add(avl, box(398), box(714), nullptr); + avl = remove_int(avl, 730); + avl = grpc_avl_add(avl, box(797), box(716), nullptr); + avl = remove_int(avl, 897); + avl = remove_int(avl, 228); + avl = remove_int(avl, 544); + avl = remove_int(avl, 552); + avl = remove_int(avl, 783); + avl = remove_int(avl, 583); + avl = remove_int(avl, 894); + avl = remove_int(avl, 942); + avl = grpc_avl_add(avl, box(346), box(725), nullptr); + avl = grpc_avl_add(avl, box(1015), box(726), nullptr); + avl = remove_int(avl, 813); + avl = grpc_avl_add(avl, box(213), box(728), nullptr); + avl = remove_int(avl, 468); + avl = remove_int(avl, 365); + avl = remove_int(avl, 399); + avl = grpc_avl_add(avl, box(380), box(732), nullptr); + avl = remove_int(avl, 835); + avl = remove_int(avl, 970); + avl = grpc_avl_add(avl, box(700), box(735), nullptr); + avl = grpc_avl_add(avl, box(807), box(736), nullptr); + avl = remove_int(avl, 312); + avl = remove_int(avl, 282); + avl = remove_int(avl, 370); + avl = remove_int(avl, 999); + avl = remove_int(avl, 241); + avl = remove_int(avl, 884); + avl = grpc_avl_add(avl, box(587), box(743), nullptr); + avl = grpc_avl_add(avl, box(332), box(744), nullptr); + avl = remove_int(avl, 686); + avl = remove_int(avl, 206); + avl = remove_int(avl, 835); + avl = grpc_avl_add(avl, box(334), box(748), nullptr); + avl = remove_int(avl, 171); + avl = grpc_avl_add(avl, box(1002), box(750), nullptr); + avl = grpc_avl_add(avl, box(779), box(751), nullptr); + avl = grpc_avl_add(avl, box(307), box(752), nullptr); + avl = grpc_avl_add(avl, box(127), box(753), nullptr); + avl = grpc_avl_add(avl, box(251), box(754), nullptr); + avl = remove_int(avl, 790); + avl = remove_int(avl, 189); + avl = remove_int(avl, 193); + avl = remove_int(avl, 38); + avl = remove_int(avl, 124); + avl = grpc_avl_add(avl, box(812), box(760), nullptr); + avl = remove_int(avl, 43); + avl = grpc_avl_add(avl, box(871), box(762), nullptr); + avl = grpc_avl_add(avl, box(580), box(763), nullptr); + avl = remove_int(avl, 501); + avl = remove_int(avl, 462); + avl = remove_int(avl, 599); + avl = grpc_avl_add(avl, box(240), box(767), nullptr); + avl = grpc_avl_add(avl, box(285), box(768), nullptr); + avl = grpc_avl_add(avl, box(472), box(769), nullptr); + avl = remove_int(avl, 865); + avl = remove_int(avl, 763); + avl = remove_int(avl, 245); + avl = remove_int(avl, 80); + avl = remove_int(avl, 713); + avl = remove_int(avl, 654); + avl = remove_int(avl, 1014); + avl = grpc_avl_add(avl, box(495), box(777), nullptr); + avl = grpc_avl_add(avl, box(552), box(778), nullptr); + avl = remove_int(avl, 19); + avl = remove_int(avl, 803); + avl = grpc_avl_add(avl, box(508), box(781), nullptr); + avl = remove_int(avl, 699); + avl = remove_int(avl, 260); + avl = remove_int(avl, 92); + avl = remove_int(avl, 497); + avl = grpc_avl_add(avl, box(970), box(786), nullptr); + avl = remove_int(avl, 987); + avl = remove_int(avl, 168); + avl = remove_int(avl, 476); + avl = remove_int(avl, 248); + avl = grpc_avl_add(avl, box(358), box(791), nullptr); + avl = remove_int(avl, 804); + avl = remove_int(avl, 77); + avl = remove_int(avl, 905); + avl = remove_int(avl, 362); + avl = grpc_avl_add(avl, box(578), box(796), nullptr); + avl = remove_int(avl, 38); + avl = remove_int(avl, 595); + avl = grpc_avl_add(avl, box(213), box(799), nullptr); + avl = remove_int(avl, 7); + avl = remove_int(avl, 620); + avl = grpc_avl_add(avl, box(946), box(802), nullptr); + avl = remove_int(avl, 145); + avl = grpc_avl_add(avl, box(628), box(804), nullptr); + avl = remove_int(avl, 972); + avl = grpc_avl_add(avl, box(728), box(806), nullptr); + avl = remove_int(avl, 91); + avl = grpc_avl_add(avl, box(136), box(808), nullptr); + avl = grpc_avl_add(avl, box(841), box(809), nullptr); + avl = grpc_avl_add(avl, box(265), box(810), nullptr); + avl = grpc_avl_add(avl, box(701), box(811), nullptr); + avl = grpc_avl_add(avl, box(27), box(812), nullptr); + avl = remove_int(avl, 72); + avl = remove_int(avl, 14); + avl = grpc_avl_add(avl, box(286), box(815), nullptr); + avl = remove_int(avl, 996); + avl = remove_int(avl, 998); + avl = grpc_avl_add(avl, box(466), box(818), nullptr); + avl = remove_int(avl, 1009); + avl = remove_int(avl, 741); + avl = remove_int(avl, 947); + avl = remove_int(avl, 241); + avl = remove_int(avl, 954); + avl = remove_int(avl, 183); + avl = remove_int(avl, 395); + avl = remove_int(avl, 951); + avl = grpc_avl_add(avl, box(267), box(827), nullptr); + avl = remove_int(avl, 812); + avl = grpc_avl_add(avl, box(577), box(829), nullptr); + avl = remove_int(avl, 624); + avl = remove_int(avl, 847); + avl = remove_int(avl, 745); + avl = grpc_avl_add(avl, box(491), box(833), nullptr); + avl = grpc_avl_add(avl, box(941), box(834), nullptr); + avl = remove_int(avl, 258); + avl = grpc_avl_add(avl, box(410), box(836), nullptr); + avl = grpc_avl_add(avl, box(80), box(837), nullptr); + avl = grpc_avl_add(avl, box(196), box(838), nullptr); + avl = grpc_avl_add(avl, box(5), box(839), nullptr); + avl = remove_int(avl, 782); + avl = grpc_avl_add(avl, box(827), box(841), nullptr); + avl = remove_int(avl, 472); + avl = remove_int(avl, 664); + avl = grpc_avl_add(avl, box(409), box(844), nullptr); + avl = grpc_avl_add(avl, box(62), box(845), nullptr); + avl = remove_int(avl, 56); + avl = remove_int(avl, 606); + avl = remove_int(avl, 707); + avl = remove_int(avl, 989); + avl = remove_int(avl, 549); + avl = remove_int(avl, 259); + avl = grpc_avl_add(avl, box(405), box(852), nullptr); + avl = remove_int(avl, 587); + avl = remove_int(avl, 350); + avl = grpc_avl_add(avl, box(980), box(855), nullptr); + avl = grpc_avl_add(avl, box(992), box(856), nullptr); + avl = grpc_avl_add(avl, box(818), box(857), nullptr); + avl = remove_int(avl, 853); + avl = remove_int(avl, 701); + avl = grpc_avl_add(avl, box(675), box(860), nullptr); + avl = remove_int(avl, 248); + avl = remove_int(avl, 649); + avl = grpc_avl_add(avl, box(508), box(863), nullptr); + avl = remove_int(avl, 927); + avl = grpc_avl_add(avl, box(957), box(865), nullptr); + avl = grpc_avl_add(avl, box(698), box(866), nullptr); + avl = grpc_avl_add(avl, box(388), box(867), nullptr); + avl = grpc_avl_add(avl, box(532), box(868), nullptr); + avl = grpc_avl_add(avl, box(681), box(869), nullptr); + avl = remove_int(avl, 544); + avl = remove_int(avl, 991); + avl = remove_int(avl, 397); + avl = grpc_avl_add(avl, box(954), box(873), nullptr); + avl = grpc_avl_add(avl, box(219), box(874), nullptr); + avl = grpc_avl_add(avl, box(465), box(875), nullptr); + avl = remove_int(avl, 371); + avl = grpc_avl_add(avl, box(601), box(877), nullptr); + avl = grpc_avl_add(avl, box(543), box(878), nullptr); + avl = remove_int(avl, 329); + avl = grpc_avl_add(avl, box(560), box(880), nullptr); + avl = remove_int(avl, 898); + avl = grpc_avl_add(avl, box(455), box(882), nullptr); + avl = remove_int(avl, 313); + avl = grpc_avl_add(avl, box(215), box(884), nullptr); + avl = remove_int(avl, 846); + avl = grpc_avl_add(avl, box(608), box(886), nullptr); + avl = remove_int(avl, 248); + avl = grpc_avl_add(avl, box(575), box(888), nullptr); + avl = remove_int(avl, 207); + avl = remove_int(avl, 810); + avl = remove_int(avl, 665); + avl = remove_int(avl, 361); + avl = grpc_avl_add(avl, box(154), box(893), nullptr); + avl = grpc_avl_add(avl, box(329), box(894), nullptr); + avl = grpc_avl_add(avl, box(326), box(895), nullptr); + avl = remove_int(avl, 746); + avl = remove_int(avl, 99); + avl = grpc_avl_add(avl, box(464), box(898), nullptr); + avl = grpc_avl_add(avl, box(141), box(899), nullptr); + avl = remove_int(avl, 383); + avl = grpc_avl_add(avl, box(414), box(901), nullptr); + avl = grpc_avl_add(avl, box(777), box(902), nullptr); + avl = remove_int(avl, 972); + avl = remove_int(avl, 841); + avl = remove_int(avl, 100); + avl = grpc_avl_add(avl, box(828), box(906), nullptr); + avl = remove_int(avl, 785); + avl = grpc_avl_add(avl, box(1008), box(908), nullptr); + avl = grpc_avl_add(avl, box(46), box(909), nullptr); + avl = remove_int(avl, 399); + avl = grpc_avl_add(avl, box(178), box(911), nullptr); + avl = grpc_avl_add(avl, box(573), box(912), nullptr); + avl = remove_int(avl, 299); + avl = grpc_avl_add(avl, box(690), box(914), nullptr); + avl = grpc_avl_add(avl, box(692), box(915), nullptr); + avl = remove_int(avl, 404); + avl = remove_int(avl, 16); + avl = remove_int(avl, 746); + avl = remove_int(avl, 486); + avl = remove_int(avl, 119); + avl = grpc_avl_add(avl, box(167), box(921), nullptr); + avl = remove_int(avl, 328); + avl = grpc_avl_add(avl, box(89), box(923), nullptr); + avl = remove_int(avl, 867); + avl = remove_int(avl, 626); + avl = remove_int(avl, 507); + avl = grpc_avl_add(avl, box(365), box(927), nullptr); + avl = grpc_avl_add(avl, box(58), box(928), nullptr); + avl = grpc_avl_add(avl, box(70), box(929), nullptr); + avl = remove_int(avl, 81); + avl = remove_int(avl, 797); + avl = grpc_avl_add(avl, box(846), box(932), nullptr); + avl = remove_int(avl, 642); + avl = grpc_avl_add(avl, box(777), box(934), nullptr); + avl = remove_int(avl, 107); + avl = grpc_avl_add(avl, box(691), box(936), nullptr); + avl = grpc_avl_add(avl, box(820), box(937), nullptr); + avl = grpc_avl_add(avl, box(202), box(938), nullptr); + avl = grpc_avl_add(avl, box(308), box(939), nullptr); + avl = grpc_avl_add(avl, box(20), box(940), nullptr); + avl = remove_int(avl, 289); + avl = grpc_avl_add(avl, box(714), box(942), nullptr); + avl = grpc_avl_add(avl, box(584), box(943), nullptr); + avl = remove_int(avl, 294); + avl = grpc_avl_add(avl, box(496), box(945), nullptr); + avl = grpc_avl_add(avl, box(394), box(946), nullptr); + avl = grpc_avl_add(avl, box(860), box(947), nullptr); + avl = grpc_avl_add(avl, box(58), box(948), nullptr); + avl = remove_int(avl, 784); + avl = remove_int(avl, 584); + avl = remove_int(avl, 708); + avl = grpc_avl_add(avl, box(142), box(952), nullptr); + avl = grpc_avl_add(avl, box(247), box(953), nullptr); + avl = grpc_avl_add(avl, box(389), box(954), nullptr); + avl = remove_int(avl, 390); + avl = grpc_avl_add(avl, box(465), box(956), nullptr); + avl = grpc_avl_add(avl, box(936), box(957), nullptr); + avl = grpc_avl_add(avl, box(309), box(958), nullptr); + avl = remove_int(avl, 928); + avl = remove_int(avl, 128); + avl = remove_int(avl, 979); + avl = remove_int(avl, 670); + avl = remove_int(avl, 738); + avl = remove_int(avl, 271); + avl = remove_int(avl, 540); + avl = grpc_avl_add(avl, box(365), box(966), nullptr); + avl = remove_int(avl, 82); + avl = grpc_avl_add(avl, box(728), box(968), nullptr); + avl = remove_int(avl, 852); + avl = grpc_avl_add(avl, box(884), box(970), nullptr); + avl = grpc_avl_add(avl, box(502), box(971), nullptr); + avl = remove_int(avl, 898); + avl = remove_int(avl, 481); + avl = grpc_avl_add(avl, box(911), box(974), nullptr); + avl = remove_int(avl, 787); + avl = remove_int(avl, 785); + avl = remove_int(avl, 537); + avl = remove_int(avl, 535); + avl = remove_int(avl, 136); + avl = remove_int(avl, 749); + avl = remove_int(avl, 637); + avl = remove_int(avl, 900); + avl = grpc_avl_add(avl, box(598), box(983), nullptr); + avl = remove_int(avl, 25); + avl = remove_int(avl, 697); + avl = grpc_avl_add(avl, box(645), box(986), nullptr); + avl = grpc_avl_add(avl, box(211), box(987), nullptr); + avl = grpc_avl_add(avl, box(589), box(988), nullptr); + avl = remove_int(avl, 702); + avl = grpc_avl_add(avl, box(53), box(990), nullptr); + avl = remove_int(avl, 492); + avl = remove_int(avl, 185); + avl = remove_int(avl, 246); + avl = remove_int(avl, 257); + avl = remove_int(avl, 502); + avl = remove_int(avl, 34); + avl = grpc_avl_add(avl, box(74), box(997), nullptr); + avl = grpc_avl_add(avl, box(834), box(998), nullptr); + avl = grpc_avl_add(avl, box(514), box(999), nullptr); + avl = grpc_avl_add(avl, box(75), box(1000), nullptr); + avl = remove_int(avl, 745); + avl = grpc_avl_add(avl, box(362), box(1002), nullptr); + avl = remove_int(avl, 215); + avl = grpc_avl_add(avl, box(624), box(1004), nullptr); + avl = remove_int(avl, 404); + avl = remove_int(avl, 359); + avl = remove_int(avl, 491); + avl = grpc_avl_add(avl, box(903), box(1008), nullptr); + avl = grpc_avl_add(avl, box(240), box(1009), nullptr); + avl = remove_int(avl, 95); + avl = grpc_avl_add(avl, box(119), box(1011), nullptr); + avl = grpc_avl_add(avl, box(857), box(1012), nullptr); + avl = remove_int(avl, 39); + avl = remove_int(avl, 866); + avl = grpc_avl_add(avl, box(503), box(1015), nullptr); + avl = grpc_avl_add(avl, box(740), box(1016), nullptr); + avl = remove_int(avl, 637); + avl = remove_int(avl, 156); + avl = remove_int(avl, 6); + avl = remove_int(avl, 745); + avl = remove_int(avl, 433); + avl = remove_int(avl, 283); + avl = grpc_avl_add(avl, box(625), box(1023), nullptr); + avl = remove_int(avl, 638); + avl = grpc_avl_add(avl, box(299), box(1025), nullptr); + avl = grpc_avl_add(avl, box(584), box(1026), nullptr); + avl = remove_int(avl, 863); + avl = grpc_avl_add(avl, box(612), box(1028), nullptr); + avl = grpc_avl_add(avl, box(62), box(1029), nullptr); + avl = grpc_avl_add(avl, box(432), box(1030), nullptr); + avl = remove_int(avl, 371); + avl = remove_int(avl, 790); + avl = remove_int(avl, 227); + avl = remove_int(avl, 836); + avl = grpc_avl_add(avl, box(703), box(1035), nullptr); + avl = grpc_avl_add(avl, box(644), box(1036), nullptr); + avl = remove_int(avl, 638); + avl = grpc_avl_add(avl, box(13), box(1038), nullptr); + avl = remove_int(avl, 66); + avl = remove_int(avl, 82); + avl = grpc_avl_add(avl, box(362), box(1041), nullptr); + avl = grpc_avl_add(avl, box(783), box(1042), nullptr); + avl = remove_int(avl, 60); + avl = grpc_avl_add(avl, box(80), box(1044), nullptr); + avl = grpc_avl_add(avl, box(825), box(1045), nullptr); + avl = grpc_avl_add(avl, box(688), box(1046), nullptr); + avl = grpc_avl_add(avl, box(662), box(1047), nullptr); + avl = remove_int(avl, 156); + avl = remove_int(avl, 376); + avl = remove_int(avl, 99); + avl = grpc_avl_add(avl, box(526), box(1051), nullptr); + avl = grpc_avl_add(avl, box(168), box(1052), nullptr); + avl = remove_int(avl, 646); + avl = remove_int(avl, 380); + avl = remove_int(avl, 833); + avl = grpc_avl_add(avl, box(53), box(1056), nullptr); + avl = remove_int(avl, 105); + avl = grpc_avl_add(avl, box(373), box(1058), nullptr); + avl = grpc_avl_add(avl, box(184), box(1059), nullptr); + avl = remove_int(avl, 288); + avl = grpc_avl_add(avl, box(966), box(1061), nullptr); + avl = remove_int(avl, 158); + avl = grpc_avl_add(avl, box(406), box(1063), nullptr); + avl = remove_int(avl, 470); + avl = grpc_avl_add(avl, box(283), box(1065), nullptr); + avl = grpc_avl_add(avl, box(838), box(1066), nullptr); + avl = grpc_avl_add(avl, box(288), box(1067), nullptr); + avl = grpc_avl_add(avl, box(950), box(1068), nullptr); + avl = grpc_avl_add(avl, box(163), box(1069), nullptr); + avl = remove_int(avl, 623); + avl = remove_int(avl, 769); + avl = grpc_avl_add(avl, box(144), box(1072), nullptr); + avl = grpc_avl_add(avl, box(489), box(1073), nullptr); + avl = remove_int(avl, 15); + avl = grpc_avl_add(avl, box(971), box(1075), nullptr); + avl = remove_int(avl, 660); + avl = grpc_avl_add(avl, box(255), box(1077), nullptr); + avl = remove_int(avl, 494); + avl = grpc_avl_add(avl, box(109), box(1079), nullptr); + avl = grpc_avl_add(avl, box(420), box(1080), nullptr); + avl = grpc_avl_add(avl, box(509), box(1081), nullptr); + avl = remove_int(avl, 178); + avl = grpc_avl_add(avl, box(216), box(1083), nullptr); + avl = grpc_avl_add(avl, box(707), box(1084), nullptr); + avl = grpc_avl_add(avl, box(411), box(1085), nullptr); + avl = grpc_avl_add(avl, box(352), box(1086), nullptr); + avl = remove_int(avl, 983); + avl = grpc_avl_add(avl, box(6), box(1088), nullptr); + avl = grpc_avl_add(avl, box(1014), box(1089), nullptr); + avl = remove_int(avl, 98); + avl = remove_int(avl, 325); + avl = grpc_avl_add(avl, box(851), box(1092), nullptr); + avl = remove_int(avl, 553); + avl = grpc_avl_add(avl, box(218), box(1094), nullptr); + avl = grpc_avl_add(avl, box(261), box(1095), nullptr); + avl = remove_int(avl, 31); + avl = grpc_avl_add(avl, box(872), box(1097), nullptr); + avl = remove_int(avl, 543); + avl = remove_int(avl, 314); + avl = remove_int(avl, 443); + avl = grpc_avl_add(avl, box(533), box(1101), nullptr); + avl = remove_int(avl, 881); + avl = remove_int(avl, 269); + avl = remove_int(avl, 940); + avl = remove_int(avl, 909); + avl = remove_int(avl, 197); + avl = remove_int(avl, 773); + avl = remove_int(avl, 790); + avl = remove_int(avl, 345); + avl = grpc_avl_add(avl, box(965), box(1110), nullptr); + avl = remove_int(avl, 622); + avl = grpc_avl_add(avl, box(352), box(1112), nullptr); + avl = remove_int(avl, 182); + avl = grpc_avl_add(avl, box(534), box(1114), nullptr); + avl = grpc_avl_add(avl, box(97), box(1115), nullptr); + avl = grpc_avl_add(avl, box(198), box(1116), nullptr); + avl = remove_int(avl, 750); + avl = grpc_avl_add(avl, box(98), box(1118), nullptr); + avl = remove_int(avl, 943); + avl = grpc_avl_add(avl, box(254), box(1120), nullptr); + avl = grpc_avl_add(avl, box(30), box(1121), nullptr); + avl = remove_int(avl, 14); + avl = remove_int(avl, 475); + avl = remove_int(avl, 82); + avl = grpc_avl_add(avl, box(789), box(1125), nullptr); + avl = grpc_avl_add(avl, box(402), box(1126), nullptr); + avl = remove_int(avl, 1019); + avl = grpc_avl_add(avl, box(858), box(1128), nullptr); + avl = grpc_avl_add(avl, box(625), box(1129), nullptr); + avl = remove_int(avl, 675); + avl = remove_int(avl, 323); + avl = grpc_avl_add(avl, box(329), box(1132), nullptr); + avl = remove_int(avl, 929); + avl = remove_int(avl, 44); + avl = grpc_avl_add(avl, box(443), box(1135), nullptr); + avl = grpc_avl_add(avl, box(653), box(1136), nullptr); + avl = grpc_avl_add(avl, box(750), box(1137), nullptr); + avl = grpc_avl_add(avl, box(252), box(1138), nullptr); + avl = grpc_avl_add(avl, box(449), box(1139), nullptr); + avl = remove_int(avl, 1022); + avl = remove_int(avl, 357); + avl = remove_int(avl, 602); + avl = remove_int(avl, 131); + avl = grpc_avl_add(avl, box(531), box(1144), nullptr); + avl = remove_int(avl, 806); + avl = grpc_avl_add(avl, box(455), box(1146), nullptr); + avl = remove_int(avl, 31); + avl = grpc_avl_add(avl, box(154), box(1148), nullptr); + avl = grpc_avl_add(avl, box(189), box(1149), nullptr); + avl = remove_int(avl, 786); + avl = grpc_avl_add(avl, box(496), box(1151), nullptr); + avl = grpc_avl_add(avl, box(81), box(1152), nullptr); + avl = grpc_avl_add(avl, box(59), box(1153), nullptr); + avl = remove_int(avl, 424); + avl = remove_int(avl, 668); + avl = grpc_avl_add(avl, box(723), box(1156), nullptr); + avl = grpc_avl_add(avl, box(822), box(1157), nullptr); + avl = grpc_avl_add(avl, box(354), box(1158), nullptr); + avl = remove_int(avl, 738); + avl = grpc_avl_add(avl, box(686), box(1160), nullptr); + avl = grpc_avl_add(avl, box(43), box(1161), nullptr); + avl = grpc_avl_add(avl, box(625), box(1162), nullptr); + avl = grpc_avl_add(avl, box(902), box(1163), nullptr); + avl = grpc_avl_add(avl, box(12), box(1164), nullptr); + avl = grpc_avl_add(avl, box(977), box(1165), nullptr); + avl = grpc_avl_add(avl, box(699), box(1166), nullptr); + avl = grpc_avl_add(avl, box(189), box(1167), nullptr); + avl = remove_int(avl, 672); + avl = remove_int(avl, 90); + avl = remove_int(avl, 757); + avl = remove_int(avl, 494); + avl = grpc_avl_add(avl, box(759), box(1172), nullptr); + avl = remove_int(avl, 758); + avl = remove_int(avl, 222); + avl = grpc_avl_add(avl, box(975), box(1175), nullptr); + avl = remove_int(avl, 993); + avl = grpc_avl_add(avl, box(2), box(1177), nullptr); + avl = grpc_avl_add(avl, box(70), box(1178), nullptr); + avl = remove_int(avl, 350); + avl = remove_int(avl, 972); + avl = remove_int(avl, 880); + avl = grpc_avl_add(avl, box(753), box(1182), nullptr); + avl = remove_int(avl, 404); + avl = grpc_avl_add(avl, box(294), box(1184), nullptr); + avl = remove_int(avl, 474); + avl = grpc_avl_add(avl, box(228), box(1186), nullptr); + avl = grpc_avl_add(avl, box(484), box(1187), nullptr); + avl = remove_int(avl, 238); + avl = remove_int(avl, 53); + avl = remove_int(avl, 691); + avl = grpc_avl_add(avl, box(345), box(1191), nullptr); + avl = remove_int(avl, 0); + avl = grpc_avl_add(avl, box(230), box(1193), nullptr); + avl = remove_int(avl, 227); + avl = remove_int(avl, 152); + avl = grpc_avl_add(avl, box(884), box(1196), nullptr); + avl = remove_int(avl, 823); + avl = remove_int(avl, 53); + avl = grpc_avl_add(avl, box(1015), box(1199), nullptr); + avl = grpc_avl_add(avl, box(697), box(1200), nullptr); + avl = grpc_avl_add(avl, box(376), box(1201), nullptr); + avl = remove_int(avl, 411); + avl = grpc_avl_add(avl, box(888), box(1203), nullptr); + avl = remove_int(avl, 55); + avl = grpc_avl_add(avl, box(85), box(1205), nullptr); + avl = remove_int(avl, 947); + avl = remove_int(avl, 382); + avl = remove_int(avl, 777); + avl = grpc_avl_add(avl, box(1017), box(1209), nullptr); + avl = grpc_avl_add(avl, box(169), box(1210), nullptr); + avl = grpc_avl_add(avl, box(156), box(1211), nullptr); + avl = remove_int(avl, 153); + avl = remove_int(avl, 642); + avl = remove_int(avl, 158); + avl = grpc_avl_add(avl, box(554), box(1215), nullptr); + avl = grpc_avl_add(avl, box(76), box(1216), nullptr); + avl = grpc_avl_add(avl, box(756), box(1217), nullptr); + avl = remove_int(avl, 767); + avl = remove_int(avl, 112); + avl = remove_int(avl, 539); + avl = remove_int(avl, 544); + avl = remove_int(avl, 628); + avl = remove_int(avl, 385); + avl = remove_int(avl, 514); + avl = remove_int(avl, 362); + avl = grpc_avl_add(avl, box(523), box(1226), nullptr); + avl = grpc_avl_add(avl, box(712), box(1227), nullptr); + avl = grpc_avl_add(avl, box(474), box(1228), nullptr); + avl = grpc_avl_add(avl, box(882), box(1229), nullptr); + avl = grpc_avl_add(avl, box(965), box(1230), nullptr); + avl = remove_int(avl, 464); + avl = grpc_avl_add(avl, box(319), box(1232), nullptr); + avl = grpc_avl_add(avl, box(504), box(1233), nullptr); + avl = remove_int(avl, 818); + avl = grpc_avl_add(avl, box(884), box(1235), nullptr); + avl = grpc_avl_add(avl, box(813), box(1236), nullptr); + avl = grpc_avl_add(avl, box(795), box(1237), nullptr); + avl = remove_int(avl, 306); + avl = grpc_avl_add(avl, box(799), box(1239), nullptr); + avl = remove_int(avl, 534); + avl = grpc_avl_add(avl, box(480), box(1241), nullptr); + avl = grpc_avl_add(avl, box(656), box(1242), nullptr); + avl = grpc_avl_add(avl, box(709), box(1243), nullptr); + avl = grpc_avl_add(avl, box(500), box(1244), nullptr); + avl = remove_int(avl, 740); + avl = grpc_avl_add(avl, box(980), box(1246), nullptr); + avl = grpc_avl_add(avl, box(458), box(1247), nullptr); + avl = remove_int(avl, 377); + avl = remove_int(avl, 338); + avl = grpc_avl_add(avl, box(554), box(1250), nullptr); + avl = grpc_avl_add(avl, box(504), box(1251), nullptr); + avl = grpc_avl_add(avl, box(603), box(1252), nullptr); + avl = grpc_avl_add(avl, box(761), box(1253), nullptr); + avl = remove_int(avl, 431); + avl = grpc_avl_add(avl, box(707), box(1255), nullptr); + avl = grpc_avl_add(avl, box(673), box(1256), nullptr); + avl = remove_int(avl, 998); + avl = remove_int(avl, 332); + avl = remove_int(avl, 413); + avl = remove_int(avl, 227); + avl = remove_int(avl, 249); + avl = remove_int(avl, 309); + avl = remove_int(avl, 459); + avl = grpc_avl_add(avl, box(645), box(1264), nullptr); + avl = remove_int(avl, 858); + avl = remove_int(avl, 997); + avl = grpc_avl_add(avl, box(519), box(1267), nullptr); + avl = remove_int(avl, 614); + avl = remove_int(avl, 462); + avl = remove_int(avl, 792); + avl = grpc_avl_add(avl, box(987), box(1271), nullptr); + avl = grpc_avl_add(avl, box(309), box(1272), nullptr); + avl = remove_int(avl, 747); + avl = grpc_avl_add(avl, box(621), box(1274), nullptr); + avl = grpc_avl_add(avl, box(450), box(1275), nullptr); + avl = remove_int(avl, 265); + avl = remove_int(avl, 8); + avl = remove_int(avl, 383); + avl = grpc_avl_add(avl, box(238), box(1279), nullptr); + avl = remove_int(avl, 241); + avl = grpc_avl_add(avl, box(180), box(1281), nullptr); + avl = grpc_avl_add(avl, box(411), box(1282), nullptr); + avl = grpc_avl_add(avl, box(791), box(1283), nullptr); + avl = grpc_avl_add(avl, box(955), box(1284), nullptr); + avl = remove_int(avl, 24); + avl = remove_int(avl, 375); + avl = grpc_avl_add(avl, box(140), box(1287), nullptr); + avl = remove_int(avl, 949); + avl = grpc_avl_add(avl, box(301), box(1289), nullptr); + avl = grpc_avl_add(avl, box(0), box(1290), nullptr); + avl = remove_int(avl, 371); + avl = remove_int(avl, 427); + avl = remove_int(avl, 841); + avl = remove_int(avl, 847); + avl = grpc_avl_add(avl, box(814), box(1295), nullptr); + avl = grpc_avl_add(avl, box(127), box(1296), nullptr); + avl = grpc_avl_add(avl, box(279), box(1297), nullptr); + avl = remove_int(avl, 669); + avl = remove_int(avl, 541); + avl = remove_int(avl, 275); + avl = remove_int(avl, 299); + avl = remove_int(avl, 552); + avl = grpc_avl_add(avl, box(310), box(1303), nullptr); + avl = grpc_avl_add(avl, box(304), box(1304), nullptr); + avl = grpc_avl_add(avl, box(1), box(1305), nullptr); + avl = grpc_avl_add(avl, box(339), box(1306), nullptr); + avl = remove_int(avl, 570); + avl = remove_int(avl, 752); + avl = remove_int(avl, 552); + avl = remove_int(avl, 442); + avl = remove_int(avl, 639); + avl = grpc_avl_add(avl, box(313), box(1312), nullptr); + avl = remove_int(avl, 85); + avl = grpc_avl_add(avl, box(964), box(1314), nullptr); + avl = grpc_avl_add(avl, box(559), box(1315), nullptr); + avl = remove_int(avl, 167); + avl = grpc_avl_add(avl, box(866), box(1317), nullptr); + avl = remove_int(avl, 275); + avl = grpc_avl_add(avl, box(173), box(1319), nullptr); + avl = grpc_avl_add(avl, box(765), box(1320), nullptr); + avl = remove_int(avl, 883); + avl = grpc_avl_add(avl, box(547), box(1322), nullptr); + avl = grpc_avl_add(avl, box(847), box(1323), nullptr); + avl = remove_int(avl, 817); + avl = remove_int(avl, 850); + avl = remove_int(avl, 718); + avl = grpc_avl_add(avl, box(806), box(1327), nullptr); + avl = grpc_avl_add(avl, box(360), box(1328), nullptr); + avl = remove_int(avl, 991); + avl = grpc_avl_add(avl, box(493), box(1330), nullptr); + avl = remove_int(avl, 516); + avl = grpc_avl_add(avl, box(361), box(1332), nullptr); + avl = remove_int(avl, 355); + avl = grpc_avl_add(avl, box(512), box(1334), nullptr); + avl = grpc_avl_add(avl, box(191), box(1335), nullptr); + avl = remove_int(avl, 703); + avl = grpc_avl_add(avl, box(333), box(1337), nullptr); + avl = remove_int(avl, 481); + avl = grpc_avl_add(avl, box(501), box(1339), nullptr); + avl = remove_int(avl, 532); + avl = remove_int(avl, 510); + avl = grpc_avl_add(avl, box(793), box(1342), nullptr); + avl = grpc_avl_add(avl, box(234), box(1343), nullptr); + avl = remove_int(avl, 159); + avl = remove_int(avl, 429); + avl = remove_int(avl, 728); + avl = remove_int(avl, 288); + avl = grpc_avl_add(avl, box(281), box(1348), nullptr); + avl = grpc_avl_add(avl, box(702), box(1349), nullptr); + avl = grpc_avl_add(avl, box(149), box(1350), nullptr); + avl = remove_int(avl, 22); + avl = remove_int(avl, 944); + avl = remove_int(avl, 55); + avl = remove_int(avl, 512); + avl = remove_int(avl, 676); + avl = remove_int(avl, 884); + avl = grpc_avl_add(avl, box(246), box(1357), nullptr); + avl = grpc_avl_add(avl, box(455), box(1358), nullptr); + avl = remove_int(avl, 782); + avl = remove_int(avl, 682); + avl = grpc_avl_add(avl, box(243), box(1361), nullptr); + avl = grpc_avl_add(avl, box(109), box(1362), nullptr); + avl = grpc_avl_add(avl, box(452), box(1363), nullptr); + avl = remove_int(avl, 151); + avl = grpc_avl_add(avl, box(159), box(1365), nullptr); + avl = remove_int(avl, 1023); + avl = grpc_avl_add(avl, box(129), box(1367), nullptr); + avl = grpc_avl_add(avl, box(537), box(1368), nullptr); + avl = remove_int(avl, 321); + avl = grpc_avl_add(avl, box(740), box(1370), nullptr); + avl = remove_int(avl, 45); + avl = remove_int(avl, 136); + avl = grpc_avl_add(avl, box(229), box(1373), nullptr); + avl = remove_int(avl, 772); + avl = grpc_avl_add(avl, box(181), box(1375), nullptr); + avl = remove_int(avl, 175); + avl = grpc_avl_add(avl, box(817), box(1377), nullptr); + avl = remove_int(avl, 956); + avl = grpc_avl_add(avl, box(675), box(1379), nullptr); + avl = grpc_avl_add(avl, box(375), box(1380), nullptr); + avl = remove_int(avl, 384); + avl = grpc_avl_add(avl, box(1016), box(1382), nullptr); + avl = remove_int(avl, 295); + avl = remove_int(avl, 697); + avl = remove_int(avl, 554); + avl = remove_int(avl, 590); + avl = remove_int(avl, 1014); + avl = grpc_avl_add(avl, box(890), box(1388), nullptr); + avl = grpc_avl_add(avl, box(293), box(1389), nullptr); + avl = remove_int(avl, 207); + avl = remove_int(avl, 46); + avl = grpc_avl_add(avl, box(899), box(1392), nullptr); + avl = grpc_avl_add(avl, box(666), box(1393), nullptr); + avl = grpc_avl_add(avl, box(85), box(1394), nullptr); + avl = grpc_avl_add(avl, box(914), box(1395), nullptr); + avl = grpc_avl_add(avl, box(128), box(1396), nullptr); + avl = grpc_avl_add(avl, box(835), box(1397), nullptr); + avl = grpc_avl_add(avl, box(787), box(1398), nullptr); + avl = grpc_avl_add(avl, box(649), box(1399), nullptr); + avl = grpc_avl_add(avl, box(723), box(1400), nullptr); + avl = remove_int(avl, 874); + avl = grpc_avl_add(avl, box(778), box(1402), nullptr); + avl = grpc_avl_add(avl, box(1015), box(1403), nullptr); + avl = grpc_avl_add(avl, box(59), box(1404), nullptr); + avl = grpc_avl_add(avl, box(259), box(1405), nullptr); + avl = grpc_avl_add(avl, box(758), box(1406), nullptr); + avl = remove_int(avl, 648); + avl = grpc_avl_add(avl, box(145), box(1408), nullptr); + avl = grpc_avl_add(avl, box(440), box(1409), nullptr); + avl = remove_int(avl, 608); + avl = remove_int(avl, 690); + avl = grpc_avl_add(avl, box(605), box(1412), nullptr); + avl = remove_int(avl, 856); + avl = remove_int(avl, 608); + avl = grpc_avl_add(avl, box(829), box(1415), nullptr); + avl = grpc_avl_add(avl, box(660), box(1416), nullptr); + avl = remove_int(avl, 596); + avl = grpc_avl_add(avl, box(519), box(1418), nullptr); + avl = grpc_avl_add(avl, box(35), box(1419), nullptr); + avl = grpc_avl_add(avl, box(871), box(1420), nullptr); + avl = remove_int(avl, 845); + avl = grpc_avl_add(avl, box(600), box(1422), nullptr); + avl = grpc_avl_add(avl, box(215), box(1423), nullptr); + avl = remove_int(avl, 761); + avl = grpc_avl_add(avl, box(975), box(1425), nullptr); + avl = remove_int(avl, 987); + avl = grpc_avl_add(avl, box(58), box(1427), nullptr); + avl = remove_int(avl, 119); + avl = grpc_avl_add(avl, box(937), box(1429), nullptr); + avl = grpc_avl_add(avl, box(372), box(1430), nullptr); + avl = grpc_avl_add(avl, box(11), box(1431), nullptr); + avl = grpc_avl_add(avl, box(398), box(1432), nullptr); + avl = grpc_avl_add(avl, box(423), box(1433), nullptr); + avl = remove_int(avl, 171); + avl = grpc_avl_add(avl, box(473), box(1435), nullptr); + avl = remove_int(avl, 752); + avl = remove_int(avl, 625); + avl = remove_int(avl, 764); + avl = remove_int(avl, 49); + avl = grpc_avl_add(avl, box(472), box(1440), nullptr); + avl = remove_int(avl, 847); + avl = remove_int(avl, 642); + avl = remove_int(avl, 1004); + avl = remove_int(avl, 795); + avl = remove_int(avl, 465); + avl = grpc_avl_add(avl, box(636), box(1446), nullptr); + avl = remove_int(avl, 152); + avl = grpc_avl_add(avl, box(61), box(1448), nullptr); + avl = remove_int(avl, 929); + avl = remove_int(avl, 9); + avl = grpc_avl_add(avl, box(251), box(1451), nullptr); + avl = grpc_avl_add(avl, box(672), box(1452), nullptr); + avl = grpc_avl_add(avl, box(66), box(1453), nullptr); + avl = remove_int(avl, 693); + avl = remove_int(avl, 914); + avl = remove_int(avl, 116); + avl = remove_int(avl, 577); + avl = grpc_avl_add(avl, box(618), box(1458), nullptr); + avl = grpc_avl_add(avl, box(495), box(1459), nullptr); + avl = remove_int(avl, 450); + avl = grpc_avl_add(avl, box(533), box(1461), nullptr); + avl = grpc_avl_add(avl, box(414), box(1462), nullptr); + avl = remove_int(avl, 74); + avl = remove_int(avl, 236); + avl = grpc_avl_add(avl, box(707), box(1465), nullptr); + avl = grpc_avl_add(avl, box(357), box(1466), nullptr); + avl = grpc_avl_add(avl, box(1007), box(1467), nullptr); + avl = grpc_avl_add(avl, box(811), box(1468), nullptr); + avl = grpc_avl_add(avl, box(418), box(1469), nullptr); + avl = grpc_avl_add(avl, box(164), box(1470), nullptr); + avl = grpc_avl_add(avl, box(622), box(1471), nullptr); + avl = remove_int(avl, 22); + avl = remove_int(avl, 14); + avl = remove_int(avl, 732); + avl = remove_int(avl, 7); + avl = remove_int(avl, 447); + avl = grpc_avl_add(avl, box(221), box(1477), nullptr); + avl = grpc_avl_add(avl, box(202), box(1478), nullptr); + avl = grpc_avl_add(avl, box(312), box(1479), nullptr); + avl = remove_int(avl, 274); + avl = grpc_avl_add(avl, box(684), box(1481), nullptr); + avl = grpc_avl_add(avl, box(954), box(1482), nullptr); + avl = grpc_avl_add(avl, box(637), box(1483), nullptr); + avl = remove_int(avl, 716); + avl = grpc_avl_add(avl, box(198), box(1485), nullptr); + avl = remove_int(avl, 340); + avl = remove_int(avl, 137); + avl = remove_int(avl, 995); + avl = remove_int(avl, 1004); + avl = grpc_avl_add(avl, box(661), box(1490), nullptr); + avl = grpc_avl_add(avl, box(862), box(1491), nullptr); + avl = remove_int(avl, 527); + avl = grpc_avl_add(avl, box(945), box(1493), nullptr); + avl = remove_int(avl, 355); + avl = remove_int(avl, 144); + avl = grpc_avl_add(avl, box(229), box(1496), nullptr); + avl = grpc_avl_add(avl, box(237), box(1497), nullptr); + avl = remove_int(avl, 471); + avl = remove_int(avl, 901); + avl = grpc_avl_add(avl, box(905), box(1500), nullptr); + avl = remove_int(avl, 19); + avl = remove_int(avl, 896); + avl = remove_int(avl, 585); + avl = remove_int(avl, 308); + avl = grpc_avl_add(avl, box(547), box(1505), nullptr); + avl = grpc_avl_add(avl, box(552), box(1506), nullptr); + avl = grpc_avl_add(avl, box(30), box(1507), nullptr); + avl = grpc_avl_add(avl, box(445), box(1508), nullptr); + avl = remove_int(avl, 785); + avl = remove_int(avl, 185); + avl = grpc_avl_add(avl, box(405), box(1511), nullptr); + avl = grpc_avl_add(avl, box(733), box(1512), nullptr); + avl = grpc_avl_add(avl, box(573), box(1513), nullptr); + avl = grpc_avl_add(avl, box(492), box(1514), nullptr); + avl = grpc_avl_add(avl, box(343), box(1515), nullptr); + avl = grpc_avl_add(avl, box(527), box(1516), nullptr); + avl = grpc_avl_add(avl, box(596), box(1517), nullptr); + avl = grpc_avl_add(avl, box(519), box(1518), nullptr); + avl = remove_int(avl, 243); + avl = remove_int(avl, 722); + avl = grpc_avl_add(avl, box(772), box(1521), nullptr); + avl = remove_int(avl, 152); + avl = remove_int(avl, 305); + avl = grpc_avl_add(avl, box(754), box(1524), nullptr); + avl = grpc_avl_add(avl, box(373), box(1525), nullptr); + avl = remove_int(avl, 995); + avl = grpc_avl_add(avl, box(329), box(1527), nullptr); + avl = remove_int(avl, 397); + avl = grpc_avl_add(avl, box(884), box(1529), nullptr); + avl = remove_int(avl, 329); + avl = remove_int(avl, 240); + avl = grpc_avl_add(avl, box(566), box(1532), nullptr); + avl = grpc_avl_add(avl, box(232), box(1533), nullptr); + avl = remove_int(avl, 993); + avl = grpc_avl_add(avl, box(888), box(1535), nullptr); + avl = remove_int(avl, 242); + avl = grpc_avl_add(avl, box(941), box(1537), nullptr); + avl = remove_int(avl, 415); + avl = grpc_avl_add(avl, box(992), box(1539), nullptr); + avl = remove_int(avl, 289); + avl = grpc_avl_add(avl, box(60), box(1541), nullptr); + avl = grpc_avl_add(avl, box(97), box(1542), nullptr); + avl = remove_int(avl, 965); + avl = remove_int(avl, 267); + avl = remove_int(avl, 360); + avl = grpc_avl_add(avl, box(5), box(1546), nullptr); + avl = remove_int(avl, 429); + avl = grpc_avl_add(avl, box(412), box(1548), nullptr); + avl = remove_int(avl, 632); + avl = remove_int(avl, 113); + avl = grpc_avl_add(avl, box(48), box(1551), nullptr); + avl = grpc_avl_add(avl, box(108), box(1552), nullptr); + avl = grpc_avl_add(avl, box(750), box(1553), nullptr); + avl = remove_int(avl, 188); + avl = grpc_avl_add(avl, box(668), box(1555), nullptr); + avl = remove_int(avl, 37); + avl = remove_int(avl, 737); + avl = grpc_avl_add(avl, box(93), box(1558), nullptr); + avl = grpc_avl_add(avl, box(628), box(1559), nullptr); + avl = grpc_avl_add(avl, box(480), box(1560), nullptr); + avl = remove_int(avl, 958); + avl = remove_int(avl, 565); + avl = remove_int(avl, 32); + avl = remove_int(avl, 1); + avl = remove_int(avl, 335); + avl = grpc_avl_add(avl, box(136), box(1566), nullptr); + avl = grpc_avl_add(avl, box(469), box(1567), nullptr); + avl = remove_int(avl, 349); + avl = grpc_avl_add(avl, box(768), box(1569), nullptr); + avl = grpc_avl_add(avl, box(915), box(1570), nullptr); + avl = remove_int(avl, 1014); + avl = grpc_avl_add(avl, box(117), box(1572), nullptr); + avl = remove_int(avl, 62); + avl = grpc_avl_add(avl, box(382), box(1574), nullptr); + avl = remove_int(avl, 571); + avl = grpc_avl_add(avl, box(655), box(1576), nullptr); + avl = grpc_avl_add(avl, box(323), box(1577), nullptr); + avl = remove_int(avl, 869); + avl = remove_int(avl, 151); + avl = grpc_avl_add(avl, box(1019), box(1580), nullptr); + avl = grpc_avl_add(avl, box(984), box(1581), nullptr); + avl = grpc_avl_add(avl, box(870), box(1582), nullptr); + avl = grpc_avl_add(avl, box(376), box(1583), nullptr); + avl = remove_int(avl, 625); + avl = grpc_avl_add(avl, box(733), box(1585), nullptr); + avl = remove_int(avl, 532); + avl = remove_int(avl, 444); + avl = grpc_avl_add(avl, box(428), box(1588), nullptr); + avl = grpc_avl_add(avl, box(860), box(1589), nullptr); + avl = grpc_avl_add(avl, box(173), box(1590), nullptr); + avl = remove_int(avl, 649); + avl = remove_int(avl, 913); + avl = remove_int(avl, 1); + avl = remove_int(avl, 304); + avl = grpc_avl_add(avl, box(604), box(1595), nullptr); + avl = grpc_avl_add(avl, box(639), box(1596), nullptr); + avl = remove_int(avl, 431); + avl = grpc_avl_add(avl, box(993), box(1598), nullptr); + avl = remove_int(avl, 681); + avl = remove_int(avl, 927); + avl = grpc_avl_add(avl, box(87), box(1601), nullptr); + avl = grpc_avl_add(avl, box(91), box(1602), nullptr); + avl = remove_int(avl, 61); + avl = remove_int(avl, 14); + avl = remove_int(avl, 305); + avl = remove_int(avl, 304); + avl = remove_int(avl, 1016); + avl = grpc_avl_add(avl, box(903), box(1608), nullptr); + avl = grpc_avl_add(avl, box(951), box(1609), nullptr); + avl = grpc_avl_add(avl, box(146), box(1610), nullptr); + avl = grpc_avl_add(avl, box(482), box(1611), nullptr); + avl = grpc_avl_add(avl, box(71), box(1612), nullptr); + avl = remove_int(avl, 246); + avl = remove_int(avl, 696); + avl = grpc_avl_add(avl, box(636), box(1615), nullptr); + avl = grpc_avl_add(avl, box(295), box(1616), nullptr); + avl = remove_int(avl, 11); + avl = remove_int(avl, 231); + avl = grpc_avl_add(avl, box(905), box(1619), nullptr); + avl = grpc_avl_add(avl, box(993), box(1620), nullptr); + avl = grpc_avl_add(avl, box(433), box(1621), nullptr); + avl = grpc_avl_add(avl, box(117), box(1622), nullptr); + avl = grpc_avl_add(avl, box(467), box(1623), nullptr); + avl = remove_int(avl, 419); + avl = grpc_avl_add(avl, box(179), box(1625), nullptr); + avl = remove_int(avl, 926); + avl = remove_int(avl, 326); + avl = grpc_avl_add(avl, box(551), box(1628), nullptr); + avl = remove_int(avl, 14); + avl = remove_int(avl, 476); + avl = remove_int(avl, 823); + avl = grpc_avl_add(avl, box(350), box(1632), nullptr); + avl = grpc_avl_add(avl, box(133), box(1633), nullptr); + avl = remove_int(avl, 906); + avl = grpc_avl_add(avl, box(827), box(1635), nullptr); + avl = grpc_avl_add(avl, box(201), box(1636), nullptr); + avl = remove_int(avl, 124); + avl = remove_int(avl, 662); + avl = grpc_avl_add(avl, box(314), box(1639), nullptr); + avl = grpc_avl_add(avl, box(986), box(1640), nullptr); + avl = grpc_avl_add(avl, box(622), box(1641), nullptr); + avl = remove_int(avl, 130); + avl = grpc_avl_add(avl, box(861), box(1643), nullptr); + avl = remove_int(avl, 497); + avl = remove_int(avl, 905); + avl = grpc_avl_add(avl, box(502), box(1646), nullptr); + avl = remove_int(avl, 721); + avl = grpc_avl_add(avl, box(514), box(1648), nullptr); + avl = grpc_avl_add(avl, box(410), box(1649), nullptr); + avl = remove_int(avl, 869); + avl = remove_int(avl, 247); + avl = grpc_avl_add(avl, box(450), box(1652), nullptr); + avl = remove_int(avl, 364); + avl = grpc_avl_add(avl, box(963), box(1654), nullptr); + avl = grpc_avl_add(avl, box(146), box(1655), nullptr); + avl = remove_int(avl, 147); + avl = remove_int(avl, 789); + avl = grpc_avl_add(avl, box(693), box(1658), nullptr); + avl = grpc_avl_add(avl, box(959), box(1659), nullptr); + avl = remove_int(avl, 478); + avl = grpc_avl_add(avl, box(116), box(1661), nullptr); + avl = grpc_avl_add(avl, box(520), box(1662), nullptr); + avl = grpc_avl_add(avl, box(809), box(1663), nullptr); + avl = grpc_avl_add(avl, box(667), box(1664), nullptr); + avl = grpc_avl_add(avl, box(406), box(1665), nullptr); + avl = remove_int(avl, 409); + avl = grpc_avl_add(avl, box(558), box(1667), nullptr); + avl = grpc_avl_add(avl, box(0), box(1668), nullptr); + avl = grpc_avl_add(avl, box(948), box(1669), nullptr); + avl = grpc_avl_add(avl, box(576), box(1670), nullptr); + avl = remove_int(avl, 864); + avl = remove_int(avl, 840); + avl = remove_int(avl, 1001); + avl = grpc_avl_add(avl, box(232), box(1674), nullptr); + avl = remove_int(avl, 676); + avl = remove_int(avl, 752); + avl = remove_int(avl, 667); + avl = remove_int(avl, 605); + avl = grpc_avl_add(avl, box(258), box(1679), nullptr); + avl = grpc_avl_add(avl, box(648), box(1680), nullptr); + avl = grpc_avl_add(avl, box(761), box(1681), nullptr); + avl = remove_int(avl, 293); + avl = remove_int(avl, 893); + avl = grpc_avl_add(avl, box(194), box(1684), nullptr); + avl = remove_int(avl, 233); + avl = grpc_avl_add(avl, box(888), box(1686), nullptr); + avl = remove_int(avl, 470); + avl = remove_int(avl, 703); + avl = remove_int(avl, 190); + avl = remove_int(avl, 359); + avl = grpc_avl_add(avl, box(621), box(1691), nullptr); + avl = remove_int(avl, 634); + avl = remove_int(avl, 335); + avl = grpc_avl_add(avl, box(718), box(1694), nullptr); + avl = grpc_avl_add(avl, box(463), box(1695), nullptr); + avl = grpc_avl_add(avl, box(233), box(1696), nullptr); + avl = remove_int(avl, 376); + avl = remove_int(avl, 496); + avl = remove_int(avl, 819); + avl = remove_int(avl, 38); + avl = remove_int(avl, 436); + avl = remove_int(avl, 102); + avl = grpc_avl_add(avl, box(607), box(1703), nullptr); + avl = remove_int(avl, 329); + avl = grpc_avl_add(avl, box(716), box(1705), nullptr); + avl = remove_int(avl, 639); + avl = remove_int(avl, 775); + avl = remove_int(avl, 578); + avl = remove_int(avl, 464); + avl = remove_int(avl, 679); + avl = remove_int(avl, 615); + avl = remove_int(avl, 104); + avl = grpc_avl_add(avl, box(414), box(1713), nullptr); + avl = grpc_avl_add(avl, box(212), box(1714), nullptr); + avl = grpc_avl_add(avl, box(266), box(1715), nullptr); + avl = grpc_avl_add(avl, box(238), box(1716), nullptr); + avl = remove_int(avl, 153); + avl = grpc_avl_add(avl, box(585), box(1718), nullptr); + avl = remove_int(avl, 121); + avl = grpc_avl_add(avl, box(534), box(1720), nullptr); + avl = remove_int(avl, 579); + avl = grpc_avl_add(avl, box(127), box(1722), nullptr); + avl = grpc_avl_add(avl, box(399), box(1723), nullptr); + avl = remove_int(avl, 417); + avl = grpc_avl_add(avl, box(978), box(1725), nullptr); + avl = grpc_avl_add(avl, box(768), box(1726), nullptr); + avl = remove_int(avl, 985); + avl = grpc_avl_add(avl, box(536), box(1728), nullptr); + avl = grpc_avl_add(avl, box(449), box(1729), nullptr); + avl = grpc_avl_add(avl, box(586), box(1730), nullptr); + avl = remove_int(avl, 998); + avl = remove_int(avl, 394); + avl = remove_int(avl, 141); + avl = grpc_avl_add(avl, box(889), box(1734), nullptr); + avl = grpc_avl_add(avl, box(871), box(1735), nullptr); + avl = grpc_avl_add(avl, box(76), box(1736), nullptr); + avl = grpc_avl_add(avl, box(549), box(1737), nullptr); + avl = grpc_avl_add(avl, box(757), box(1738), nullptr); + avl = remove_int(avl, 908); + avl = grpc_avl_add(avl, box(789), box(1740), nullptr); + avl = remove_int(avl, 224); + avl = grpc_avl_add(avl, box(407), box(1742), nullptr); + avl = grpc_avl_add(avl, box(381), box(1743), nullptr); + avl = grpc_avl_add(avl, box(561), box(1744), nullptr); + avl = grpc_avl_add(avl, box(667), box(1745), nullptr); + avl = grpc_avl_add(avl, box(522), box(1746), nullptr); + avl = grpc_avl_add(avl, box(948), box(1747), nullptr); + avl = remove_int(avl, 770); + avl = grpc_avl_add(avl, box(872), box(1749), nullptr); + avl = grpc_avl_add(avl, box(327), box(1750), nullptr); + avl = remove_int(avl, 10); + avl = grpc_avl_add(avl, box(122), box(1752), nullptr); + avl = remove_int(avl, 606); + avl = grpc_avl_add(avl, box(485), box(1754), nullptr); + avl = remove_int(avl, 6); + avl = grpc_avl_add(avl, box(329), box(1756), nullptr); + avl = grpc_avl_add(avl, box(783), box(1757), nullptr); + avl = remove_int(avl, 416); + avl = grpc_avl_add(avl, box(656), box(1759), nullptr); + avl = grpc_avl_add(avl, box(971), box(1760), nullptr); + avl = grpc_avl_add(avl, box(77), box(1761), nullptr); + avl = grpc_avl_add(avl, box(942), box(1762), nullptr); + avl = remove_int(avl, 361); + avl = grpc_avl_add(avl, box(66), box(1764), nullptr); + avl = grpc_avl_add(avl, box(299), box(1765), nullptr); + avl = grpc_avl_add(avl, box(929), box(1766), nullptr); + avl = grpc_avl_add(avl, box(797), box(1767), nullptr); + avl = remove_int(avl, 869); + avl = remove_int(avl, 907); + avl = grpc_avl_add(avl, box(870), box(1770), nullptr); + avl = remove_int(avl, 580); + avl = remove_int(avl, 120); + avl = grpc_avl_add(avl, box(913), box(1773), nullptr); + avl = remove_int(avl, 480); + avl = grpc_avl_add(avl, box(489), box(1775), nullptr); + avl = remove_int(avl, 845); + avl = grpc_avl_add(avl, box(896), box(1777), nullptr); + avl = remove_int(avl, 567); + avl = remove_int(avl, 427); + avl = grpc_avl_add(avl, box(443), box(1780), nullptr); + avl = grpc_avl_add(avl, box(3), box(1781), nullptr); + avl = remove_int(avl, 12); + avl = grpc_avl_add(avl, box(376), box(1783), nullptr); + avl = grpc_avl_add(avl, box(155), box(1784), nullptr); + avl = grpc_avl_add(avl, box(188), box(1785), nullptr); + avl = grpc_avl_add(avl, box(149), box(1786), nullptr); + avl = grpc_avl_add(avl, box(178), box(1787), nullptr); + avl = remove_int(avl, 84); + avl = grpc_avl_add(avl, box(805), box(1789), nullptr); + avl = grpc_avl_add(avl, box(612), box(1790), nullptr); + avl = remove_int(avl, 991); + avl = grpc_avl_add(avl, box(837), box(1792), nullptr); + avl = remove_int(avl, 173); + avl = remove_int(avl, 72); + avl = grpc_avl_add(avl, box(1014), box(1795), nullptr); + avl = remove_int(avl, 303); + avl = grpc_avl_add(avl, box(865), box(1797), nullptr); + avl = grpc_avl_add(avl, box(793), box(1798), nullptr); + avl = remove_int(avl, 173); + avl = remove_int(avl, 477); + avl = grpc_avl_add(avl, box(950), box(1801), nullptr); + avl = grpc_avl_add(avl, box(105), box(1802), nullptr); + avl = grpc_avl_add(avl, box(895), box(1803), nullptr); + avl = grpc_avl_add(avl, box(171), box(1804), nullptr); + avl = grpc_avl_add(avl, box(753), box(1805), nullptr); + avl = grpc_avl_add(avl, box(946), box(1806), nullptr); + avl = remove_int(avl, 194); + avl = remove_int(avl, 559); + avl = remove_int(avl, 116); + avl = grpc_avl_add(avl, box(968), box(1810), nullptr); + avl = remove_int(avl, 124); + avl = remove_int(avl, 99); + avl = grpc_avl_add(avl, box(563), box(1813), nullptr); + avl = remove_int(avl, 182); + avl = grpc_avl_add(avl, box(816), box(1815), nullptr); + avl = remove_int(avl, 73); + avl = remove_int(avl, 261); + avl = grpc_avl_add(avl, box(847), box(1818), nullptr); + avl = grpc_avl_add(avl, box(368), box(1819), nullptr); + avl = grpc_avl_add(avl, box(808), box(1820), nullptr); + avl = grpc_avl_add(avl, box(779), box(1821), nullptr); + avl = remove_int(avl, 818); + avl = grpc_avl_add(avl, box(466), box(1823), nullptr); + avl = remove_int(avl, 316); + avl = grpc_avl_add(avl, box(986), box(1825), nullptr); + avl = grpc_avl_add(avl, box(688), box(1826), nullptr); + avl = grpc_avl_add(avl, box(509), box(1827), nullptr); + avl = grpc_avl_add(avl, box(51), box(1828), nullptr); + avl = remove_int(avl, 655); + avl = remove_int(avl, 785); + avl = remove_int(avl, 893); + avl = grpc_avl_add(avl, box(167), box(1832), nullptr); + avl = remove_int(avl, 13); + avl = remove_int(avl, 263); + avl = grpc_avl_add(avl, box(1009), box(1835), nullptr); + avl = remove_int(avl, 480); + avl = remove_int(avl, 778); + avl = remove_int(avl, 713); + avl = remove_int(avl, 628); + avl = grpc_avl_add(avl, box(803), box(1840), nullptr); + avl = remove_int(avl, 267); + avl = grpc_avl_add(avl, box(676), box(1842), nullptr); + avl = grpc_avl_add(avl, box(231), box(1843), nullptr); + avl = grpc_avl_add(avl, box(824), box(1844), nullptr); + avl = remove_int(avl, 961); + avl = grpc_avl_add(avl, box(311), box(1846), nullptr); + avl = grpc_avl_add(avl, box(420), box(1847), nullptr); + avl = grpc_avl_add(avl, box(960), box(1848), nullptr); + avl = grpc_avl_add(avl, box(468), box(1849), nullptr); + avl = grpc_avl_add(avl, box(815), box(1850), nullptr); + avl = remove_int(avl, 247); + avl = remove_int(avl, 194); + avl = grpc_avl_add(avl, box(546), box(1853), nullptr); + avl = remove_int(avl, 222); + avl = remove_int(avl, 914); + avl = remove_int(avl, 741); + avl = grpc_avl_add(avl, box(470), box(1857), nullptr); + avl = grpc_avl_add(avl, box(933), box(1858), nullptr); + avl = grpc_avl_add(avl, box(97), box(1859), nullptr); + avl = remove_int(avl, 564); + avl = remove_int(avl, 295); + avl = grpc_avl_add(avl, box(864), box(1862), nullptr); + avl = remove_int(avl, 329); + avl = grpc_avl_add(avl, box(124), box(1864), nullptr); + avl = grpc_avl_add(avl, box(1000), box(1865), nullptr); + avl = grpc_avl_add(avl, box(228), box(1866), nullptr); + avl = grpc_avl_add(avl, box(187), box(1867), nullptr); + avl = remove_int(avl, 224); + avl = remove_int(avl, 306); + avl = remove_int(avl, 884); + avl = grpc_avl_add(avl, box(449), box(1871), nullptr); + avl = grpc_avl_add(avl, box(353), box(1872), nullptr); + avl = grpc_avl_add(avl, box(994), box(1873), nullptr); + avl = grpc_avl_add(avl, box(596), box(1874), nullptr); + avl = grpc_avl_add(avl, box(996), box(1875), nullptr); + avl = grpc_avl_add(avl, box(101), box(1876), nullptr); + avl = grpc_avl_add(avl, box(1012), box(1877), nullptr); + avl = grpc_avl_add(avl, box(982), box(1878), nullptr); + avl = grpc_avl_add(avl, box(742), box(1879), nullptr); + avl = remove_int(avl, 92); + avl = remove_int(avl, 1022); + avl = grpc_avl_add(avl, box(941), box(1882), nullptr); + avl = remove_int(avl, 742); + avl = remove_int(avl, 919); + avl = grpc_avl_add(avl, box(588), box(1885), nullptr); + avl = remove_int(avl, 221); + avl = grpc_avl_add(avl, box(356), box(1887), nullptr); + avl = grpc_avl_add(avl, box(932), box(1888), nullptr); + avl = remove_int(avl, 837); + avl = grpc_avl_add(avl, box(394), box(1890), nullptr); + avl = grpc_avl_add(avl, box(642), box(1891), nullptr); + avl = grpc_avl_add(avl, box(52), box(1892), nullptr); + avl = grpc_avl_add(avl, box(437), box(1893), nullptr); + avl = grpc_avl_add(avl, box(948), box(1894), nullptr); + avl = grpc_avl_add(avl, box(93), box(1895), nullptr); + avl = remove_int(avl, 873); + avl = remove_int(avl, 336); + avl = remove_int(avl, 277); + avl = remove_int(avl, 932); + avl = grpc_avl_add(avl, box(80), box(1900), nullptr); + avl = grpc_avl_add(avl, box(952), box(1901), nullptr); + avl = grpc_avl_add(avl, box(510), box(1902), nullptr); + avl = remove_int(avl, 876); + avl = remove_int(avl, 612); + avl = grpc_avl_add(avl, box(923), box(1905), nullptr); + avl = grpc_avl_add(avl, box(475), box(1906), nullptr); + avl = remove_int(avl, 478); + avl = remove_int(avl, 148); + avl = grpc_avl_add(avl, box(538), box(1909), nullptr); + avl = remove_int(avl, 47); + avl = grpc_avl_add(avl, box(89), box(1911), nullptr); + avl = remove_int(avl, 723); + avl = grpc_avl_add(avl, box(687), box(1913), nullptr); + avl = grpc_avl_add(avl, box(480), box(1914), nullptr); + avl = grpc_avl_add(avl, box(149), box(1915), nullptr); + avl = remove_int(avl, 68); + avl = remove_int(avl, 862); + avl = remove_int(avl, 363); + avl = grpc_avl_add(avl, box(996), box(1919), nullptr); + avl = remove_int(avl, 380); + avl = grpc_avl_add(avl, box(957), box(1921), nullptr); + avl = remove_int(avl, 413); + avl = grpc_avl_add(avl, box(360), box(1923), nullptr); + avl = grpc_avl_add(avl, box(304), box(1924), nullptr); + avl = grpc_avl_add(avl, box(634), box(1925), nullptr); + avl = grpc_avl_add(avl, box(506), box(1926), nullptr); + avl = remove_int(avl, 248); + avl = grpc_avl_add(avl, box(124), box(1928), nullptr); + avl = grpc_avl_add(avl, box(181), box(1929), nullptr); + avl = remove_int(avl, 507); + avl = grpc_avl_add(avl, box(141), box(1931), nullptr); + avl = remove_int(avl, 409); + avl = remove_int(avl, 129); + avl = remove_int(avl, 694); + avl = remove_int(avl, 723); + avl = grpc_avl_add(avl, box(998), box(1936), nullptr); + avl = grpc_avl_add(avl, box(906), box(1937), nullptr); + avl = grpc_avl_add(avl, box(44), box(1938), nullptr); + avl = remove_int(avl, 949); + avl = remove_int(avl, 117); + avl = grpc_avl_add(avl, box(700), box(1941), nullptr); + avl = grpc_avl_add(avl, box(258), box(1942), nullptr); + avl = remove_int(avl, 828); + avl = grpc_avl_add(avl, box(860), box(1944), nullptr); + avl = grpc_avl_add(avl, box(987), box(1945), nullptr); + avl = grpc_avl_add(avl, box(316), box(1946), nullptr); + avl = grpc_avl_add(avl, box(919), box(1947), nullptr); + avl = remove_int(avl, 84); + avl = grpc_avl_add(avl, box(473), box(1949), nullptr); + avl = remove_int(avl, 127); + avl = remove_int(avl, 829); + avl = remove_int(avl, 829); + avl = grpc_avl_add(avl, box(488), box(1953), nullptr); + avl = grpc_avl_add(avl, box(954), box(1954), nullptr); + avl = remove_int(avl, 198); + avl = remove_int(avl, 972); + avl = remove_int(avl, 670); + avl = grpc_avl_add(avl, box(822), box(1958), nullptr); + avl = remove_int(avl, 589); + avl = remove_int(avl, 459); + avl = grpc_avl_add(avl, box(1003), box(1961), nullptr); + avl = grpc_avl_add(avl, box(657), box(1962), nullptr); + avl = grpc_avl_add(avl, box(477), box(1963), nullptr); + avl = grpc_avl_add(avl, box(923), box(1964), nullptr); + avl = remove_int(avl, 496); + avl = remove_int(avl, 99); + avl = grpc_avl_add(avl, box(127), box(1967), nullptr); + avl = grpc_avl_add(avl, box(1013), box(1968), nullptr); + avl = grpc_avl_add(avl, box(778), box(1969), nullptr); + avl = remove_int(avl, 5); + avl = remove_int(avl, 990); + avl = remove_int(avl, 850); + avl = remove_int(avl, 160); + avl = remove_int(avl, 86); + avl = grpc_avl_add(avl, box(283), box(1975), nullptr); + avl = remove_int(avl, 278); + avl = remove_int(avl, 297); + avl = remove_int(avl, 137); + avl = remove_int(avl, 653); + avl = grpc_avl_add(avl, box(702), box(1980), nullptr); + avl = remove_int(avl, 63); + avl = remove_int(avl, 427); + avl = remove_int(avl, 706); + avl = remove_int(avl, 806); + avl = grpc_avl_add(avl, box(335), box(1985), nullptr); + avl = grpc_avl_add(avl, box(412), box(1986), nullptr); + avl = remove_int(avl, 766); + avl = remove_int(avl, 937); + avl = remove_int(avl, 886); + avl = remove_int(avl, 652); + avl = grpc_avl_add(avl, box(545), box(1991), nullptr); + avl = grpc_avl_add(avl, box(408), box(1992), nullptr); + avl = grpc_avl_add(avl, box(841), box(1993), nullptr); + avl = remove_int(avl, 593); + avl = grpc_avl_add(avl, box(582), box(1995), nullptr); + avl = grpc_avl_add(avl, box(597), box(1996), nullptr); + avl = remove_int(avl, 49); + avl = remove_int(avl, 835); + avl = grpc_avl_add(avl, box(417), box(1999), nullptr); + avl = grpc_avl_add(avl, box(191), box(2000), nullptr); + avl = remove_int(avl, 406); + avl = grpc_avl_add(avl, box(30), box(2002), nullptr); + avl = remove_int(avl, 841); + avl = remove_int(avl, 50); + avl = grpc_avl_add(avl, box(967), box(2005), nullptr); + avl = grpc_avl_add(avl, box(849), box(2006), nullptr); + avl = remove_int(avl, 608); + avl = grpc_avl_add(avl, box(306), box(2008), nullptr); + avl = remove_int(avl, 779); + avl = grpc_avl_add(avl, box(897), box(2010), nullptr); + avl = grpc_avl_add(avl, box(147), box(2011), nullptr); + avl = remove_int(avl, 982); + avl = grpc_avl_add(avl, box(470), box(2013), nullptr); + avl = remove_int(avl, 951); + avl = grpc_avl_add(avl, box(388), box(2015), nullptr); + avl = remove_int(avl, 616); + avl = remove_int(avl, 721); + avl = remove_int(avl, 942); + avl = remove_int(avl, 589); + avl = grpc_avl_add(avl, box(218), box(2020), nullptr); + avl = remove_int(avl, 671); + avl = grpc_avl_add(avl, box(1020), box(2022), nullptr); + avl = remove_int(avl, 277); + avl = grpc_avl_add(avl, box(681), box(2024), nullptr); + avl = grpc_avl_add(avl, box(179), box(2025), nullptr); + avl = grpc_avl_add(avl, box(370), box(2026), nullptr); + avl = grpc_avl_add(avl, box(0), box(2027), nullptr); + avl = remove_int(avl, 523); + avl = grpc_avl_add(avl, box(99), box(2029), nullptr); + avl = grpc_avl_add(avl, box(334), box(2030), nullptr); + avl = grpc_avl_add(avl, box(569), box(2031), nullptr); + avl = grpc_avl_add(avl, box(257), box(2032), nullptr); + avl = remove_int(avl, 572); + avl = grpc_avl_add(avl, box(805), box(2034), nullptr); + avl = grpc_avl_add(avl, box(143), box(2035), nullptr); + avl = grpc_avl_add(avl, box(670), box(2036), nullptr); + avl = remove_int(avl, 42); + avl = grpc_avl_add(avl, box(46), box(2038), nullptr); + avl = remove_int(avl, 970); + avl = grpc_avl_add(avl, box(353), box(2040), nullptr); + avl = remove_int(avl, 258); + avl = grpc_avl_add(avl, box(451), box(2042), nullptr); + avl = grpc_avl_add(avl, box(28), box(2043), nullptr); + avl = grpc_avl_add(avl, box(729), box(2044), nullptr); + avl = grpc_avl_add(avl, box(401), box(2045), nullptr); + avl = grpc_avl_add(avl, box(614), box(2046), nullptr); + avl = remove_int(avl, 990); + avl = remove_int(avl, 212); + avl = remove_int(avl, 22); + avl = remove_int(avl, 677); + avl = grpc_avl_add(avl, box(1016), box(2051), nullptr); + avl = grpc_avl_add(avl, box(980), box(2052), nullptr); + avl = grpc_avl_add(avl, box(990), box(2053), nullptr); + avl = grpc_avl_add(avl, box(355), box(2054), nullptr); + avl = remove_int(avl, 730); + avl = remove_int(avl, 37); + avl = grpc_avl_add(avl, box(407), box(2057), nullptr); + avl = grpc_avl_add(avl, box(222), box(2058), nullptr); + avl = grpc_avl_add(avl, box(439), box(2059), nullptr); + avl = grpc_avl_add(avl, box(563), box(2060), nullptr); + avl = remove_int(avl, 992); + avl = remove_int(avl, 786); + avl = grpc_avl_add(avl, box(1), box(2063), nullptr); + avl = grpc_avl_add(avl, box(473), box(2064), nullptr); + avl = grpc_avl_add(avl, box(992), box(2065), nullptr); + avl = remove_int(avl, 190); + avl = remove_int(avl, 450); + avl = remove_int(avl, 1020); + avl = remove_int(avl, 149); + avl = grpc_avl_add(avl, box(329), box(2070), nullptr); + avl = grpc_avl_add(avl, box(35), box(2071), nullptr); + avl = remove_int(avl, 843); + avl = grpc_avl_add(avl, box(855), box(2073), nullptr); + avl = remove_int(avl, 878); + avl = grpc_avl_add(avl, box(993), box(2075), nullptr); + avl = grpc_avl_add(avl, box(87), box(2076), nullptr); + avl = grpc_avl_add(avl, box(572), box(2077), nullptr); + avl = remove_int(avl, 896); + avl = grpc_avl_add(avl, box(849), box(2079), nullptr); + avl = remove_int(avl, 597); + avl = grpc_avl_add(avl, box(472), box(2081), nullptr); + avl = remove_int(avl, 778); + avl = remove_int(avl, 934); + avl = remove_int(avl, 314); + avl = grpc_avl_add(avl, box(101), box(2085), nullptr); + avl = remove_int(avl, 938); + avl = remove_int(avl, 1010); + avl = grpc_avl_add(avl, box(579), box(2088), nullptr); + avl = remove_int(avl, 798); + avl = remove_int(avl, 88); + avl = grpc_avl_add(avl, box(851), box(2091), nullptr); + avl = remove_int(avl, 705); + avl = grpc_avl_add(avl, box(26), box(2093), nullptr); + avl = remove_int(avl, 973); + avl = grpc_avl_add(avl, box(923), box(2095), nullptr); + avl = remove_int(avl, 668); + avl = grpc_avl_add(avl, box(310), box(2097), nullptr); + avl = grpc_avl_add(avl, box(269), box(2098), nullptr); + avl = remove_int(avl, 173); + avl = grpc_avl_add(avl, box(279), box(2100), nullptr); + avl = remove_int(avl, 203); + avl = grpc_avl_add(avl, box(411), box(2102), nullptr); + avl = remove_int(avl, 950); + avl = grpc_avl_add(avl, box(6), box(2104), nullptr); + avl = remove_int(avl, 400); + avl = remove_int(avl, 468); + avl = remove_int(avl, 271); + avl = grpc_avl_add(avl, box(627), box(2108), nullptr); + avl = remove_int(avl, 727); + avl = remove_int(avl, 148); + avl = remove_int(avl, 98); + avl = remove_int(avl, 997); + avl = remove_int(avl, 215); + avl = remove_int(avl, 628); + avl = remove_int(avl, 826); + avl = remove_int(avl, 664); + avl = grpc_avl_add(avl, box(76), box(2117), nullptr); + avl = remove_int(avl, 194); + avl = remove_int(avl, 18); + avl = grpc_avl_add(avl, box(727), box(2120), nullptr); + avl = remove_int(avl, 295); + avl = grpc_avl_add(avl, box(645), box(2122), nullptr); + avl = remove_int(avl, 321); + avl = remove_int(avl, 863); + avl = grpc_avl_add(avl, box(824), box(2125), nullptr); + avl = grpc_avl_add(avl, box(651), box(2126), nullptr); + avl = grpc_avl_add(avl, box(804), box(2127), nullptr); + avl = remove_int(avl, 307); + avl = grpc_avl_add(avl, box(867), box(2129), nullptr); + avl = remove_int(avl, 384); + avl = grpc_avl_add(avl, box(819), box(2131), nullptr); + avl = remove_int(avl, 674); + avl = grpc_avl_add(avl, box(76), box(2133), nullptr); + avl = remove_int(avl, 898); + avl = grpc_avl_add(avl, box(45), box(2135), nullptr); + avl = grpc_avl_add(avl, box(512), box(2136), nullptr); + avl = remove_int(avl, 773); + avl = remove_int(avl, 907); + avl = remove_int(avl, 382); + avl = remove_int(avl, 95); + avl = remove_int(avl, 734); + avl = remove_int(avl, 81); + avl = grpc_avl_add(avl, box(348), box(2143), nullptr); + avl = remove_int(avl, 509); + avl = remove_int(avl, 301); + avl = grpc_avl_add(avl, box(861), box(2146), nullptr); + avl = grpc_avl_add(avl, box(918), box(2147), nullptr); + avl = remove_int(avl, 992); + avl = grpc_avl_add(avl, box(356), box(2149), nullptr); + avl = remove_int(avl, 64); + avl = remove_int(avl, 444); + avl = remove_int(avl, 741); + avl = grpc_avl_add(avl, box(710), box(2153), nullptr); + avl = grpc_avl_add(avl, box(264), box(2154), nullptr); + avl = remove_int(avl, 347); + avl = remove_int(avl, 250); + avl = grpc_avl_add(avl, box(82), box(2157), nullptr); + avl = grpc_avl_add(avl, box(571), box(2158), nullptr); + avl = remove_int(avl, 721); + avl = remove_int(avl, 622); + avl = grpc_avl_add(avl, box(950), box(2161), nullptr); + avl = grpc_avl_add(avl, box(94), box(2162), nullptr); + avl = remove_int(avl, 970); + avl = grpc_avl_add(avl, box(815), box(2164), nullptr); + avl = remove_int(avl, 930); + avl = remove_int(avl, 703); + avl = grpc_avl_add(avl, box(432), box(2167), nullptr); + avl = remove_int(avl, 544); + avl = grpc_avl_add(avl, box(21), box(2169), nullptr); + avl = grpc_avl_add(avl, box(186), box(2170), nullptr); + avl = remove_int(avl, 143); + avl = grpc_avl_add(avl, box(425), box(2172), nullptr); + avl = remove_int(avl, 769); + avl = grpc_avl_add(avl, box(656), box(2174), nullptr); + avl = remove_int(avl, 29); + avl = grpc_avl_add(avl, box(464), box(2176), nullptr); + avl = remove_int(avl, 713); + avl = grpc_avl_add(avl, box(800), box(2178), nullptr); + avl = remove_int(avl, 621); + avl = grpc_avl_add(avl, box(962), box(2180), nullptr); + avl = remove_int(avl, 448); + avl = grpc_avl_add(avl, box(878), box(2182), nullptr); + avl = remove_int(avl, 39); + avl = remove_int(avl, 999); + avl = grpc_avl_add(avl, box(182), box(2185), nullptr); + avl = grpc_avl_add(avl, box(429), box(2186), nullptr); + avl = grpc_avl_add(avl, box(598), box(2187), nullptr); + avl = remove_int(avl, 551); + avl = grpc_avl_add(avl, box(827), box(2189), nullptr); + avl = grpc_avl_add(avl, box(809), box(2190), nullptr); + avl = remove_int(avl, 438); + avl = remove_int(avl, 811); + avl = grpc_avl_add(avl, box(808), box(2193), nullptr); + avl = grpc_avl_add(avl, box(788), box(2194), nullptr); + avl = remove_int(avl, 156); + avl = grpc_avl_add(avl, box(933), box(2196), nullptr); + avl = grpc_avl_add(avl, box(344), box(2197), nullptr); + avl = remove_int(avl, 460); + avl = grpc_avl_add(avl, box(161), box(2199), nullptr); + avl = grpc_avl_add(avl, box(444), box(2200), nullptr); + avl = remove_int(avl, 597); + avl = remove_int(avl, 668); + avl = grpc_avl_add(avl, box(703), box(2203), nullptr); + avl = remove_int(avl, 515); + avl = grpc_avl_add(avl, box(380), box(2205), nullptr); + avl = grpc_avl_add(avl, box(338), box(2206), nullptr); + avl = remove_int(avl, 550); + avl = remove_int(avl, 946); + avl = remove_int(avl, 714); + avl = remove_int(avl, 739); + avl = grpc_avl_add(avl, box(413), box(2211), nullptr); + avl = remove_int(avl, 450); + avl = grpc_avl_add(avl, box(411), box(2213), nullptr); + avl = grpc_avl_add(avl, box(117), box(2214), nullptr); + avl = grpc_avl_add(avl, box(322), box(2215), nullptr); + avl = grpc_avl_add(avl, box(915), box(2216), nullptr); + avl = grpc_avl_add(avl, box(410), box(2217), nullptr); + avl = grpc_avl_add(avl, box(66), box(2218), nullptr); + avl = remove_int(avl, 756); + avl = remove_int(avl, 596); + avl = grpc_avl_add(avl, box(882), box(2221), nullptr); + avl = grpc_avl_add(avl, box(930), box(2222), nullptr); + avl = grpc_avl_add(avl, box(36), box(2223), nullptr); + avl = remove_int(avl, 742); + avl = grpc_avl_add(avl, box(539), box(2225), nullptr); + avl = grpc_avl_add(avl, box(596), box(2226), nullptr); + avl = remove_int(avl, 82); + avl = remove_int(avl, 686); + avl = remove_int(avl, 933); + avl = remove_int(avl, 42); + avl = remove_int(avl, 340); + avl = grpc_avl_add(avl, box(126), box(2232), nullptr); + avl = grpc_avl_add(avl, box(493), box(2233), nullptr); + avl = grpc_avl_add(avl, box(839), box(2234), nullptr); + avl = remove_int(avl, 774); + avl = grpc_avl_add(avl, box(337), box(2236), nullptr); + avl = remove_int(avl, 322); + avl = grpc_avl_add(avl, box(16), box(2238), nullptr); + avl = remove_int(avl, 73); + avl = remove_int(avl, 85); + avl = remove_int(avl, 191); + avl = remove_int(avl, 541); + avl = grpc_avl_add(avl, box(704), box(2243), nullptr); + avl = remove_int(avl, 767); + avl = remove_int(avl, 1006); + avl = remove_int(avl, 844); + avl = remove_int(avl, 742); + avl = grpc_avl_add(avl, box(48), box(2248), nullptr); + avl = grpc_avl_add(avl, box(138), box(2249), nullptr); + avl = grpc_avl_add(avl, box(437), box(2250), nullptr); + avl = grpc_avl_add(avl, box(275), box(2251), nullptr); + avl = remove_int(avl, 520); + avl = grpc_avl_add(avl, box(1019), box(2253), nullptr); + avl = remove_int(avl, 955); + avl = grpc_avl_add(avl, box(270), box(2255), nullptr); + avl = remove_int(avl, 680); + avl = remove_int(avl, 698); + avl = grpc_avl_add(avl, box(735), box(2258), nullptr); + avl = grpc_avl_add(avl, box(400), box(2259), nullptr); + avl = remove_int(avl, 991); + avl = grpc_avl_add(avl, box(263), box(2261), nullptr); + avl = remove_int(avl, 704); + avl = grpc_avl_add(avl, box(757), box(2263), nullptr); + avl = remove_int(avl, 194); + avl = remove_int(avl, 616); + avl = remove_int(avl, 784); + avl = grpc_avl_add(avl, box(382), box(2267), nullptr); + avl = grpc_avl_add(avl, box(464), box(2268), nullptr); + avl = grpc_avl_add(avl, box(817), box(2269), nullptr); + avl = remove_int(avl, 445); + avl = grpc_avl_add(avl, box(412), box(2271), nullptr); + avl = remove_int(avl, 525); + avl = grpc_avl_add(avl, box(299), box(2273), nullptr); + avl = grpc_avl_add(avl, box(464), box(2274), nullptr); + avl = grpc_avl_add(avl, box(715), box(2275), nullptr); + avl = remove_int(avl, 58); + avl = remove_int(avl, 218); + avl = grpc_avl_add(avl, box(961), box(2278), nullptr); + avl = grpc_avl_add(avl, box(491), box(2279), nullptr); + avl = remove_int(avl, 846); + avl = grpc_avl_add(avl, box(762), box(2281), nullptr); + avl = remove_int(avl, 974); + avl = remove_int(avl, 887); + avl = grpc_avl_add(avl, box(498), box(2284), nullptr); + avl = remove_int(avl, 810); + avl = remove_int(avl, 743); + avl = remove_int(avl, 22); + avl = remove_int(avl, 284); + avl = grpc_avl_add(avl, box(482), box(2289), nullptr); + avl = grpc_avl_add(avl, box(1021), box(2290), nullptr); + avl = remove_int(avl, 155); + avl = remove_int(avl, 128); + avl = grpc_avl_add(avl, box(819), box(2293), nullptr); + avl = grpc_avl_add(avl, box(324), box(2294), nullptr); + avl = remove_int(avl, 196); + avl = remove_int(avl, 370); + avl = remove_int(avl, 753); + avl = remove_int(avl, 56); + avl = remove_int(avl, 735); + avl = grpc_avl_add(avl, box(272), box(2300), nullptr); + avl = grpc_avl_add(avl, box(474), box(2301), nullptr); + avl = grpc_avl_add(avl, box(719), box(2302), nullptr); + avl = grpc_avl_add(avl, box(236), box(2303), nullptr); + avl = remove_int(avl, 818); + avl = grpc_avl_add(avl, box(727), box(2305), nullptr); + avl = remove_int(avl, 892); + avl = remove_int(avl, 871); + avl = remove_int(avl, 231); + avl = grpc_avl_add(avl, box(62), box(2309), nullptr); + avl = grpc_avl_add(avl, box(953), box(2310), nullptr); + avl = remove_int(avl, 701); + avl = grpc_avl_add(avl, box(193), box(2312), nullptr); + avl = remove_int(avl, 619); + avl = remove_int(avl, 22); + avl = remove_int(avl, 804); + avl = remove_int(avl, 851); + avl = grpc_avl_add(avl, box(286), box(2317), nullptr); + avl = grpc_avl_add(avl, box(751), box(2318), nullptr); + avl = remove_int(avl, 525); + avl = grpc_avl_add(avl, box(217), box(2320), nullptr); + avl = remove_int(avl, 336); + avl = grpc_avl_add(avl, box(86), box(2322), nullptr); + avl = grpc_avl_add(avl, box(81), box(2323), nullptr); + avl = grpc_avl_add(avl, box(850), box(2324), nullptr); + avl = remove_int(avl, 872); + avl = grpc_avl_add(avl, box(402), box(2326), nullptr); + avl = grpc_avl_add(avl, box(54), box(2327), nullptr); + avl = grpc_avl_add(avl, box(980), box(2328), nullptr); + avl = grpc_avl_add(avl, box(845), box(2329), nullptr); + avl = remove_int(avl, 1004); + avl = remove_int(avl, 273); + avl = remove_int(avl, 879); + avl = grpc_avl_add(avl, box(354), box(2333), nullptr); + avl = grpc_avl_add(avl, box(58), box(2334), nullptr); + avl = grpc_avl_add(avl, box(127), box(2335), nullptr); + avl = remove_int(avl, 84); + avl = grpc_avl_add(avl, box(360), box(2337), nullptr); + avl = remove_int(avl, 648); + avl = remove_int(avl, 488); + avl = remove_int(avl, 585); + avl = remove_int(avl, 230); + avl = grpc_avl_add(avl, box(887), box(2342), nullptr); + avl = remove_int(avl, 558); + avl = remove_int(avl, 958); + avl = grpc_avl_add(avl, box(822), box(2345), nullptr); + avl = remove_int(avl, 1004); + avl = remove_int(avl, 747); + avl = grpc_avl_add(avl, box(631), box(2348), nullptr); + avl = grpc_avl_add(avl, box(442), box(2349), nullptr); + avl = remove_int(avl, 957); + avl = remove_int(avl, 964); + avl = grpc_avl_add(avl, box(10), box(2352), nullptr); + avl = remove_int(avl, 189); + avl = grpc_avl_add(avl, box(742), box(2354), nullptr); + avl = remove_int(avl, 108); + avl = grpc_avl_add(avl, box(1014), box(2356), nullptr); + avl = remove_int(avl, 266); + avl = remove_int(avl, 623); + avl = remove_int(avl, 697); + avl = grpc_avl_add(avl, box(180), box(2360), nullptr); + avl = remove_int(avl, 472); + avl = grpc_avl_add(avl, box(567), box(2362), nullptr); + avl = remove_int(avl, 1020); + avl = remove_int(avl, 273); + avl = grpc_avl_add(avl, box(864), box(2365), nullptr); + avl = grpc_avl_add(avl, box(1009), box(2366), nullptr); + avl = remove_int(avl, 224); + avl = remove_int(avl, 81); + avl = grpc_avl_add(avl, box(653), box(2369), nullptr); + avl = remove_int(avl, 67); + avl = remove_int(avl, 102); + avl = remove_int(avl, 76); + avl = remove_int(avl, 935); + avl = remove_int(avl, 169); + avl = remove_int(avl, 232); + avl = remove_int(avl, 79); + avl = grpc_avl_add(avl, box(509), box(2377), nullptr); + avl = remove_int(avl, 900); + avl = remove_int(avl, 822); + avl = remove_int(avl, 945); + avl = remove_int(avl, 356); + avl = grpc_avl_add(avl, box(443), box(2382), nullptr); + avl = grpc_avl_add(avl, box(925), box(2383), nullptr); + avl = remove_int(avl, 994); + avl = remove_int(avl, 324); + avl = grpc_avl_add(avl, box(291), box(2386), nullptr); + avl = remove_int(avl, 94); + avl = remove_int(avl, 795); + avl = remove_int(avl, 42); + avl = grpc_avl_add(avl, box(613), box(2390), nullptr); + avl = remove_int(avl, 289); + avl = grpc_avl_add(avl, box(980), box(2392), nullptr); + avl = remove_int(avl, 316); + avl = grpc_avl_add(avl, box(281), box(2394), nullptr); + avl = grpc_avl_add(avl, box(1006), box(2395), nullptr); + avl = remove_int(avl, 776); + avl = grpc_avl_add(avl, box(108), box(2397), nullptr); + avl = grpc_avl_add(avl, box(918), box(2398), nullptr); + avl = remove_int(avl, 721); + avl = remove_int(avl, 563); + avl = grpc_avl_add(avl, box(925), box(2401), nullptr); + avl = remove_int(avl, 448); + avl = remove_int(avl, 198); + avl = remove_int(avl, 1); + avl = grpc_avl_add(avl, box(160), box(2405), nullptr); + avl = remove_int(avl, 515); + avl = grpc_avl_add(avl, box(284), box(2407), nullptr); + avl = grpc_avl_add(avl, box(225), box(2408), nullptr); + avl = remove_int(avl, 304); + avl = grpc_avl_add(avl, box(714), box(2410), nullptr); + avl = grpc_avl_add(avl, box(708), box(2411), nullptr); + avl = grpc_avl_add(avl, box(624), box(2412), nullptr); + avl = remove_int(avl, 662); + avl = remove_int(avl, 825); + avl = remove_int(avl, 383); + avl = remove_int(avl, 381); + avl = grpc_avl_add(avl, box(194), box(2417), nullptr); + avl = remove_int(avl, 280); + avl = remove_int(avl, 25); + avl = remove_int(avl, 633); + avl = grpc_avl_add(avl, box(897), box(2421), nullptr); + avl = remove_int(avl, 636); + avl = remove_int(avl, 596); + avl = remove_int(avl, 757); + avl = remove_int(avl, 343); + avl = remove_int(avl, 162); + avl = remove_int(avl, 913); + avl = remove_int(avl, 843); + avl = remove_int(avl, 280); + avl = remove_int(avl, 911); + avl = grpc_avl_add(avl, box(1008), box(2431), nullptr); + avl = remove_int(avl, 948); + avl = remove_int(avl, 74); + avl = remove_int(avl, 571); + avl = grpc_avl_add(avl, box(486), box(2435), nullptr); + avl = grpc_avl_add(avl, box(285), box(2436), nullptr); + avl = remove_int(avl, 304); + avl = remove_int(avl, 516); + avl = grpc_avl_add(avl, box(758), box(2439), nullptr); + avl = grpc_avl_add(avl, box(776), box(2440), nullptr); + avl = remove_int(avl, 696); + avl = grpc_avl_add(avl, box(104), box(2442), nullptr); + avl = grpc_avl_add(avl, box(700), box(2443), nullptr); + avl = grpc_avl_add(avl, box(114), box(2444), nullptr); + avl = grpc_avl_add(avl, box(567), box(2445), nullptr); + avl = remove_int(avl, 620); + avl = grpc_avl_add(avl, box(270), box(2447), nullptr); + avl = remove_int(avl, 730); + avl = grpc_avl_add(avl, box(749), box(2449), nullptr); + avl = grpc_avl_add(avl, box(443), box(2450), nullptr); + avl = remove_int(avl, 457); + avl = grpc_avl_add(avl, box(571), box(2452), nullptr); + avl = grpc_avl_add(avl, box(626), box(2453), nullptr); + avl = remove_int(avl, 638); + avl = remove_int(avl, 313); + + grpc_avl_unref(avl, nullptr); +} + +static void test_stress(int amount_of_stress) { + int added[1024]; + int i, j; + int deletions = 0; + grpc_avl avl; + + unsigned seed = (unsigned)time(nullptr); + + gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed); + + srand((unsigned)time(nullptr)); + avl = grpc_avl_create(&int_int_vtable); + + memset(added, 0, sizeof(added)); + + for (i = 1; deletions < amount_of_stress; i++) { + int idx = rand() % (int)GPR_ARRAY_SIZE(added); + GPR_ASSERT(i); + if (rand() < RAND_MAX / 2) { + added[idx] = i; + printf("avl = grpc_avl_add(avl, box(%d), box(%d), NULL); /* d=%d */\n", + idx, i, deletions); + avl = grpc_avl_add(avl, box(idx), box(i), nullptr); + } else { + deletions += (added[idx] != 0); + added[idx] = 0; + printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions); + avl = remove_int(avl, idx); + } + for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) { + if (added[j] != 0) { + check_get(avl, j, added[j]); + } else { + check_negget(avl, j); + } + } + } + + grpc_avl_unref(avl, nullptr); +} + +int main(int argc, char* argv[]) { + grpc_test_init(argc, argv); + + test_get(); + test_ll(); + test_lr(); + test_rr(); + test_rl(); + test_unbalanced(); + test_replace(); + test_remove(); + test_badcase1(); + test_badcase2(); + test_badcase3(); + test_stress(10); + + return 0; +} diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc index 2e61243831..53e910eddd 100644 --- a/test/core/backoff/backoff_test.cc +++ b/test/core/backoff/backoff_test.cc @@ -21,7 +21,6 @@ #include <algorithm> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include <gtest/gtest.h> #include "test/core/util/test_config.h" diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index dd8d88170e..df803d16a2 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -34,25 +34,32 @@ #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/server.h" +#include "test/core/end2end/cq_verifier.h" +#define MIN_HTTP2_FRAME_SIZE 9 + +/* Args to provide to thread running server side validator */ typedef struct { grpc_server* server; grpc_completion_queue* cq; grpc_bad_client_server_side_validator validator; void* registered_method; gpr_event done_thd; - gpr_event done_write; } thd_args; +/* Run the server side validator and set done_thd once done */ static void thd_func(void* arg) { thd_args* a = (thd_args*)arg; - a->validator(a->server, a->cq, a->registered_method); + if (a->validator != nullptr) { + a->validator(a->server, a->cq, a->registered_method); + } gpr_event_set(&a->done_thd, (void*)1); } -static void done_write(void* arg, grpc_error* error) { - thd_args* a = (thd_args*)arg; - gpr_event_set(&a->done_write, (void*)1); +/* Sets the done_write event */ +static void set_done_write(void* arg, grpc_error* error) { + gpr_event* done_write = (gpr_event*)arg; + gpr_event_set(done_write, (void*)1); } static void server_setup_transport(void* ts, grpc_transport* transport) { @@ -62,136 +69,172 @@ static void server_setup_transport(void* ts, grpc_transport* transport) { grpc_server_get_channel_args(a->server)); } -static void read_done(void* arg, grpc_error* error) { +/* Sets the read_done event */ +static void set_read_done(void* arg, grpc_error* error) { gpr_event* read_done = (gpr_event*)arg; gpr_event_set(read_done, (void*)1); } -void grpc_run_bad_client_test( - grpc_bad_client_server_side_validator server_validator, - grpc_bad_client_client_stream_validator client_validator, - const char* client_payload, size_t client_payload_length, uint32_t flags) { - grpc_endpoint_pair sfd; - thd_args a; - gpr_thd_id id; - char* hex; - grpc_transport* transport; - grpc_slice slice = - grpc_slice_from_copied_buffer(client_payload, client_payload_length); - grpc_slice_buffer outgoing; - grpc_closure done_write_closure; - grpc_core::ExecCtx exec_ctx; - grpc_completion_queue* shutdown_cq; +/* shutdown client */ +static void shutdown_client(grpc_endpoint** client_fd) { + if (*client_fd != nullptr) { + grpc_endpoint_shutdown( + *client_fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect")); + grpc_endpoint_destroy(*client_fd); + grpc_core::ExecCtx::Get()->Flush(); + *client_fd = nullptr; + } +} - if (client_payload_length < 4 * 1024) { - hex = gpr_dump(client_payload, client_payload_length, +/* Runs client side validator */ +void grpc_run_client_side_validator(grpc_bad_client_arg* arg, uint32_t flags, + grpc_endpoint_pair* sfd, + grpc_completion_queue* client_cq) { + char* hex; + gpr_event done_write; + if (arg->client_payload_length < 4 * 1024) { + hex = gpr_dump(arg->client_payload, arg->client_payload_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); - /* Add a debug log */ gpr_log(GPR_INFO, "TEST: %s", hex); - gpr_free(hex); } else { gpr_log(GPR_INFO, "TEST: (%" PRIdPTR " byte long string)", - client_payload_length); + arg->client_payload_length); } - /* Init grpc */ - grpc_init(); - - /* Create endpoints */ - sfd = grpc_iomgr_create_endpoint_pair("fixture", nullptr); - - /* Create server, completion events */ - a.server = grpc_server_create(nullptr, nullptr); - a.cq = grpc_completion_queue_create_for_next(nullptr); - gpr_event_init(&a.done_thd); - gpr_event_init(&a.done_write); - a.validator = server_validator; - grpc_server_register_completion_queue(a.server, a.cq, nullptr); - a.registered_method = - grpc_server_register_method(a.server, GRPC_BAD_CLIENT_REGISTERED_METHOD, - GRPC_BAD_CLIENT_REGISTERED_HOST, - GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0); - grpc_server_start(a.server); - transport = grpc_create_chttp2_transport(nullptr, sfd.server, false); - server_setup_transport(&a, transport); - grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); - - /* Bind everything into the same pollset */ - grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(a.cq)); - grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq)); - - /* Check a ground truth */ - GPR_ASSERT(grpc_server_has_open_connections(a.server)); - - /* Start validator */ - gpr_thd_new(&id, "grpc_bad_client", thd_func, &a, nullptr); + grpc_slice slice = grpc_slice_from_copied_buffer(arg->client_payload, + arg->client_payload_length); + grpc_slice_buffer outgoing; + grpc_closure done_write_closure; + gpr_event_init(&done_write); grpc_slice_buffer_init(&outgoing); grpc_slice_buffer_add(&outgoing, slice); - GRPC_CLOSURE_INIT(&done_write_closure, done_write, &a, + GRPC_CLOSURE_INIT(&done_write_closure, set_done_write, &done_write, grpc_schedule_on_exec_ctx); /* Write data */ - grpc_endpoint_write(sfd.client, &outgoing, &done_write_closure); + grpc_endpoint_write(sfd->client, &outgoing, &done_write_closure); grpc_core::ExecCtx::Get()->Flush(); /* Await completion, unless the request is large and write may not finish * before the peer shuts down. */ if (!(flags & GRPC_BAD_CLIENT_LARGE_REQUEST)) { GPR_ASSERT( - gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(5))); + gpr_event_wait(&done_write, grpc_timeout_seconds_to_deadline(5))); } if (flags & GRPC_BAD_CLIENT_DISCONNECT) { - grpc_endpoint_shutdown( - sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Forced Disconnect")); - grpc_endpoint_destroy(sfd.client); - grpc_core::ExecCtx::Get()->Flush(); - sfd.client = nullptr; + shutdown_client(&sfd->client); } - GPR_ASSERT(gpr_event_wait(&a.done_thd, grpc_timeout_seconds_to_deadline(5))); - - if (sfd.client != nullptr) { - // Validate client stream, if requested. - if (client_validator != nullptr) { + if (sfd->client != nullptr) { + /* Validate client stream, if requested. */ + if (arg->client_validator != nullptr) { gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); grpc_slice_buffer incoming; grpc_slice_buffer_init(&incoming); - // We may need to do multiple reads to read the complete server response. + /* We may need to do multiple reads to read the complete server + * response. */ while (true) { gpr_event read_done_event; gpr_event_init(&read_done_event); grpc_closure read_done_closure; - GRPC_CLOSURE_INIT(&read_done_closure, read_done, &read_done_event, + GRPC_CLOSURE_INIT(&read_done_closure, set_read_done, &read_done_event, grpc_schedule_on_exec_ctx); - grpc_endpoint_read(sfd.client, &incoming, &read_done_closure); + grpc_endpoint_read(sfd->client, &incoming, &read_done_closure); grpc_core::ExecCtx::Get()->Flush(); do { GPR_ASSERT(gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0); - GPR_ASSERT( - grpc_completion_queue_next( - a.cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) - .type == GRPC_QUEUE_TIMEOUT); + /* Perform a cq next just to provide a thread that can read incoming + bytes on the client fd */ + GPR_ASSERT(grpc_completion_queue_next( + client_cq, grpc_timeout_milliseconds_to_deadline(100), + nullptr) + .type == GRPC_QUEUE_TIMEOUT); } while (!gpr_event_get(&read_done_event)); - if (client_validator(&incoming)) break; + if (arg->client_validator(&incoming, arg->client_validator_arg)) break; gpr_log(GPR_INFO, "client validator failed; trying additional read " "in case we didn't get all the data"); } grpc_slice_buffer_destroy_internal(&incoming); } - // Shutdown. - grpc_endpoint_shutdown( - sfd.client, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Test Shutdown")); - grpc_endpoint_destroy(sfd.client); grpc_core::ExecCtx::Get()->Flush(); } - GPR_ASSERT( - gpr_event_wait(&a.done_write, grpc_timeout_seconds_to_deadline(1))); + /* If the request was too large, then we need to forcefully shut down the + * client, so that the write can be considered completed */ + if (flags & GRPC_BAD_CLIENT_LARGE_REQUEST) { + shutdown_client(&sfd->client); + } + + /* Make sure that the client is done writing */ + while (!gpr_event_get(&done_write)) { + GPR_ASSERT( + grpc_completion_queue_next( + client_cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) + .type == GRPC_QUEUE_TIMEOUT); + } + + grpc_slice_buffer_destroy_internal(&outgoing); + grpc_core::ExecCtx::Get()->Flush(); +} + +void grpc_run_bad_client_test( + grpc_bad_client_server_side_validator server_validator, + grpc_bad_client_arg args[], int num_args, uint32_t flags) { + grpc_endpoint_pair sfd; + thd_args a; + grpc_transport* transport; + grpc_core::ExecCtx exec_ctx; + grpc_completion_queue* shutdown_cq; + grpc_completion_queue* client_cq; + + /* Init grpc */ + grpc_init(); + + /* Create endpoints */ + sfd = grpc_iomgr_create_endpoint_pair("fixture", nullptr); + + /* Create server, completion events */ + a.server = grpc_server_create(nullptr, nullptr); + a.cq = grpc_completion_queue_create_for_next(nullptr); + client_cq = grpc_completion_queue_create_for_next(nullptr); + + grpc_server_register_completion_queue(a.server, a.cq, nullptr); + a.registered_method = + grpc_server_register_method(a.server, GRPC_BAD_CLIENT_REGISTERED_METHOD, + GRPC_BAD_CLIENT_REGISTERED_HOST, + GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER, 0); + grpc_server_start(a.server); + transport = grpc_create_chttp2_transport(nullptr, sfd.server, false); + server_setup_transport(&a, transport); + grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); + + /* Bind fds to pollsets */ + grpc_endpoint_add_to_pollset(sfd.client, grpc_cq_pollset(client_cq)); + grpc_endpoint_add_to_pollset(sfd.server, grpc_cq_pollset(a.cq)); + + /* Check a ground truth */ + GPR_ASSERT(grpc_server_has_open_connections(a.server)); + + gpr_thd_id id; + gpr_event_init(&a.done_thd); + a.validator = server_validator; + /* Start validator */ + gpr_thd_new(&id, "grpc_bad_client", thd_func, &a, nullptr); + for (int i = 0; i < num_args; i++) { + grpc_run_client_side_validator(&args[i], i == (num_args - 1) ? flags : 0, + &sfd, client_cq); + } + /* Wait for server thread to finish */ + GPR_ASSERT(gpr_event_wait(&a.done_thd, grpc_timeout_seconds_to_deadline(1))); + + /* Shutdown. */ + shutdown_client(&sfd.client); + shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); grpc_server_shutdown_and_notify(a.server, shutdown_cq, nullptr); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, nullptr, @@ -201,7 +244,91 @@ void grpc_run_bad_client_test( grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); - grpc_slice_buffer_destroy_internal(&outgoing); - + grpc_completion_queue_destroy(client_cq); grpc_shutdown(); } + +bool client_connection_preface_validator(grpc_slice_buffer* incoming, + void* arg) { + if (incoming->count < 1) { + return false; + } + grpc_slice slice = incoming->slices[0]; + /* There should be atleast a settings frame present */ + if (GRPC_SLICE_LENGTH(slice) < MIN_HTTP2_FRAME_SIZE) { + return false; + } + const uint8_t* p = GRPC_SLICE_START_PTR(slice); + /* Check the frame type (SETTINGS) */ + if (*(p + 3) != 4) { + return false; + } + return true; +} + +/* connection preface and settings frame to be sent by the client */ +#define CONNECTION_PREFACE_FROM_CLIENT \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" + +grpc_bad_client_arg connection_preface_arg = { + client_connection_preface_validator, nullptr, + CONNECTION_PREFACE_FROM_CLIENT, sizeof(CONNECTION_PREFACE_FROM_CLIENT) - 1}; + +bool rst_stream_client_validator(grpc_slice_buffer* incoming, void* arg) { + // Get last frame from incoming slice buffer. + grpc_slice_buffer last_frame_buffer; + grpc_slice_buffer_init(&last_frame_buffer); + grpc_slice_buffer_trim_end(incoming, 13, &last_frame_buffer); + GPR_ASSERT(last_frame_buffer.count == 1); + grpc_slice last_frame = last_frame_buffer.slices[0]; + + const uint8_t* p = GRPC_SLICE_START_PTR(last_frame); + bool success = + // Length == 4 + *p++ != 0 || *p++ != 0 || *p++ != 4 || + // Frame type (RST_STREAM) + *p++ != 3 || + // Flags + *p++ != 0 || + // Stream ID. + *p++ != 0 || *p++ != 0 || *p++ != 0 || *p++ != 1 || + // Payload (error code) + *p++ == 0 || *p++ == 0 || *p++ == 0 || *p == 0 || *p == 11; + + if (!success) { + gpr_log(GPR_INFO, "client expected RST_STREAM frame, not found"); + } + + grpc_slice_buffer_destroy(&last_frame_buffer); + return success; +} + +static void* tag(intptr_t t) { return (void*)t; } + +void server_verifier_request_call(grpc_server* server, + grpc_completion_queue* cq, + void* registered_method) { + grpc_call_error error; + grpc_call* s; + grpc_call_details call_details; + cq_verifier* cqv = cq_verifier_create(cq); + grpc_metadata_array request_metadata_recv; + + grpc_call_details_init(&call_details); + grpc_metadata_array_init(&request_metadata_recv); + + error = grpc_server_request_call(server, &s, &call_details, + &request_metadata_recv, cq, cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + cq_verify(cqv); + + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); + + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + grpc_call_unref(s); + cq_verifier_destroy(cqv); +} diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index d3abfac2aa..de7d830cd7 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -28,30 +28,69 @@ #define GRPC_BAD_CLIENT_REGISTERED_METHOD "/registered/bar" #define GRPC_BAD_CLIENT_REGISTERED_HOST "localhost" +/* The server side validator function to run */ typedef void (*grpc_bad_client_server_side_validator)(grpc_server* server, grpc_completion_queue* cq, void* registered_method); -// Returns false if we need to read more data. +/* Returns false if we need to read more data. */ typedef bool (*grpc_bad_client_client_stream_validator)( - grpc_slice_buffer* incoming); + grpc_slice_buffer* incoming, void* arg); +struct grpc_bad_client_arg { + grpc_bad_client_client_stream_validator client_validator; + void* client_validator_arg; + const char* client_payload; + size_t client_payload_length; +}; + +/* Flags for grpc_run_bad_client_test */ #define GRPC_BAD_CLIENT_DISCONNECT 1 #define GRPC_BAD_CLIENT_LARGE_REQUEST 2 /* Test runner. - - Create a server, and send client_payload to it as bytes from a client. - Execute server_validator in a separate thread to assert that the bytes are - handled as expected. */ + * + * Create a server, and for each arg in \a args send client_payload. For each + * payload, run client_validator to make sure that the response is as expected. + * Also execute \a server_validator in a separate thread to assert that the + * bytes are handled as expected. + * + * The flags are only applicable to the last validator in the array. (This can + * be changed in the future if necessary) + */ void grpc_run_bad_client_test( grpc_bad_client_server_side_validator server_validator, - grpc_bad_client_client_stream_validator client_validator, - const char* client_payload, size_t client_payload_length, uint32_t flags); + grpc_bad_client_arg args[], int num_args, uint32_t flags); + +/* A hack to let old tests work as before. In these tests, instead of an array, + * the tests provide a single client_validator and payload + */ +#define COMBINE1(X, Y) X##Y +#define COMBINE(X, Y) COMBINE1(X, Y) + +#define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, \ + flags) \ + grpc_bad_client_arg COMBINE(bca, __LINE__) = {client_validator, nullptr, \ + payload, sizeof(payload) - 1}; \ + grpc_run_bad_client_test(server_validator, &COMBINE(bca, __LINE__), 1, flags) + +/* Helper validator functions */ +/* Client side validator for connection preface from server. \a arg is unused */ +bool client_connection_preface_validator(grpc_slice_buffer* incoming, + void* arg); + +/* Client side validator for checking if reset stream is present at the end + * of the buffer. \a arg is unused. + */ +bool rst_stream_client_validator(grpc_slice_buffer* incoming, void* arg); -#define GRPC_RUN_BAD_CLIENT_TEST(server_validator, client_validator, payload, \ - flags) \ - grpc_run_bad_client_test(server_validator, client_validator, payload, \ - sizeof(payload) - 1, flags) +/* Helper grpc_bad_client_arg arguments for direct use */ +/* Sends a connection preface from the client with an empty settings frame */ +extern grpc_bad_client_arg connection_preface_arg; +/* Server side verifier function that performs a + * single grpc_server_request_call */ +void server_verifier_request_call(grpc_server* server, + grpc_completion_queue* cq, + void* registered_method); #endif /* GRPC_TEST_CORE_BAD_CLIENT_BAD_CLIENT_H */ diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index 14c8a27334..32afba5b1f 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -27,10 +27,11 @@ default_test_options = TestOptions(False, 1.0) BAD_CLIENT_TESTS = { 'badreq': default_test_options, 'connection_prefix': default_test_options._replace(cpu_cost=0.2), + 'duplicate_header': default_test_options, 'headers': default_test_options._replace(cpu_cost=0.2), 'initial_settings_frame': default_test_options._replace(cpu_cost=0.2), 'head_of_line_blocking': default_test_options, - # 'large_metadata': default_test_options, #disabling as per issue #11745 + 'large_metadata': default_test_options, 'server_registered_method': default_test_options, 'simple_request': default_test_options, 'window_overflow': default_test_options, diff --git a/test/core/bad_client/generate_tests.bzl b/test/core/bad_client/generate_tests.bzl index 022edf3ff3..2769d5c3bb 100755 --- a/test/core/bad_client/generate_tests.bzl +++ b/test/core/bad_client/generate_tests.bzl @@ -16,6 +16,7 @@ """Generates the appropriate build.json data for all the bad_client tests.""" +load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library") def test_options(): return struct() @@ -25,10 +26,11 @@ def test_options(): BAD_CLIENT_TESTS = { 'badreq': test_options(), 'connection_prefix': test_options(), + 'duplicate_header': test_options(), 'headers': test_options(), 'initial_settings_frame': test_options(), 'head_of_line_blocking': test_options(), - # 'large_metadata': test_options(), # disabling as per issue #11745 + 'large_metadata': test_options(), 'server_registered_method': test_options(), 'simple_request': test_options(), 'window_overflow': test_options(), @@ -36,14 +38,14 @@ BAD_CLIENT_TESTS = { } def grpc_bad_client_tests(): - native.cc_library( + grpc_cc_library( name = 'bad_client_test', srcs = ['bad_client.cc'], hdrs = ['bad_client.h'], deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier'] ) for t, topt in BAD_CLIENT_TESTS.items(): - native.cc_test( + grpc_cc_test( name = '%s_bad_client_test' % t, srcs = ['tests/%s.cc' % t], deps = [':bad_client_test'], diff --git a/test/core/bad_client/tests/duplicate_header.cc b/test/core/bad_client/tests/duplicate_header.cc new file mode 100644 index 0000000000..0d689bbb7e --- /dev/null +++ b/test/core/bad_client/tests/duplicate_header.cc @@ -0,0 +1,134 @@ +/* + * + * Copyright 2018 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 "test/core/bad_client/bad_client.h" + +#include <string.h> + +#include <grpc/grpc.h> + +#include "src/core/lib/surface/server.h" +#include "test/core/end2end/cq_verifier.h" + +#define PFX_STR \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ + +#define HEADER_STR \ + "\x00\x00\xc9\x01\x04\x00\x00\x00\x01" /* headers: generated from \ + simple_request.headers in this \ + directory */ \ + "\x10\x05:path\x08/foo/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15" \ + "deflate,identity,gzip" \ + "\x10\x02te\x08trailers" \ + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" + +#define PAYLOAD_STR \ + "\x00\x00\x20\x00\x00\x00\x00\x00\x01" \ + "\x00\x00\x00\x00" + +static void* tag(intptr_t t) { return (void*)t; } + +static void verifier(grpc_server* server, grpc_completion_queue* cq, + void* registered_method) { + grpc_call_error error; + grpc_call* s; + grpc_call_details call_details; + grpc_byte_buffer* request_payload_recv = nullptr; + grpc_op* op; + grpc_op ops[6]; + cq_verifier* cqv = cq_verifier_create(cq); + grpc_metadata_array request_metadata_recv; + int was_cancelled = 2; + + grpc_call_details_init(&call_details); + grpc_metadata_array_init(&request_metadata_recv); + + error = grpc_server_request_call(server, &s, &call_details, + &request_metadata_recv, cq, cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + cq_verify(cqv); + + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); + GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = nullptr; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(102), 1); + cq_verify(cqv); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op->flags = 0; + op->reserved = nullptr; + op++; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = 0; + op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; + grpc_slice status_details = grpc_slice_from_static_string("xyz"); + op->data.send_status_from_server.status_details = &status_details; + op->flags = 0; + op->reserved = nullptr; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(103), 1); + + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + grpc_call_unref(s); + cq_verifier_destroy(cqv); +} + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + + /* Verify that sending multiple headers doesn't segfault */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, + PFX_STR HEADER_STR HEADER_STR PAYLOAD_STR, 0); + GRPC_RUN_BAD_CLIENT_TEST(verifier, nullptr, + PFX_STR HEADER_STR HEADER_STR HEADER_STR PAYLOAD_STR, + 0); + grpc_shutdown(); + return 0; +} diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc index f56c4d71dd..8668e091b6 100644 --- a/test/core/bad_client/tests/head_of_line_blocking.cc +++ b/test/core/bad_client/tests/head_of_line_blocking.cc @@ -131,7 +131,8 @@ int main(int argc, char** argv) { addbuf(hdr, sizeof(hdr)); addbuf(msg, FRAME_SIZE); } - grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count, 0); + grpc_bad_client_arg bca = {nullptr, nullptr, g_buffer, g_count}; + grpc_run_bad_client_test(verifier, &bca, 1, 0); gpr_free(g_buffer); grpc_shutdown(); diff --git a/test/core/bad_client/tests/large_metadata.cc b/test/core/bad_client/tests/large_metadata.cc index ff3e9eb932..d534753f53 100644 --- a/test/core/bad_client/tests/large_metadata.cc +++ b/test/core/bad_client/tests/large_metadata.cc @@ -31,23 +31,20 @@ // be longer than the C99 string literal limit. Instead, we dynamically // construct it by adding the large headers one at a time. -#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR \ - "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" /* settings frame */ \ - "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* headers: generated from \ - large_metadata.headers in this \ - directory */ \ - "\x00\x00\x00\x04\x01\x00\x00\x00\x00" \ - "\x00" \ - "5{\x01\x05\x00\x00\x00\x01" \ - "\x10\x05:path\x08/foo/bar" \ - "\x10\x07:scheme\x04http" \ - "\x10\x07:method\x04POST" \ - "\x10\x0a:authority\x09localhost" \ - "\x10\x0c" \ - "content-type\x10" \ - "application/grpc" \ - "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \ - "\x10\x02te\x08trailers" \ +/* headers: generated from large_metadata.headers in this directory */ +#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_REQUEST \ + "\x00\x00\x00\x04\x01\x00\x00\x00\x00" \ + "\x00" \ + "5{\x01\x05\x00\x00\x00\x01" \ + "\x10\x05:path\x08/foo/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \ + "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" // Each large-metadata header is constructed from these start and end @@ -65,8 +62,8 @@ // The number of headers we're adding and the total size of the client // payload. #define NUM_HEADERS 46 -#define PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE \ - ((sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR) - 1) + \ +#define TOO_MUCH_METADATA_FROM_CLIENT_REQUEST_SIZE \ + ((sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_REQUEST) - 1) + \ (NUM_HEADERS * PFX_TOO_MUCH_METADATA_FROM_CLIENT_HEADER_SIZE) + 1) #define PFX_TOO_MUCH_METADATA_FROM_SERVER_STR \ @@ -95,32 +92,6 @@ static void* tag(intptr_t t) { return (void*)t; } -static void server_verifier(grpc_server* server, grpc_completion_queue* cq, - void* registered_method) { - grpc_call_error error; - grpc_call* s; - grpc_call_details call_details; - cq_verifier* cqv = cq_verifier_create(cq); - grpc_metadata_array request_metadata_recv; - - grpc_call_details_init(&call_details); - grpc_metadata_array_init(&request_metadata_recv); - - error = grpc_server_request_call(server, &s, &call_details, - &request_metadata_recv, cq, cq, tag(101)); - GPR_ASSERT(GRPC_CALL_OK == error); - CQ_EXPECT_COMPLETION(cqv, tag(101), 1); - cq_verify(cqv); - - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "localhost")); - GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo/bar")); - - grpc_metadata_array_destroy(&request_metadata_recv); - grpc_call_details_destroy(&call_details); - grpc_call_unref(s); - cq_verifier_destroy(cqv); -} - static void server_verifier_sends_too_much_metadata(grpc_server* server, grpc_completion_queue* cq, void* registered_method) { @@ -167,43 +138,6 @@ static void server_verifier_sends_too_much_metadata(grpc_server* server, cq_verifier_destroy(cqv); } -static bool client_validator(grpc_slice_buffer* incoming) { - for (size_t i = 0; i < incoming->count; ++i) { - const char* s = (const char*)GRPC_SLICE_START_PTR(incoming->slices[i]); - char* hex = gpr_dump(s, GRPC_SLICE_LENGTH(incoming->slices[i]), - GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_INFO, "RESPONSE SLICE %" PRIdPTR ": %s", i, hex); - gpr_free(hex); - } - - // Get last frame from incoming slice buffer. - grpc_slice_buffer last_frame_buffer; - grpc_slice_buffer_init(&last_frame_buffer); - grpc_slice_buffer_trim_end(incoming, 13, &last_frame_buffer); - GPR_ASSERT(last_frame_buffer.count == 1); - grpc_slice last_frame = last_frame_buffer.slices[0]; - - const uint8_t* p = GRPC_SLICE_START_PTR(last_frame); - bool success = - // Length == 4 - *p++ != 0 || *p++ != 0 || *p++ != 4 || - // Frame type (RST_STREAM) - *p++ != 3 || - // Flags - *p++ != 0 || - // Stream ID. - *p++ != 0 || *p++ != 0 || *p++ != 0 || *p++ != 1 || - // Payload (error code) - *p++ == 0 || *p++ == 0 || *p++ == 0 || *p == 0 || *p == 11; - - if (!success) { - gpr_log(GPR_INFO, "client expected RST_STREAM frame, not found"); - } - - grpc_slice_buffer_destroy(&last_frame_buffer); - return success; -} - int main(int argc, char** argv) { int i; @@ -222,19 +156,22 @@ int main(int argc, char** argv) { size_t headers_len; const char* client_headers = gpr_strvec_flatten(&headers, &headers_len); gpr_strvec_destroy(&headers); - char client_payload[PFX_TOO_MUCH_METADATA_FROM_CLIENT_PAYLOAD_SIZE] = - PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR; - memcpy( - client_payload + sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_PREFIX_STR) - 1, - client_headers, headers_len); - GRPC_RUN_BAD_CLIENT_TEST(server_verifier, client_validator, client_payload, - 0); + char client_payload[TOO_MUCH_METADATA_FROM_CLIENT_REQUEST_SIZE] = + PFX_TOO_MUCH_METADATA_FROM_CLIENT_REQUEST; + memcpy(client_payload + sizeof(PFX_TOO_MUCH_METADATA_FROM_CLIENT_REQUEST) - 1, + client_headers, headers_len); + grpc_bad_client_arg args[2]; + args[0] = connection_preface_arg; + args[1].client_validator = rst_stream_client_validator; + args[1].client_payload = client_payload; + args[1].client_payload_length = sizeof(client_payload) - 1; + + grpc_run_bad_client_test(server_verifier_request_call, args, 2, 0); gpr_free((void*)client_headers); // Test sending more metadata than the client will accept. GRPC_RUN_BAD_CLIENT_TEST(server_verifier_sends_too_much_metadata, - client_validator, + rst_stream_client_validator, PFX_TOO_MUCH_METADATA_FROM_SERVER_STR, 0); - return 0; } diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc index ed8279c951..fe6b05d03a 100644 --- a/test/core/bad_client/tests/window_overflow.cc +++ b/test/core/bad_client/tests/window_overflow.cc @@ -26,8 +26,7 @@ #include "src/core/lib/surface/server.h" #define PFX_STR \ - "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ - "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ \ + "\x00\x00\x00\x04\x01\x00\x00\x00\x00" \ "\x00\x00\xc9\x01\x04\x00\x00\x00\x01" /* headers: generated from \ simple_request.headers in this \ directory */ \ @@ -70,7 +69,7 @@ int main(int argc, char** argv) { #define MAX_FRAME_SIZE 16384 #define MESSAGES_PER_FRAME (MAX_FRAME_SIZE / 5) #define FRAME_SIZE (MESSAGES_PER_FRAME * 5) -#define SEND_SIZE (6 * 1024 * 1024) +#define SEND_SIZE (4 * 1024 * 1024) #define NUM_FRAMES (SEND_SIZE / FRAME_SIZE + 1) grpc_test_init(argc, argv); grpc_init(); @@ -92,8 +91,10 @@ int main(int argc, char** argv) { addbuf(message, sizeof(message)); } } - grpc_run_bad_client_test(verifier, nullptr, g_buffer, g_count, - GRPC_BAD_CLIENT_LARGE_REQUEST); + grpc_bad_client_arg bca[2]; + bca[0] = connection_preface_arg; + bca[1] = {rst_stream_client_validator, nullptr, g_buffer, g_count}; + grpc_run_bad_client_test(verifier, bca, 2, GRPC_BAD_CLIENT_LARGE_REQUEST); gpr_free(g_buffer); grpc_shutdown(); diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 8a7960b5ed..e2ab22e014 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -22,14 +22,15 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> + #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/bad_ssl/generate_tests.bzl b/test/core/bad_ssl/generate_tests.bzl index b7cb8f86e6..3cf7fd7b4e 100755 --- a/test/core/bad_ssl/generate_tests.bzl +++ b/test/core/bad_ssl/generate_tests.bzl @@ -26,12 +26,23 @@ def grpc_bad_ssl_tests(): name = 'bad_ssl_test_server', srcs = ['server_common.cc'], hdrs = ['server_common.h'], - deps = ['//test/core/util:grpc_test_util', '//:grpc', '//test/core/end2end:ssl_test_data'] + deps = ['//test/core/util:grpc_test_util', + '//:grpc', + '//test/core/end2end:ssl_test_data'] ) for t in BAD_SSL_TESTS: - native.cc_test( + native.cc_binary( name = 'bad_ssl_%s_server' % t, srcs = ['servers/%s.cc' % t], deps = [':bad_ssl_test_server'], ) - + native.cc_test( + name = 'bad_ssl_%s_test' % t, + srcs = ['bad_ssl_test.cc'], + data = [':bad_ssl_%s_server' % t, + '//src/core/tsi/test_creds:badserver.key', + '//src/core/tsi/test_creds:badserver.pem',], + deps = ['//test/core/util:grpc_test_util', + '//:gpr', + '//test/core/end2end:cq_verifier'], + ) diff --git a/test/core/bad_ssl/server_common.cc b/test/core/bad_ssl/server_common.cc index 08842b8350..809539aff3 100644 --- a/test/core/bad_ssl/server_common.cc +++ b/test/core/bad_ssl/server_common.cc @@ -16,11 +16,11 @@ * */ -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <signal.h> #include "test/core/bad_ssl/server_common.h" +#include "test/core/util/cmdline.h" #include "test/core/util/test_config.h" /* Common server implementation details for all servers in servers/. diff --git a/test/core/bad_ssl/servers/alpn.cc b/test/core/bad_ssl/servers/alpn.cc index 23954d82fd..4a04178b1c 100644 --- a/test/core/bad_ssl/servers/alpn.cc +++ b/test/core/bad_ssl/servers/alpn.cc @@ -21,9 +21,9 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/ext/transport/chttp2/alpn/alpn.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/bad_ssl/server_common.h" #include "test/core/end2end/data/ssl_test_data.h" diff --git a/test/core/bad_ssl/servers/cert.cc b/test/core/bad_ssl/servers/cert.cc index a51dd34e4b..3ed7d029ee 100644 --- a/test/core/bad_ssl/servers/cert.cc +++ b/test/core/bad_ssl/servers/cert.cc @@ -21,7 +21,6 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/lib/iomgr/load_file.h" diff --git a/test/core/channel/BUILD b/test/core/channel/BUILD index 92f5907aac..c5dfd8ef37 100644 --- a/test/core/channel/BUILD +++ b/test/core/channel/BUILD @@ -53,3 +53,15 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "minimal_stack_is_minimal_test", + srcs = ["minimal_stack_is_minimal_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + ], +) diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc index 4a8195e984..d232bc02ac 100644 --- a/test/core/channel/channel_args_test.cc +++ b/test/core/channel/channel_args_test.cc @@ -19,9 +19,9 @@ #include <string.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/test_config.h" @@ -74,7 +74,8 @@ static void test_set_compression_algorithm(void) { static void test_compression_algorithm_states(void) { grpc_core::ExecCtx exec_ctx; - grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate; + grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate, + *ch_args_wo_gzip_deflate_gzip; unsigned states_bitset; size_t i; @@ -87,28 +88,35 @@ static void test_compression_algorithm_states(void) { GPR_ASSERT(GPR_BITGET(states_bitset, i)); } - /* disable gzip and deflate */ + /* disable gzip and deflate and stream/gzip */ ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( &ch_args, GRPC_COMPRESS_GZIP, 0); GPR_ASSERT(ch_args == ch_args_wo_gzip); ch_args_wo_gzip_deflate = grpc_channel_args_compression_algorithm_set_state( &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0); GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); + ch_args_wo_gzip_deflate_gzip = + grpc_channel_args_compression_algorithm_set_state( + &ch_args_wo_gzip_deflate, GRPC_COMPRESS_STREAM_GZIP, 0); + GPR_ASSERT(ch_args_wo_gzip_deflate == ch_args_wo_gzip_deflate_gzip); states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states( ch_args_wo_gzip_deflate); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { - if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) { + if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE || + i == GRPC_COMPRESS_STREAM_GZIP) { GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0); } else { GPR_ASSERT(GPR_BITGET(states_bitset, i) != 0); } } - /* re-enabled gzip only */ + /* re-enabled gzip and stream/gzip only */ ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( - &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1); - GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); + &ch_args_wo_gzip_deflate_gzip, GRPC_COMPRESS_GZIP, 1); + ch_args_wo_gzip = grpc_channel_args_compression_algorithm_set_state( + &ch_args_wo_gzip, GRPC_COMPRESS_STREAM_GZIP, 1); + GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate_gzip); states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states( ch_args_wo_gzip); diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD index ec72e0ea72..c4d12fe3a1 100644 --- a/test/core/client_channel/BUILD +++ b/test/core/client_channel/BUILD @@ -23,8 +23,19 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_fuzzer( name = "uri_fuzzer_test", srcs = ["uri_fuzzer_test.cc"], - language = "C++", corpus = "uri_corpus", + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( + name = "parse_address_test", + srcs = ["parse_address_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -33,14 +44,13 @@ grpc_fuzzer( ) grpc_cc_test( - name = "lb_policies_test", - srcs = ["lb_policies_test.cc"], + name = "uri_parser_test", + srcs = ["uri_parser_test.cc"], language = "C++", deps = [ "//:gpr", "//:grpc", - "//test/core/end2end:cq_verifier", - "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], ) + diff --git a/test/core/client_channel/lb_policies_test.cc b/test/core/client_channel/lb_policies_test.cc deleted file mode 100644 index 716c63b9d0..0000000000 --- a/test/core/client_channel/lb_policies_test.cc +++ /dev/null @@ -1,1029 +0,0 @@ -/* - * - * Copyright 2015 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 <stdarg.h> -#include <string.h> - -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> -#include <grpc/support/log.h> -#include <grpc/support/string_util.h> -#include <grpc/support/time.h> - -#include "src/core/ext/filters/client_channel/client_channel.h" -#include "src/core/ext/filters/client_channel/lb_policy_registry.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/gpr/string.h" -#include "src/core/lib/surface/channel.h" -#include "src/core/lib/surface/server.h" -#include "test/core/end2end/cq_verifier.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" - -#define RETRY_TIMEOUT 300 - -typedef struct servers_fixture { - size_t num_servers; - grpc_server** servers; - grpc_call** server_calls; - grpc_completion_queue* cq; - grpc_completion_queue* shutdown_cq; - char** servers_hostports; - grpc_metadata_array* request_metadata_recv; -} servers_fixture; - -typedef struct request_sequences { - size_t n; /* number of iterations */ - int* connections; /* indexed by the interation number, value is the index of - the server it connected to or -1 if none */ - /* indexed by the interation number, value is the client connectivity state */ - grpc_connectivity_state* connectivity_states; -} request_sequences; - -typedef void (*verifier_fn)(const servers_fixture*, grpc_channel*, - const request_sequences*, const size_t); - -typedef struct test_spec { - size_t num_iters; - size_t num_servers; - - int** kill_at; - int** revive_at; - - const char* description; - - verifier_fn verifier; - -} test_spec; - -static void test_spec_reset(test_spec* spec) { - size_t i, j; - - for (i = 0; i < spec->num_iters; i++) { - for (j = 0; j < spec->num_servers; j++) { - spec->kill_at[i][j] = 0; - spec->revive_at[i][j] = 0; - } - } -} - -static test_spec* test_spec_create(size_t num_iters, size_t num_servers) { - test_spec* spec; - size_t i; - - spec = static_cast<test_spec*>(gpr_malloc(sizeof(test_spec))); - spec->num_iters = num_iters; - spec->num_servers = num_servers; - spec->kill_at = static_cast<int**>(gpr_malloc(sizeof(int*) * num_iters)); - spec->revive_at = static_cast<int**>(gpr_malloc(sizeof(int*) * num_iters)); - for (i = 0; i < num_iters; i++) { - spec->kill_at[i] = static_cast<int*>(gpr_malloc(sizeof(int) * num_servers)); - spec->revive_at[i] = - static_cast<int*>(gpr_malloc(sizeof(int) * num_servers)); - } - - test_spec_reset(spec); - return spec; -} - -static void test_spec_destroy(test_spec* spec) { - size_t i; - for (i = 0; i < spec->num_iters; i++) { - gpr_free(spec->kill_at[i]); - gpr_free(spec->revive_at[i]); - } - - gpr_free(spec->kill_at); - gpr_free(spec->revive_at); - - gpr_free(spec); -} - -static void* tag(intptr_t t) { return (void*)t; } - -static gpr_timespec n_millis_time(int n) { - return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_millis(n, GPR_TIMESPAN)); -} - -static void drain_cq(grpc_completion_queue* cq) { - grpc_event ev; - do { - ev = grpc_completion_queue_next(cq, n_millis_time(5000), nullptr); - } while (ev.type != GRPC_QUEUE_SHUTDOWN); -} - -static void kill_server(const servers_fixture* f, size_t i) { - gpr_log(GPR_INFO, "KILLING SERVER %" PRIuPTR, i); - GPR_ASSERT(f->servers[i] != nullptr); - grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(10000), - n_millis_time(5000), nullptr) - .type == GRPC_OP_COMPLETE); - grpc_server_destroy(f->servers[i]); - f->servers[i] = nullptr; -} - -typedef struct request_data { - grpc_metadata_array initial_metadata_recv; - grpc_metadata_array trailing_metadata_recv; - grpc_slice details; - grpc_status_code status; - grpc_call_details* call_details; -} request_data; - -static void revive_server(const servers_fixture* f, request_data* rdata, - size_t i) { - int got_port; - gpr_log(GPR_INFO, "RAISE AGAIN SERVER %" PRIuPTR, i); - GPR_ASSERT(f->servers[i] == nullptr); - - gpr_log(GPR_DEBUG, "revive: %s", f->servers_hostports[i]); - - f->servers[i] = grpc_server_create(nullptr, nullptr); - grpc_server_register_completion_queue(f->servers[i], f->cq, nullptr); - GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( - f->servers[i], f->servers_hostports[i])) > 0); - grpc_server_start(f->servers[i]); - - GPR_ASSERT(GRPC_CALL_OK == - grpc_server_request_call(f->servers[i], &f->server_calls[i], - &rdata->call_details[i], - &f->request_metadata_recv[i], f->cq, - f->cq, tag(1000 + (int)i))); -} - -static servers_fixture* setup_servers(const char* server_host, - request_data* rdata, - const size_t num_servers) { - servers_fixture* f = - static_cast<servers_fixture*>(gpr_malloc(sizeof(servers_fixture))); - size_t i; - - f->num_servers = num_servers; - f->server_calls = - static_cast<grpc_call**>(gpr_malloc(sizeof(grpc_call*) * num_servers)); - f->request_metadata_recv = static_cast<grpc_metadata_array*>( - gpr_malloc(sizeof(grpc_metadata_array) * num_servers)); - /* Create servers. */ - f->servers = static_cast<grpc_server**>( - gpr_malloc(sizeof(grpc_server*) * num_servers)); - f->servers_hostports = - static_cast<char**>(gpr_malloc(sizeof(char*) * num_servers)); - f->cq = grpc_completion_queue_create_for_next(nullptr); - f->shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); - for (i = 0; i < num_servers; i++) { - grpc_metadata_array_init(&f->request_metadata_recv[i]); - gpr_join_host_port(&f->servers_hostports[i], server_host, - grpc_pick_unused_port_or_die()); - f->servers[i] = nullptr; - revive_server(f, rdata, i); - } - return f; -} - -static void teardown_servers(servers_fixture* f) { - size_t i; - /* Destroy server. */ - for (i = 0; i < f->num_servers; i++) { - if (f->servers[i] == nullptr) continue; - grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(10000), - n_millis_time(5000), nullptr) - .type == GRPC_OP_COMPLETE); - grpc_server_destroy(f->servers[i]); - } - grpc_completion_queue_shutdown(f->cq); - drain_cq(f->cq); - grpc_completion_queue_destroy(f->cq); - grpc_completion_queue_destroy(f->shutdown_cq); - - gpr_free(f->servers); - - for (i = 0; i < f->num_servers; i++) { - gpr_free(f->servers_hostports[i]); - grpc_metadata_array_destroy(&f->request_metadata_recv[i]); - } - - gpr_free(f->servers_hostports); - gpr_free(f->request_metadata_recv); - gpr_free(f->server_calls); - gpr_free(f); -} - -static request_sequences request_sequences_create(size_t n) { - request_sequences res; - res.n = n; - res.connections = static_cast<int*>(gpr_malloc(sizeof(*res.connections) * n)); - res.connectivity_states = static_cast<grpc_connectivity_state*>( - gpr_malloc(sizeof(*res.connectivity_states) * n)); - memset(res.connections, 0, sizeof(*res.connections) * n); - memset(res.connectivity_states, 0, sizeof(*res.connectivity_states) * n); - return res; -} - -static void request_sequences_destroy(const request_sequences* rseqs) { - gpr_free(rseqs->connections); - gpr_free(rseqs->connectivity_states); -} - -/** Returns connection sequence (server indices), which must be freed */ -static request_sequences perform_request(servers_fixture* f, - grpc_channel* client, - request_data* rdata, - const test_spec* spec) { - grpc_call* c; - int s_idx; - int* s_valid; - grpc_op ops[6]; - grpc_op* op; - int was_cancelled; - size_t i, iter_num; - grpc_event ev; - int read_tag; - int completed_client; - const request_sequences sequences = request_sequences_create(spec->num_iters); - - s_valid = static_cast<int*>(gpr_malloc(sizeof(int) * f->num_servers)); - - for (iter_num = 0; iter_num < spec->num_iters; iter_num++) { - cq_verifier* cqv = cq_verifier_create(f->cq); - was_cancelled = 2; - - for (i = 0; i < f->num_servers; i++) { - if (spec->kill_at[iter_num][i] != 0) { - kill_server(f, i); - } else if (spec->revive_at[iter_num][i] != 0) { - /* killing takes precedence */ - revive_server(f, rdata, i); - } - } - - sequences.connections[iter_num] = -1; - grpc_metadata_array_init(&rdata->initial_metadata_recv); - grpc_metadata_array_init(&rdata->trailing_metadata_recv); - - for (i = 0; i < f->num_servers; i++) { - grpc_call_details_init(&rdata->call_details[i]); - } - memset(s_valid, 0, f->num_servers * sizeof(int)); - - grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); - c = grpc_channel_create_call(client, nullptr, GRPC_PROPAGATE_DEFAULTS, - f->cq, grpc_slice_from_static_string("/foo"), - &host, gpr_inf_future(GPR_CLOCK_REALTIME), - nullptr); - GPR_ASSERT(c); - completed_client = 0; - - memset(ops, 0, sizeof(ops)); - op = ops; - op->op = GRPC_OP_SEND_INITIAL_METADATA; - op->data.send_initial_metadata.count = 0; - op->flags = 0; - op->reserved = nullptr; - op++; - op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; - op->flags = 0; - op->reserved = nullptr; - op++; - op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata.recv_initial_metadata = - &rdata->initial_metadata_recv; - op->flags = 0; - op->reserved = nullptr; - op++; - op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; - op->data.recv_status_on_client.trailing_metadata = - &rdata->trailing_metadata_recv; - op->data.recv_status_on_client.status = &rdata->status; - op->data.recv_status_on_client.status_details = &rdata->details; - op->flags = 0; - op->reserved = nullptr; - op++; - GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(c, ops, (size_t)(op - ops), - tag(1), nullptr)); - - s_idx = -1; - while ((ev = grpc_completion_queue_next( - f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT), - nullptr)) - .type != GRPC_QUEUE_TIMEOUT) { - GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - read_tag = ((int)(intptr_t)ev.tag); - const grpc_connectivity_state conn_state = - grpc_channel_check_connectivity_state(client, 0); - sequences.connectivity_states[iter_num] = conn_state; - gpr_log(GPR_DEBUG, "EVENT: success:%d, type:%d, tag:%d iter:%" PRIuPTR, - ev.success, ev.type, read_tag, iter_num); - if (ev.success && read_tag >= 1000) { - GPR_ASSERT(s_idx == -1); /* only one server must reply */ - /* only server notifications for non-shutdown events */ - s_idx = read_tag - 1000; - s_valid[s_idx] = 1; - sequences.connections[iter_num] = s_idx; - break; - } else if (read_tag == 1) { - gpr_log(GPR_DEBUG, "client timed out"); - GPR_ASSERT(ev.success); - completed_client = 1; - } - } - - if (s_idx >= 0) { - memset(ops, 0, sizeof(ops)); - op = ops; - op->op = GRPC_OP_SEND_INITIAL_METADATA; - op->data.send_initial_metadata.count = 0; - op->flags = 0; - op->reserved = nullptr; - op++; - op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; - op->data.send_status_from_server.trailing_metadata_count = 0; - op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; - grpc_slice status_details = grpc_slice_from_static_string("xyz"); - op->data.send_status_from_server.status_details = &status_details; - op->flags = 0; - op->reserved = nullptr; - op++; - op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; - op->data.recv_close_on_server.cancelled = &was_cancelled; - op->flags = 0; - op->reserved = nullptr; - op++; - GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(f->server_calls[s_idx], - ops, (size_t)(op - ops), - tag(102), nullptr)); - - CQ_EXPECT_COMPLETION(cqv, tag(102), 1); - if (!completed_client) { - CQ_EXPECT_COMPLETION(cqv, tag(1), 1); - } - cq_verify(cqv); - - GPR_ASSERT(rdata->status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT(0 == grpc_slice_str_cmp(rdata->details, "xyz")); - GPR_ASSERT(0 == - grpc_slice_str_cmp(rdata->call_details[s_idx].method, "/foo")); - GPR_ASSERT(0 == grpc_slice_str_cmp(rdata->call_details[s_idx].host, - "foo.test.google.fr")); - GPR_ASSERT(was_cancelled == 1); - - grpc_call_unref(f->server_calls[s_idx]); - - /* ask for the next request on this server */ - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( - f->servers[s_idx], &f->server_calls[s_idx], - &rdata->call_details[s_idx], - &f->request_metadata_recv[s_idx], f->cq, - f->cq, tag(1000 + (int)s_idx))); - } else { /* no response from server */ - grpc_call_cancel(c, nullptr); - if (!completed_client) { - CQ_EXPECT_COMPLETION(cqv, tag(1), 1); - cq_verify(cqv); - } - } - - GPR_ASSERT(grpc_completion_queue_next( - f->cq, grpc_timeout_milliseconds_to_deadline(RETRY_TIMEOUT), - nullptr) - .type == GRPC_QUEUE_TIMEOUT); - - grpc_metadata_array_destroy(&rdata->initial_metadata_recv); - grpc_metadata_array_destroy(&rdata->trailing_metadata_recv); - - cq_verifier_destroy(cqv); - - grpc_call_unref(c); - - for (i = 0; i < f->num_servers; i++) { - grpc_call_details_destroy(&rdata->call_details[i]); - } - grpc_slice_unref(rdata->details); - } - - gpr_free(s_valid); - - return sequences; -} - -static grpc_call** perform_multirequest(servers_fixture* f, - grpc_channel* client, - size_t concurrent_calls) { - grpc_call** calls; - grpc_op ops[6]; - grpc_op* op; - size_t i; - - calls = static_cast<grpc_call**>( - gpr_malloc(sizeof(grpc_call*) * concurrent_calls)); - for (i = 0; i < f->num_servers; i++) { - kill_server(f, i); - } - - memset(ops, 0, sizeof(ops)); - op = ops; - op->op = GRPC_OP_SEND_INITIAL_METADATA; - op->data.send_initial_metadata.count = 0; - op->flags = 0; - op->reserved = nullptr; - op++; - op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; - op->flags = 0; - op->reserved = nullptr; - - grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); - for (i = 0; i < concurrent_calls; i++) { - calls[i] = grpc_channel_create_call( - client, nullptr, GRPC_PROPAGATE_DEFAULTS, f->cq, - grpc_slice_from_static_string("/foo"), &host, - gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); - GPR_ASSERT(calls[i]); - GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(calls[i], ops, - (size_t)(op - ops), tag(1), - nullptr)); - } - - return calls; -} - -void run_spec(const test_spec* spec) { - grpc_channel* client; - char* client_hostport; - char* servers_hostports_str; - request_data rdata; - servers_fixture* f; - grpc_channel_args args; - grpc_arg arg_array[2]; - rdata.call_details = static_cast<grpc_call_details*>( - gpr_malloc(sizeof(grpc_call_details) * spec->num_servers)); - f = setup_servers("127.0.0.1", &rdata, spec->num_servers); - - /* Create client. */ - servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports, - f->num_servers, ",", nullptr); - gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str); - - arg_array[0].type = GRPC_ARG_INTEGER; - arg_array[0].key = - const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); - arg_array[0].value.integer = RETRY_TIMEOUT; - arg_array[1].type = GRPC_ARG_STRING; - arg_array[1].key = const_cast<char*>(GRPC_ARG_LB_POLICY_NAME); - arg_array[1].value.string = const_cast<char*>("round_robin"); - args.num_args = 2; - args.args = arg_array; - - client = grpc_insecure_channel_create(client_hostport, &args, nullptr); - - gpr_log(GPR_INFO, "Testing '%s' with servers=%s client=%s", spec->description, - servers_hostports_str, client_hostport); - - const request_sequences sequences = perform_request(f, client, &rdata, spec); - - spec->verifier(f, client, &sequences, spec->num_iters); - - gpr_free(client_hostport); - gpr_free(servers_hostports_str); - gpr_free(rdata.call_details); - request_sequences_destroy(&sequences); - - grpc_channel_destroy(client); /* calls the LB's shutdown func */ - teardown_servers(f); -} - -static grpc_channel* create_client(const servers_fixture* f) { - grpc_channel* client; - char* client_hostport; - char* servers_hostports_str; - grpc_arg arg_array[3]; - grpc_channel_args args; - - servers_hostports_str = gpr_strjoin_sep((const char**)f->servers_hostports, - f->num_servers, ",", nullptr); - gpr_asprintf(&client_hostport, "ipv4:%s", servers_hostports_str); - - arg_array[0].type = GRPC_ARG_INTEGER; - arg_array[0].key = - const_cast<char*>("grpc.testing.fixed_reconnect_backoff_ms"); - arg_array[0].value.integer = RETRY_TIMEOUT; - arg_array[1].type = GRPC_ARG_STRING; - arg_array[1].key = const_cast<char*>(GRPC_ARG_LB_POLICY_NAME); - arg_array[1].value.string = const_cast<char*>("ROUND_ROBIN"); - arg_array[2].type = GRPC_ARG_INTEGER; - arg_array[2].key = - const_cast<char*>(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS); - arg_array[2].value.integer = 0; - args.num_args = GPR_ARRAY_SIZE(arg_array); - args.args = arg_array; - - client = grpc_insecure_channel_create(client_hostport, &args, nullptr); - gpr_free(client_hostport); - gpr_free(servers_hostports_str); - - return client; -} - -static void test_ping() { - grpc_channel* client; - request_data rdata; - servers_fixture* f; - cq_verifier* cqv; - grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - const size_t num_servers = 1; - int i; - - rdata.call_details = static_cast<grpc_call_details*>( - gpr_malloc(sizeof(grpc_call_details) * num_servers)); - f = setup_servers("127.0.0.1", &rdata, num_servers); - cqv = cq_verifier_create(f->cq); - - client = create_client(f); - - grpc_channel_ping(client, f->cq, tag(0), nullptr); - CQ_EXPECT_COMPLETION(cqv, tag(0), 0); - - /* check that we're still in idle, and start connecting */ - GPR_ASSERT(grpc_channel_check_connectivity_state(client, 1) == - GRPC_CHANNEL_IDLE); - /* we'll go through some set of transitions (some might be missed), until - READY is reached */ - while (state != GRPC_CHANNEL_READY) { - grpc_channel_watch_connectivity_state( - client, state, grpc_timeout_seconds_to_deadline(3), f->cq, tag(99)); - CQ_EXPECT_COMPLETION(cqv, tag(99), 1); - cq_verify(cqv); - state = grpc_channel_check_connectivity_state(client, 0); - GPR_ASSERT(state == GRPC_CHANNEL_READY || - state == GRPC_CHANNEL_CONNECTING || - state == GRPC_CHANNEL_TRANSIENT_FAILURE); - } - - for (i = 1; i <= 5; i++) { - grpc_channel_ping(client, f->cq, tag(i), nullptr); - CQ_EXPECT_COMPLETION(cqv, tag(i), 1); - cq_verify(cqv); - } - gpr_free(rdata.call_details); - - grpc_channel_destroy(client); - teardown_servers(f); - - cq_verifier_destroy(cqv); -} - -static void test_pending_calls(size_t concurrent_calls) { - size_t i; - grpc_call** calls; - grpc_channel* client; - request_data rdata; - servers_fixture* f; - test_spec* spec = test_spec_create(0, 4); - rdata.call_details = static_cast<grpc_call_details*>( - gpr_malloc(sizeof(grpc_call_details) * spec->num_servers)); - f = setup_servers("127.0.0.1", &rdata, spec->num_servers); - - client = create_client(f); - calls = perform_multirequest(f, client, concurrent_calls); - grpc_call_cancel(calls[0], nullptr); /* exercise the cancel pick path whilst - there are pending picks */ - - gpr_free(rdata.call_details); - - grpc_channel_destroy(client); /* calls the LB's shutdown func */ - /* destroy the calls after the channel so that they are still around for the - * LB's shutdown func to process */ - for (i = 0; i < concurrent_calls; i++) { - grpc_call_unref(calls[i]); - } - gpr_free(calls); - teardown_servers(f); - test_spec_destroy(spec); -} - -static void test_get_channel_info() { - grpc_channel* channel = - grpc_insecure_channel_create("ipv4:127.0.0.1:1234", nullptr, nullptr); - // Ensures that resolver returns. - grpc_channel_check_connectivity_state(channel, true /* try_to_connect */); - // First, request no fields. This is a no-op. - grpc_channel_info channel_info; - memset(&channel_info, 0, sizeof(channel_info)); - grpc_channel_get_info(channel, &channel_info); - // Request LB policy name. - char* lb_policy_name = nullptr; - channel_info.lb_policy_name = &lb_policy_name; - grpc_channel_get_info(channel, &channel_info); - GPR_ASSERT(lb_policy_name != nullptr); - GPR_ASSERT(strcmp(lb_policy_name, "pick_first") == 0); - gpr_free(lb_policy_name); - // Request service config, which does not exist, so we'll get nothing back. - memset(&channel_info, 0, sizeof(channel_info)); - char* service_config_json = const_cast<char*>("dummy_string"); - channel_info.service_config_json = &service_config_json; - grpc_channel_get_info(channel, &channel_info); - GPR_ASSERT(service_config_json == nullptr); - // Recreate the channel such that it has a service config. - grpc_channel_destroy(channel); - grpc_arg arg; - arg.type = GRPC_ARG_STRING; - arg.key = const_cast<char*>(GRPC_ARG_SERVICE_CONFIG); - arg.value.string = - const_cast<char*>("{\"loadBalancingPolicy\": \"ROUND_ROBIN\"}"); - grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); - channel = grpc_insecure_channel_create("ipv4:127.0.0.1:1234", args, nullptr); - { - grpc_core::ExecCtx exec_ctx; - grpc_channel_args_destroy(args); - } - // Ensures that resolver returns. - grpc_channel_check_connectivity_state(channel, true /* try_to_connect */); - // Now request the service config again. - grpc_channel_get_info(channel, &channel_info); - GPR_ASSERT(service_config_json != nullptr); - GPR_ASSERT(strcmp(service_config_json, arg.value.string) == 0); - gpr_free(service_config_json); - // Clean up. - grpc_channel_destroy(channel); -} - -static void print_failed_expectations(const int* expected_connection_sequence, - const int* actual_connection_sequence, - const size_t expected_seq_length, - const size_t num_iters) { - size_t i; - for (i = 0; i < num_iters; i++) { - gpr_log(GPR_ERROR, - "FAILURE: Iter (expected, actual): %" PRIuPTR " (%d, %d)", i, - expected_connection_sequence[i % expected_seq_length], - actual_connection_sequence[i]); - } -} - -static void verify_vanilla_round_robin(const servers_fixture* f, - grpc_channel* client, - const request_sequences* sequences, - const size_t num_iters) { - const size_t expected_seq_length = f->num_servers; - - /* verify conn. seq. expectation */ - /* get the first sequence of "num_servers" elements */ - int* expected_connection_sequence = - static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length)); - memcpy(expected_connection_sequence, sequences->connections, - sizeof(int) * expected_seq_length); - - for (size_t i = 0; i < num_iters; i++) { - const int actual = sequences->connections[i]; - const int expected = expected_connection_sequence[i % expected_seq_length]; - if (actual != expected) { - gpr_log( - GPR_ERROR, - "CONNECTION SEQUENCE FAILURE: expected %d, got %d at iteration #%d", - expected, actual, (int)i); - abort(); - } - } - - /* All servers are available, therefore all client subchannels are READY, even - * when we only need one for the client channel state to be READY */ - for (size_t i = 0; i < sequences->n; i++) { - const grpc_connectivity_state actual = - static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]); - const grpc_connectivity_state expected = GRPC_CHANNEL_READY; - if (actual != expected) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' " - "at iteration #%d", - grpc_connectivity_state_name(expected), - grpc_connectivity_state_name(actual), (int)i); - abort(); - } - } - - gpr_free(expected_connection_sequence); -} - -/* At the start of the second iteration, all but the first and last servers (as - * given in "f") are killed */ -static void verify_vanishing_floor_round_robin( - const servers_fixture* f, grpc_channel* client, - const request_sequences* sequences, const size_t num_iters) { - int* expected_connection_sequence; - const size_t expected_seq_length = 2; - size_t i; - - /* verify conn. seq. expectation */ - /* copy the first full sequence (without -1s) */ - expected_connection_sequence = - static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length)); - memcpy(expected_connection_sequence, sequences->connections + 2, - expected_seq_length * sizeof(int)); - - /* first two elements of the sequence should be [0 (1st server), -1 (failure)] - */ - GPR_ASSERT(sequences->connections[0] == 0); - GPR_ASSERT(sequences->connections[1] == -1); - - /* the next two element must be [3, 0], repeating from that point: the 3 is - * brought forth by servers 1 and 2 disappearing after the intial pick of 0 */ - GPR_ASSERT(sequences->connections[2] == 3); - GPR_ASSERT(sequences->connections[3] == 0); - - /* make sure that the expectation obliges */ - for (i = 2; i < num_iters; i++) { - const int actual = sequences->connections[i]; - const int expected = expected_connection_sequence[i % expected_seq_length]; - if (actual != expected) { - print_failed_expectations(expected_connection_sequence, - sequences->connections, expected_seq_length, - num_iters); - abort(); - } - } - - /* There's always at least one subchannel READY (connected), therefore the - * overall state of the client channel is READY at all times. */ - for (i = 0; i < sequences->n; i++) { - const grpc_connectivity_state actual = - static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]); - const grpc_connectivity_state expected = GRPC_CHANNEL_READY; - if (actual != expected) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' " - "at iteration #%d", - grpc_connectivity_state_name(expected), - grpc_connectivity_state_name(actual), (int)i); - abort(); - } - } - - gpr_free(expected_connection_sequence); -} - -static void verify_total_carnage_round_robin(const servers_fixture* f, - grpc_channel* client, - const request_sequences* sequences, - const size_t num_iters) { - for (size_t i = 0; i < num_iters; i++) { - const int actual = sequences->connections[i]; - const int expected = -1; - if (actual != expected) { - gpr_log( - GPR_ERROR, - "CONNECTION SEQUENCE FAILURE: expected %d, got %d at iteration #%d", - expected, actual, (int)i); - abort(); - } - } - - /* No server is ever available. There should be no READY states (or SHUTDOWN). - * Note that all other states (IDLE, CONNECTING, TRANSIENT_FAILURE) are still - * possible, as the policy transitions while attempting to reconnect. */ - for (size_t i = 0; i < sequences->n; i++) { - const grpc_connectivity_state actual = - static_cast<grpc_connectivity_state>(sequences->connectivity_states[i]); - if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state " - "'%s' at iteration #%d.", - grpc_connectivity_state_name(actual), (int)i); - abort(); - } - } -} - -static void verify_partial_carnage_round_robin( - const servers_fixture* f, grpc_channel* client, - const request_sequences* sequences, const size_t num_iters) { - int* expected_connection_sequence; - size_t i; - const size_t expected_seq_length = f->num_servers; - - /* verify conn. seq. expectation */ - /* get the first sequence of "num_servers" elements */ - expected_connection_sequence = - static_cast<int*>(gpr_malloc(sizeof(int) * expected_seq_length)); - memcpy(expected_connection_sequence, sequences->connections, - sizeof(int) * expected_seq_length); - - for (i = 0; i < num_iters / 2; i++) { - const int actual = sequences->connections[i]; - const int expected = expected_connection_sequence[i % expected_seq_length]; - if (actual != expected) { - print_failed_expectations(expected_connection_sequence, - sequences->connections, expected_seq_length, - num_iters); - abort(); - } - } - - /* second half of the iterations go without response */ - for (; i < num_iters; i++) { - GPR_ASSERT(sequences->connections[i] == -1); - } - - /* We can assert that the first client channel state should be READY, when all - * servers were available */ - grpc_connectivity_state actual = - static_cast<grpc_connectivity_state>(sequences->connectivity_states[0]); - grpc_connectivity_state expected = GRPC_CHANNEL_READY; - if (actual != expected) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' " - "at iteration #%d", - grpc_connectivity_state_name(expected), - grpc_connectivity_state_name(actual), 0); - abort(); - } - - /* ... and that the last one shouldn't be READY (or SHUTDOWN): all servers are - * gone. It may be all other states (IDLE, CONNECTING, TRANSIENT_FAILURE), as - * the policy transitions while attempting to reconnect. */ - actual = static_cast<grpc_connectivity_state>( - sequences->connectivity_states[num_iters - 1]); - for (i = 0; i < sequences->n; i++) { - if (actual == GRPC_CHANNEL_READY || actual == GRPC_CHANNEL_SHUTDOWN) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: got unexpected state " - "'%s' at iteration #%d.", - grpc_connectivity_state_name(actual), (int)i); - abort(); - } - } - gpr_free(expected_connection_sequence); -} - -static void dump_array(const char* desc, const int* data, const size_t count) { - gpr_strvec s; - char* tmp; - size_t i; - gpr_strvec_init(&s); - gpr_strvec_add(&s, gpr_strdup(desc)); - gpr_strvec_add(&s, gpr_strdup(":")); - for (i = 0; i < count; i++) { - gpr_asprintf(&tmp, " %d", data[i]); - gpr_strvec_add(&s, tmp); - } - tmp = gpr_strvec_flatten(&s, nullptr); - gpr_strvec_destroy(&s); - gpr_log(GPR_DEBUG, "%s", tmp); - gpr_free(tmp); -} - -static void verify_rebirth_round_robin(const servers_fixture* f, - grpc_channel* client, - const request_sequences* sequences, - const size_t num_iters) { - dump_array("actual_connection_sequence", sequences->connections, num_iters); - - /* first iteration succeeds */ - GPR_ASSERT(sequences->connections[0] != -1); - /* then we fail for a while... */ - GPR_ASSERT(sequences->connections[1] == -1); - /* ... but should be up eventually */ - size_t first_iter_back_up = ~0ul; - for (size_t i = 2; i < sequences->n; ++i) { - if (sequences->connections[i] != -1) { - first_iter_back_up = i; - break; - } - } - GPR_ASSERT(first_iter_back_up != ~0ul); - - /* We can assert that the first client channel state should be READY, when all - * servers were available; same thing for the last one. In the middle - * somewhere there must exist at least one TRANSIENT_FAILURE */ - grpc_connectivity_state actual = - static_cast<grpc_connectivity_state>(sequences->connectivity_states[0]); - grpc_connectivity_state expected = GRPC_CHANNEL_READY; - if (actual != expected) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' " - "at iteration #%d", - grpc_connectivity_state_name(expected), - grpc_connectivity_state_name(actual), 0); - abort(); - } - - actual = static_cast<grpc_connectivity_state>( - sequences->connectivity_states[num_iters - 1]); - expected = GRPC_CHANNEL_READY; - if (actual != expected) { - gpr_log(GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: expected '%s', got '%s' " - "at iteration #%d", - grpc_connectivity_state_name(expected), - grpc_connectivity_state_name(actual), (int)num_iters - 1); - abort(); - } - - bool found_failure_status = false; - for (size_t i = 1; i < sequences->n - 1; i++) { - if (sequences->connectivity_states[i] == GRPC_CHANNEL_TRANSIENT_FAILURE) { - found_failure_status = true; - break; - } - } - if (!found_failure_status) { - gpr_log( - GPR_ERROR, - "CONNECTIVITY STATUS SEQUENCE FAILURE: " - "GRPC_CHANNEL_TRANSIENT_FAILURE status not found. Got the following " - "instead:"); - for (size_t i = 0; i < num_iters; i++) { - gpr_log(GPR_ERROR, "[%d]: %s", (int)i, - grpc_connectivity_state_name(static_cast<grpc_connectivity_state>( - sequences->connectivity_states[i]))); - } - } -} - -int main(int argc, char** argv) { - grpc_core::ExecCtx exec_ctx; - test_spec* spec; - size_t i; - const size_t NUM_ITERS = 10; - const size_t NUM_SERVERS = 4; - - grpc_init(); - grpc_test_init(argc, argv); - grpc_tracer_set_enabled("round_robin", 1); - - GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", nullptr) == - nullptr); - GPR_ASSERT(grpc_lb_policy_create(nullptr, nullptr) == nullptr); - - spec = test_spec_create(NUM_ITERS, NUM_SERVERS); - /* everything is fine, all servers stay up the whole time and life's peachy - */ - spec->verifier = verify_vanilla_round_robin; - spec->description = "test_all_server_up"; - run_spec(spec); - - /* Kill all servers first thing in the morning */ - test_spec_reset(spec); - spec->verifier = verify_total_carnage_round_robin; - spec->description = "test_kill_all_server"; - for (i = 0; i < NUM_SERVERS; i++) { - spec->kill_at[0][i] = 1; - } - run_spec(spec); - - /* at the start of the 2nd iteration, kill all but the first and last - * servers. - * This should knock down the server bound to be selected next */ - test_spec_reset(spec); - spec->verifier = verify_vanishing_floor_round_robin; - spec->description = "test_kill_middle_servers_at_2nd_iteration"; - for (i = 1; i < NUM_SERVERS - 1; i++) { - spec->kill_at[1][i] = 1; - } - run_spec(spec); - - /* Midway, kill all servers. */ - test_spec_reset(spec); - spec->verifier = verify_partial_carnage_round_robin; - spec->description = "test_kill_all_server_midway"; - for (i = 0; i < NUM_SERVERS; i++) { - spec->kill_at[spec->num_iters / 2][i] = 1; - } - run_spec(spec); - - /* After first iteration, kill all servers. On the third one, bring them all - * back up. */ - test_spec_reset(spec); - spec->verifier = verify_rebirth_round_robin; - spec->description = "test_kill_all_server_after_1st_resurrect_at_3rd"; - for (i = 0; i < NUM_SERVERS; i++) { - spec->kill_at[1][i] = 1; - spec->revive_at[3][i] = 1; - } - run_spec(spec); - test_spec_destroy(spec); - - test_pending_calls(4); - test_ping(); - test_get_channel_info(); - - grpc_shutdown(); - return 0; -} diff --git a/test/core/client_channel/resolvers/BUILD b/test/core/client_channel/resolvers/BUILD index b5269c7ef0..d8b0395846 100644 --- a/test/core/client_channel/resolvers/BUILD +++ b/test/core/client_channel/resolvers/BUILD @@ -43,6 +43,18 @@ grpc_cc_test( ) grpc_cc_test( + name = "dns_resolver_cooldown_test", + srcs = ["dns_resolver_cooldown_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + ], +) + +grpc_cc_test( name = "sockaddr_resolver_test", srcs = ["sockaddr_resolver_test.cc"], language = "C++", diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc index 18a795fbcb..8cafadf05a 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc @@ -79,17 +79,17 @@ static grpc_ares_request* my_dns_lookup_ares( return nullptr; } -static grpc_resolver* create_resolver(const char* name) { - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("dns"); +static grpc_core::OrphanablePtr<grpc_core::Resolver> create_resolver( + const char* name) { + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(name, 0); GPR_ASSERT(uri); - grpc_resolver_args args; - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - grpc_resolver* resolver = - grpc_resolver_factory_create_resolver(factory, &args); - grpc_resolver_factory_unref(factory); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); grpc_uri_destroy(uri); return resolver; } @@ -112,7 +112,7 @@ static bool wait_loop(int deadline_seconds, gpr_event* ev) { } typedef struct next_args { - grpc_resolver* resolver; + grpc_core::Resolver* resolver; grpc_channel_args** result; grpc_closure* on_complete; } next_args; @@ -120,21 +120,21 @@ typedef struct next_args { static void call_resolver_next_now_lock_taken(void* arg, grpc_error* error_unused) { next_args* a = static_cast<next_args*>(arg); - grpc_resolver_next_locked(a->resolver, a->result, a->on_complete); + a->resolver->NextLocked(a->result, a->on_complete); gpr_free(a); } -static void call_resolver_next_after_locking(grpc_resolver* resolver, +static void call_resolver_next_after_locking(grpc_core::Resolver* resolver, grpc_channel_args** result, - grpc_closure* on_complete) { + grpc_closure* on_complete, + grpc_combiner* combiner) { next_args* a = static_cast<next_args*>(gpr_malloc(sizeof(*a))); a->resolver = resolver; a->result = result; a->on_complete = on_complete; - GRPC_CLOSURE_SCHED( - GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, - grpc_combiner_scheduler(resolver->combiner)), - GRPC_ERROR_NONE); + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(call_resolver_next_now_lock_taken, a, + grpc_combiner_scheduler(combiner)), + GRPC_ERROR_NONE); } int main(int argc, char** argv) { @@ -149,12 +149,14 @@ int main(int argc, char** argv) { { grpc_core::ExecCtx exec_ctx; - grpc_resolver* resolver = create_resolver("dns:test"); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + create_resolver("dns:test"); gpr_event ev1; gpr_event_init(&ev1); call_resolver_next_after_locking( - resolver, &result, - GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx)); + resolver.get(), &result, + GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx), + g_combiner); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(wait_loop(5, &ev1)); GPR_ASSERT(result == nullptr); @@ -162,14 +164,14 @@ int main(int argc, char** argv) { gpr_event ev2; gpr_event_init(&ev2); call_resolver_next_after_locking( - resolver, &result, - GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx)); + resolver.get(), &result, + GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx), + g_combiner); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(wait_loop(30, &ev2)); GPR_ASSERT(result != nullptr); grpc_channel_args_destroy(result); - GRPC_RESOLVER_UNREF(resolver, "test"); GRPC_COMBINER_UNREF(g_combiner, "test"); } diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc new file mode 100644 index 0000000000..9402a605b3 --- /dev/null +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -0,0 +1,303 @@ +/* + * + * Copyright 2015 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 <cstring> + +#include <grpc/support/log.h> + +#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" +#include "src/core/ext/filters/client_channel/resolver_registry.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/memory.h" +#include "src/core/lib/iomgr/combiner.h" +#include "src/core/lib/iomgr/sockaddr_utils.h" +#include "test/core/util/test_config.h" + +static grpc_combiner* g_combiner; + +static void (*g_default_grpc_resolve_address)( + const char* name, const char* default_port, + grpc_pollset_set* interested_parties, grpc_closure* on_done, + grpc_resolved_addresses** addrs); + +grpc_ares_request* (*g_default_dns_lookup_ares)( + const char* dns_server, const char* name, const char* default_port, + grpc_pollset_set* interested_parties, grpc_closure* on_done, + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json); + +// Counter incremented by test_resolve_address_impl indicating the number of +// times a system-level resolution has happened. +static int g_resolution_count; + +struct iomgr_args { + gpr_event ev; + gpr_atm done_atm; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; +} g_iomgr_args; + +// Wrapper around g_default_grpc_resolve_address in order to count the number of +// times we incur in a system-level name resolution. +static void test_resolve_address_impl(const char* name, + const char* default_port, + grpc_pollset_set* interested_parties, + grpc_closure* on_done, + grpc_resolved_addresses** addrs) { + g_default_grpc_resolve_address(name, default_port, g_iomgr_args.pollset_set, + on_done, addrs); + ++g_resolution_count; +} + +grpc_ares_request* test_dns_lookup_ares( + const char* dns_server, const char* name, const char* default_port, + grpc_pollset_set* interested_parties, grpc_closure* on_done, + grpc_lb_addresses** addrs, bool check_grpclb, char** service_config_json) { + grpc_ares_request* result = g_default_dns_lookup_ares( + dns_server, name, default_port, g_iomgr_args.pollset_set, on_done, addrs, + check_grpclb, service_config_json); + ++g_resolution_count; + return result; +} + +static gpr_timespec test_deadline(void) { + return grpc_timeout_seconds_to_deadline(100); +} + +static void do_nothing(void* arg, grpc_error* error) {} + +void iomgr_args_init(iomgr_args* args) { + gpr_event_init(&args->ev); + args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); + grpc_pollset_init(args->pollset, &args->mu); + args->pollset_set = grpc_pollset_set_create(); + grpc_pollset_set_add_pollset(args->pollset_set, args->pollset); + gpr_atm_rel_store(&args->done_atm, 0); +} + +void iomgr_args_finish(iomgr_args* args) { + GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); + grpc_pollset_set_del_pollset(args->pollset_set, args->pollset); + grpc_pollset_set_destroy(args->pollset_set); + grpc_closure do_nothing_cb; + GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr, + grpc_schedule_on_exec_ctx); + gpr_mu_lock(args->mu); + grpc_pollset_shutdown(args->pollset, &do_nothing_cb); + gpr_mu_unlock(args->mu); + // exec_ctx needs to be flushed before calling grpc_pollset_destroy() + grpc_core::ExecCtx::Get()->Flush(); + grpc_pollset_destroy(args->pollset); + gpr_free(args->pollset); +} + +static grpc_millis n_sec_deadline(int seconds) { + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); +} + +static void poll_pollset_until_request_done(iomgr_args* args) { + grpc_core::ExecCtx exec_ctx; + grpc_millis deadline = n_sec_deadline(10); + while (true) { + bool done = gpr_atm_acq_load(&args->done_atm) != 0; + if (done) { + break; + } + grpc_millis time_left = deadline - grpc_core::ExecCtx::Get()->Now(); + gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); + GPR_ASSERT(time_left >= 0); + grpc_pollset_worker* worker = nullptr; + gpr_mu_lock(args->mu); + GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(args->pollset, &worker, + n_sec_deadline(1))); + gpr_mu_unlock(args->mu); + grpc_core::ExecCtx::Get()->Flush(); + } + gpr_event_set(&args->ev, (void*)1); +} + +struct OnResolutionCallbackArg { + const char* uri_str = nullptr; + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver; + grpc_channel_args* result = nullptr; + grpc_millis delay_before_second_resolution = 0; + bool using_cares = false; +}; + +// Counter for the number of times a resolution notification callback has been +// invoked. +static int g_on_resolution_invocations_count; + +// Set to true by the last callback in the resolution chain. +bool g_all_callbacks_invoked; + +void on_third_resolution(void* arg, grpc_error* error) { + OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg); + GPR_ASSERT(error == GRPC_ERROR_NONE); + ++g_on_resolution_invocations_count; + grpc_channel_args_destroy(cb_arg->result); + gpr_log(GPR_INFO, + "3rd: g_on_resolution_invocations_count: %d, g_resolution_count: %d", + g_on_resolution_invocations_count, g_resolution_count); + // In this case we expect to have incurred in another system-level resolution + // because on_second_resolution slept for longer than the min resolution + // period. + GPR_ASSERT(g_on_resolution_invocations_count == 3); + GPR_ASSERT(g_resolution_count == 2); + cb_arg->resolver.reset(); + if (cb_arg->using_cares) { + gpr_atm_rel_store(&g_iomgr_args.done_atm, 1); + gpr_mu_lock(g_iomgr_args.mu); + GRPC_LOG_IF_ERROR("pollset_kick", + grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); + gpr_mu_unlock(g_iomgr_args.mu); + } + grpc_core::Delete(cb_arg); + g_all_callbacks_invoked = true; +} + +void on_second_resolution(void* arg, grpc_error* error) { + OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg); + ++g_on_resolution_invocations_count; + grpc_channel_args_destroy(cb_arg->result); + + gpr_log(GPR_INFO, + "2nd: g_on_resolution_invocations_count: %d, g_resolution_count: %d", + g_on_resolution_invocations_count, g_resolution_count); + // The resolution request for which this function is the callback happened + // before the min resolution period. Therefore, no new system-level + // resolutions happened, as indicated by g_resolution_count. + GPR_ASSERT(g_on_resolution_invocations_count == 2); + GPR_ASSERT(g_resolution_count == 1); + grpc_core::ExecCtx::Get()->TestOnlySetNow( + cb_arg->delay_before_second_resolution * 2); + cb_arg->resolver->NextLocked( + &cb_arg->result, + GRPC_CLOSURE_CREATE(on_third_resolution, arg, + grpc_combiner_scheduler(g_combiner))); + cb_arg->resolver->RequestReresolutionLocked(); + if (cb_arg->using_cares) { + gpr_mu_lock(g_iomgr_args.mu); + GRPC_LOG_IF_ERROR("pollset_kick", + grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); + gpr_mu_unlock(g_iomgr_args.mu); + } +} + +void on_first_resolution(void* arg, grpc_error* error) { + OnResolutionCallbackArg* cb_arg = static_cast<OnResolutionCallbackArg*>(arg); + ++g_on_resolution_invocations_count; + grpc_channel_args_destroy(cb_arg->result); + cb_arg->resolver->NextLocked( + &cb_arg->result, + GRPC_CLOSURE_CREATE(on_second_resolution, arg, + grpc_combiner_scheduler(g_combiner))); + cb_arg->resolver->RequestReresolutionLocked(); + gpr_log(GPR_INFO, + "1st: g_on_resolution_invocations_count: %d, g_resolution_count: %d", + g_on_resolution_invocations_count, g_resolution_count); + // Theres one initial system-level resolution and one invocation of a + // notification callback (the current function). + GPR_ASSERT(g_on_resolution_invocations_count == 1); + GPR_ASSERT(g_resolution_count == 1); + if (cb_arg->using_cares) { + gpr_mu_lock(g_iomgr_args.mu); + GRPC_LOG_IF_ERROR("pollset_kick", + grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); + gpr_mu_unlock(g_iomgr_args.mu); + } +} + +static void start_test_under_combiner(void* arg, grpc_error* error) { + OnResolutionCallbackArg* res_cb_arg = + static_cast<OnResolutionCallbackArg*>(arg); + + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); + grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, 0); + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", res_cb_arg->uri_str, + factory->scheme()); + GPR_ASSERT(uri != nullptr); + grpc_core::ResolverArgs args; + args.uri = uri; + args.combiner = g_combiner; + g_on_resolution_invocations_count = 0; + g_resolution_count = 0; + constexpr int kMinResolutionPeriodMs = 1000; + + grpc_arg cooldown_arg; + cooldown_arg.key = + const_cast<char*>(GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); + cooldown_arg.type = GRPC_ARG_INTEGER; + cooldown_arg.value.integer = kMinResolutionPeriodMs; + auto* cooldown_channel_args = + grpc_channel_args_copy_and_add(nullptr, &cooldown_arg, 1); + args.args = cooldown_channel_args; + res_cb_arg->resolver = factory->CreateResolver(args); + grpc_channel_args_destroy(cooldown_channel_args); + GPR_ASSERT(res_cb_arg->resolver != nullptr); + res_cb_arg->delay_before_second_resolution = kMinResolutionPeriodMs; + // First resolution, would incur in system-level resolution. + res_cb_arg->resolver->NextLocked( + &res_cb_arg->result, + GRPC_CLOSURE_CREATE(on_first_resolution, res_cb_arg, + grpc_combiner_scheduler(g_combiner))); + grpc_uri_destroy(uri); +} + +static void test_cooldown(bool using_cares) { + grpc_core::ExecCtx exec_ctx; + if (using_cares) iomgr_args_init(&g_iomgr_args); + OnResolutionCallbackArg* res_cb_arg = + grpc_core::New<OnResolutionCallbackArg>(); + res_cb_arg->uri_str = "dns:127.0.0.1"; + res_cb_arg->using_cares = using_cares; + + GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(start_test_under_combiner, res_cb_arg, + grpc_combiner_scheduler(g_combiner)), + GRPC_ERROR_NONE); + if (using_cares) { + grpc_core::ExecCtx::Get()->Flush(); + poll_pollset_until_request_done(&g_iomgr_args); + iomgr_args_finish(&g_iomgr_args); + } +} + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + grpc_init(); + + g_combiner = grpc_combiner_create(); + + const bool using_cares = (grpc_resolve_address == grpc_resolve_address_ares); + g_default_grpc_resolve_address = grpc_resolve_address; + g_default_dns_lookup_ares = grpc_dns_lookup_ares; + grpc_dns_lookup_ares = test_dns_lookup_ares; + grpc_resolve_address = test_resolve_address_impl; + + test_cooldown(using_cares); + + { + grpc_core::ExecCtx exec_ctx; + GRPC_COMBINER_UNREF(g_combiner, "test"); + } + grpc_shutdown(); + GPR_ASSERT(g_all_callbacks_invoked); + return 0; +} diff --git a/test/core/client_channel/resolvers/dns_resolver_test.cc b/test/core/client_channel/resolvers/dns_resolver_test.cc index 80667908ef..e3fba2838c 100644 --- a/test/core/client_channel/resolvers/dns_resolver_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_test.cc @@ -27,47 +27,46 @@ static grpc_combiner* g_combiner; -static void test_succeeds(grpc_resolver_factory* factory, const char* string) { +static void test_succeeds(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver != nullptr); - GRPC_RESOLVER_UNREF(resolver, "test_succeeds"); grpc_uri_destroy(uri); } -static void test_fails(grpc_resolver_factory* factory, const char* string) { +static void test_fails(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver == nullptr); grpc_uri_destroy(uri); } int main(int argc, char** argv) { - grpc_resolver_factory* dns; grpc_test_init(argc, argv); grpc_init(); g_combiner = grpc_combiner_create(); - dns = grpc_resolver_factory_lookup("dns"); + grpc_core::ResolverFactory* dns = + grpc_core::ResolverRegistry::LookupResolverFactory("dns"); test_succeeds(dns, "dns:10.2.1.1"); test_succeeds(dns, "dns:10.2.1.1:1234"); @@ -78,7 +77,6 @@ int main(int argc, char** argv) { test_fails(dns, "ipv4://8.8.8.8/8.8.8.8:8888"); } - grpc_resolver_factory_unref(dns); { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc index d85cbb1d03..03af8954e1 100644 --- a/test/core/client_channel/resolvers/fake_resolver_test.cc +++ b/test/core/client_channel/resolvers/fake_resolver_test.cc @@ -27,25 +27,26 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/test_config.h" -static grpc_resolver* build_fake_resolver( +static grpc_core::OrphanablePtr<grpc_core::Resolver> build_fake_resolver( grpc_combiner* combiner, - grpc_fake_resolver_response_generator* response_generator) { - grpc_resolver_factory* factory = grpc_resolver_factory_lookup("fake"); + grpc_core::FakeResolverResponseGenerator* response_generator) { + grpc_core::ResolverFactory* factory = + grpc_core::ResolverRegistry::LookupResolverFactory("fake"); grpc_arg generator_arg = - grpc_fake_resolver_response_generator_arg(response_generator); - grpc_resolver_args args; - memset(&args, 0, sizeof(args)); + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator); grpc_channel_args channel_args = {1, &generator_arg}; + grpc_core::ResolverArgs args; args.args = &channel_args; args.combiner = combiner; - grpc_resolver* resolver = - grpc_resolver_factory_create_resolver(factory, &args); - grpc_resolver_factory_unref(factory); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); return resolver; } @@ -55,11 +56,13 @@ typedef struct on_resolution_arg { gpr_event ev; } on_resolution_arg; +// Callback to check the resolution result is as expected. void on_resolution_cb(void* arg, grpc_error* error) { + if (error != GRPC_ERROR_NONE) return; on_resolution_arg* res = static_cast<on_resolution_arg*>(arg); // We only check the addresses channel arg because that's the only one // explicitly set by the test via - // grpc_fake_resolver_response_generator_set_response. + // FakeResolverResponseGenerator::SetResponse(). const grpc_lb_addresses* actual_lb_addresses = grpc_lb_addresses_find_channel_arg(res->resolver_result); const grpc_lb_addresses* expected_lb_addresses = @@ -71,97 +74,167 @@ void on_resolution_cb(void* arg, grpc_error* error) { gpr_event_set(&res->ev, (void*)1); } -static void test_fake_resolver() { - grpc_core::ExecCtx exec_ctx; - grpc_combiner* combiner = grpc_combiner_create(); - // Create resolver. - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_response_generator_create(); - grpc_resolver* resolver = build_fake_resolver(combiner, response_generator); - GPR_ASSERT(resolver != nullptr); - - // Setup expectations. - grpc_uri* uris[] = {grpc_uri_parse("ipv4:10.2.1.1:1234", true), - grpc_uri_parse("ipv4:127.0.0.1:4321", true)}; - const char* balancer_names[] = {"name1", "name2"}; - const bool is_balancer[] = {true, false}; - grpc_lb_addresses* addresses = grpc_lb_addresses_create(3, nullptr); - for (size_t i = 0; i < GPR_ARRAY_SIZE(uris); ++i) { +// Create a new resolution containing 2 addresses. +static grpc_channel_args* create_new_resolver_result() { + static size_t test_counter = 0; + const size_t num_addresses = 2; + char* uri_string; + char* balancer_name; + // Create grpc_lb_addresses. + grpc_lb_addresses* addresses = + grpc_lb_addresses_create(num_addresses, nullptr); + for (size_t i = 0; i < num_addresses; ++i) { + gpr_asprintf(&uri_string, "ipv4:127.0.0.1:100%" PRIuPTR, + test_counter * num_addresses + i); + grpc_uri* uri = grpc_uri_parse(uri_string, true); + gpr_asprintf(&balancer_name, "balancer%" PRIuPTR, + test_counter * num_addresses + i); grpc_lb_addresses_set_address_from_uri( - addresses, i, uris[i], is_balancer[i], balancer_names[i], nullptr); - grpc_uri_destroy(uris[i]); + addresses, i, uri, bool(num_addresses % 2), balancer_name, nullptr); + gpr_free(balancer_name); + grpc_uri_destroy(uri); + gpr_free(uri_string); } + // Convert grpc_lb_addresses to grpc_channel_args. const grpc_arg addresses_arg = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args* results = grpc_channel_args_copy_and_add(nullptr, &addresses_arg, 1); grpc_lb_addresses_destroy(addresses); + ++test_counter; + return results; +} + +static on_resolution_arg create_on_resolution_arg(grpc_channel_args* results) { on_resolution_arg on_res_arg; memset(&on_res_arg, 0, sizeof(on_res_arg)); on_res_arg.expected_resolver_result = results; gpr_event_init(&on_res_arg.ev); + return on_res_arg; +} + +static void test_fake_resolver() { + grpc_core::ExecCtx exec_ctx; + grpc_combiner* combiner = grpc_combiner_create(); + // Create resolver. + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + build_fake_resolver(combiner, response_generator.get()); + GPR_ASSERT(resolver.get() != nullptr); + // Test 1: normal resolution. + // next_results != NULL, reresolution_results == NULL, last_used_results == + // NULL. Expected response is next_results. + grpc_channel_args* results = create_new_resolver_result(); + on_resolution_arg on_res_arg = create_on_resolution_arg(results); grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - - // Set resolver results and trigger first resolution. on_resolution_cb - // performs the checks. - grpc_fake_resolver_response_generator_set_response(response_generator, - results); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + // Resolution won't be triggered until next_results is set. + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); - - // Setup update. - grpc_uri* uris_update[] = {grpc_uri_parse("ipv4:192.168.1.0:31416", true)}; - const char* balancer_names_update[] = {"name3"}; - const bool is_balancer_update[] = {false}; - grpc_lb_addresses* addresses_update = grpc_lb_addresses_create(1, nullptr); - for (size_t i = 0; i < GPR_ARRAY_SIZE(uris_update); ++i) { - grpc_lb_addresses_set_address_from_uri(addresses_update, i, uris_update[i], - is_balancer_update[i], - balancer_names_update[i], nullptr); - grpc_uri_destroy(uris_update[i]); - } - - grpc_arg addresses_update_arg = - grpc_lb_addresses_create_channel_arg(addresses_update); - grpc_channel_args* results_update = - grpc_channel_args_copy_and_add(nullptr, &addresses_update_arg, 1); - grpc_lb_addresses_destroy(addresses_update); - - // Setup expectations for the update. - on_resolution_arg on_res_arg_update; - memset(&on_res_arg_update, 0, sizeof(on_res_arg_update)); - on_res_arg_update.expected_resolver_result = results_update; - gpr_event_init(&on_res_arg_update.ev); - on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg_update, + // Test 2: update resolution. + // next_results != NULL, reresolution_results == NULL, last_used_results != + // NULL. Expected response is next_results. + results = create_new_resolver_result(); + grpc_channel_args* last_used_results = grpc_channel_args_copy(results); + on_res_arg = create_on_resolution_arg(results); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, grpc_combiner_scheduler(combiner)); - - // Set updated resolver results and trigger a second resolution. - grpc_fake_resolver_response_generator_set_response(response_generator, - results_update); - grpc_resolver_next_locked(resolver, &on_res_arg_update.resolver_result, - on_resolution); + // Resolution won't be triggered until next_results is set. + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); grpc_core::ExecCtx::Get()->Flush(); - GPR_ASSERT(gpr_event_wait(&on_res_arg_update.ev, + GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_seconds_to_deadline(5)) != nullptr); - - // Requesting a new resolution without re-senting the response shouldn't - // trigger the resolution callback. + // Test 3: fallback re-resolution. + // next_results == NULL, reresolution_results == NULL, last_used_results != + // NULL. Expected response is last_used_results. + on_res_arg = create_on_resolution_arg(last_used_results); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Trigger a re-resolution. + resolver->RequestReresolutionLocked(); + grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, + grpc_timeout_seconds_to_deadline(5)) != nullptr); + // Test 4: normal re-resolution. + // next_results == NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is reresolution_results. + grpc_channel_args* reresolution_results = create_new_resolver_result(); + on_res_arg = + create_on_resolution_arg(grpc_channel_args_copy(reresolution_results)); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Set reresolution_results. + response_generator->SetReresolutionResponse(reresolution_results); + // Flush here to guarantee that the response has been set. + grpc_core::ExecCtx::Get()->Flush(); + // Trigger a re-resolution. + resolver->RequestReresolutionLocked(); + grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, + grpc_timeout_seconds_to_deadline(5)) != nullptr); + // Test 5: repeat re-resolution. + // next_results == NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is reresolution_results. + on_res_arg = create_on_resolution_arg(reresolution_results); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Trigger a re-resolution. + resolver->RequestReresolutionLocked(); + grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, + grpc_timeout_seconds_to_deadline(5)) != nullptr); + // Test 6: normal resolution. + // next_results != NULL, reresolution_results != NULL, last_used_results != + // NULL. Expected response is next_results. + results = create_new_resolver_result(); + last_used_results = grpc_channel_args_copy(results); + on_res_arg = create_on_resolution_arg(results); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + // Resolution won't be triggered until next_results is set. + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + response_generator->SetResponse(results); + grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, + grpc_timeout_seconds_to_deadline(5)) != nullptr); + // Test 7: fallback re-resolution. + // next_results == NULL, reresolution_results == NULL, last_used_results != + // NULL. Expected response is last_used_results. + on_res_arg = create_on_resolution_arg(last_used_results); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); + // Reset reresolution_results. + response_generator->SetReresolutionResponse(nullptr); + // Flush here to guarantee that reresolution_results has been reset. + grpc_core::ExecCtx::Get()->Flush(); + // Trigger a re-resolution. + resolver->RequestReresolutionLocked(); + grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, + grpc_timeout_seconds_to_deadline(5)) != nullptr); + // Test 8: no-op. + // Requesting a new resolution without setting the response shouldn't trigger + // the resolution callback. memset(&on_res_arg, 0, sizeof(on_res_arg)); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); + on_resolution = GRPC_CLOSURE_CREATE(on_resolution_cb, &on_res_arg, + grpc_combiner_scheduler(combiner)); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT(gpr_event_wait(&on_res_arg.ev, grpc_timeout_milliseconds_to_deadline(100)) == nullptr); - + // Clean up. GRPC_COMBINER_UNREF(combiner, "test_fake_resolver"); - GRPC_RESOLVER_UNREF(resolver, "test_fake_resolver"); - - grpc_fake_resolver_response_generator_unref(response_generator); } int main(int argc, char** argv) { diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc index 07ee133ee3..b9287c2468 100644 --- a/test/core/client_channel/resolvers/sockaddr_resolver_test.cc +++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.cc @@ -40,18 +40,18 @@ void on_resolution_cb(void* arg, grpc_error* error) { grpc_channel_args_destroy(res->resolver_result); } -static void test_succeeds(grpc_resolver_factory* factory, const char* string) { +static void test_succeeds(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver != nullptr); on_resolution_arg on_res_arg; @@ -60,40 +60,39 @@ static void test_succeeds(grpc_resolver_factory* factory, const char* string) { grpc_closure* on_resolution = GRPC_CLOSURE_CREATE( on_resolution_cb, &on_res_arg, grpc_schedule_on_exec_ctx); - grpc_resolver_next_locked(resolver, &on_res_arg.resolver_result, - on_resolution); - GRPC_RESOLVER_UNREF(resolver, "test_succeeds"); + resolver->NextLocked(&on_res_arg.resolver_result, on_resolution); grpc_uri_destroy(uri); /* Flush ExecCtx to avoid stack-use-after-scope on on_res_arg which is * accessed in the closure on_resolution_cb */ grpc_core::ExecCtx::Get()->Flush(); } -static void test_fails(grpc_resolver_factory* factory, const char* string) { +static void test_fails(grpc_core::ResolverFactory* factory, + const char* string) { + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->scheme()); grpc_core::ExecCtx exec_ctx; grpc_uri* uri = grpc_uri_parse(string, 0); - grpc_resolver_args args; - grpc_resolver* resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, - factory->vtable->scheme); GPR_ASSERT(uri); - memset(&args, 0, sizeof(args)); + grpc_core::ResolverArgs args; args.uri = uri; args.combiner = g_combiner; - resolver = grpc_resolver_factory_create_resolver(factory, &args); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + factory->CreateResolver(args); GPR_ASSERT(resolver == nullptr); grpc_uri_destroy(uri); } int main(int argc, char** argv) { - grpc_resolver_factory *ipv4, *ipv6; grpc_test_init(argc, argv); grpc_init(); g_combiner = grpc_combiner_create(); - ipv4 = grpc_resolver_factory_lookup("ipv4"); - ipv6 = grpc_resolver_factory_lookup("ipv6"); + grpc_core::ResolverFactory* ipv4 = + grpc_core::ResolverRegistry::LookupResolverFactory("ipv4"); + grpc_core::ResolverFactory* ipv6 = + grpc_core::ResolverRegistry::LookupResolverFactory("ipv6"); test_fails(ipv4, "ipv4:10.2.1.1"); test_succeeds(ipv4, "ipv4:10.2.1.1:1234"); @@ -109,9 +108,6 @@ int main(int argc, char** argv) { test_fails(ipv6, "ipv6:[::]:123456"); test_fails(ipv6, "ipv6:www.google.com"); - grpc_resolver_factory_unref(ipv4); - grpc_resolver_factory_unref(ipv6); - { grpc_core::ExecCtx exec_ctx; GRPC_COMBINER_UNREF(g_combiner, "test"); diff --git a/test/core/compression/BUILD b/test/core/compression/BUILD index ee71eecfeb..b60390dbfe 100644 --- a/test/core/compression/BUILD +++ b/test/core/compression/BUILD @@ -53,3 +53,15 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "stream_compress_test", + srcs = ["stream_compression_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + ], +) diff --git a/test/core/compression/algorithm_test.cc b/test/core/compression/algorithm_test.cc index 9e811e9af1..3dcddf3e67 100644 --- a/test/core/compression/algorithm_test.cc +++ b/test/core/compression/algorithm_test.cc @@ -23,12 +23,13 @@ #include <grpc/grpc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/static_metadata.h" #include "test/core/util/test_config.h" +const uint32_t message_prefix_length = 0; +const uint32_t stream_prefix_length = 7; static void test_algorithm_mesh(void) { int i; @@ -48,9 +49,26 @@ static void test_algorithm_mesh(void) { mdstr = grpc_slice_from_copied_string(name); GPR_ASSERT(grpc_slice_eq(mdstr, grpc_compression_algorithm_slice(parsed))); GPR_ASSERT(parsed == grpc_compression_algorithm_from_slice(mdstr)); - mdelem = grpc_compression_encoding_mdelem(parsed); - GPR_ASSERT(grpc_slice_eq(GRPC_MDVALUE(mdelem), mdstr)); - GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); + if (parsed == 0) { + continue; + } else if (grpc_compression_algorithm_is_message(parsed)) { + mdelem = grpc_message_compression_encoding_mdelem( + grpc_compression_algorithm_to_message_compression_algorithm(parsed)); + grpc_slice value = GRPC_MDVALUE(mdelem); + GPR_ASSERT(0 == memcmp(&name[message_prefix_length], + GRPC_SLICE_START_PTR(value), + GRPC_SLICE_LENGTH(value))); + GPR_ASSERT(grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_GRPC_ENCODING)); + } else { + mdelem = grpc_stream_compression_encoding_mdelem( + grpc_compression_algorithm_to_stream_compression_algorithm(parsed)); + grpc_slice value = GRPC_MDVALUE(mdelem); + GPR_ASSERT(0 == memcmp(&name[stream_prefix_length], + GRPC_SLICE_START_PTR(value), + GRPC_SLICE_LENGTH(value))); + GPR_ASSERT( + grpc_slice_eq(GRPC_MDKEY(mdelem), GRPC_MDSTR_CONTENT_ENCODING)); + } grpc_slice_unref_internal(mdstr); GRPC_MDELEM_UNREF(mdelem); } diff --git a/test/core/compression/compression_test.cc b/test/core/compression/compression_test.cc index a1a9441c8d..6522988c66 100644 --- a/test/core/compression/compression_test.cc +++ b/test/core/compression/compression_test.cc @@ -22,15 +22,16 @@ #include <grpc/compression.h> #include <grpc/grpc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static void test_compression_algorithm_parse(void) { size_t i; - const char* valid_names[] = {"identity", "gzip", "deflate"}; + const char* valid_names[] = {"identity", "gzip", "deflate", "stream/gzip"}; const grpc_compression_algorithm valid_algorithms[] = { - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE}; + GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE, + GRPC_COMPRESS_STREAM_GZIP}; const char* invalid_names[] = {"gzip2", "foo", "", "2gzip"}; gpr_log(GPR_DEBUG, "test_compression_algorithm_parse"); @@ -59,9 +60,10 @@ static void test_compression_algorithm_name(void) { int success; const char* name; size_t i; - const char* valid_names[] = {"identity", "gzip", "deflate"}; + const char* valid_names[] = {"identity", "gzip", "deflate", "stream/gzip"}; const grpc_compression_algorithm valid_algorithms[] = { - GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE}; + GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_DEFLATE, + GRPC_COMPRESS_STREAM_GZIP}; gpr_log(GPR_DEBUG, "test_compression_algorithm_name"); @@ -171,6 +173,54 @@ static void test_compression_algorithm_for_level(void) { grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, accepted_encodings)); } + + { + /* accept stream gzip */ + uint32_t accepted_encodings = 0; + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, + accepted_encodings)); + } + + { + /* accept all algorithms */ + uint32_t accepted_encodings = 0; + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */ + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE); + GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_STREAM_GZIP); + + GPR_ASSERT(GRPC_COMPRESS_NONE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_GZIP == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED, + accepted_encodings)); + + GPR_ASSERT(GRPC_COMPRESS_DEFLATE == + grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH, + accepted_encodings)); + } } static void test_compression_enable_disable_algorithm(void) { diff --git a/test/core/compression/message_compress_test.cc b/test/core/compression/message_compress_test.cc index b03ca4c4cb..e3fe825fdf 100644 --- a/test/core/compression/message_compress_test.cc +++ b/test/core/compression/message_compress_test.cc @@ -23,9 +23,9 @@ #include <grpc/grpc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/murmur_hash.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" @@ -39,7 +39,7 @@ typedef enum { } compressability; static void assert_passthrough(grpc_slice value, - grpc_compression_algorithm algorithm, + grpc_message_compression_algorithm algorithm, grpc_slice_split_mode uncompressed_split_mode, grpc_slice_split_mode compressed_split_mode, compressability compress_result_check) { @@ -51,7 +51,8 @@ static void assert_passthrough(grpc_slice value, int was_compressed; const char* algorithm_name; - GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algorithm_name) != 0); + GPR_ASSERT( + grpc_message_compression_algorithm_name(algorithm, &algorithm_name) != 0); gpr_log(GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR " value_hash=0x%08x " @@ -92,7 +93,8 @@ static void assert_passthrough(grpc_slice value, { grpc_core::ExecCtx exec_ctx; GPR_ASSERT(grpc_msg_decompress( - was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output)); + was_compressed ? algorithm : GRPC_MESSAGE_COMPRESS_NONE, &compressed, + &output)); } final = grpc_slice_merge(output.slices, output.count); @@ -112,8 +114,8 @@ static grpc_slice repeated(char c, size_t length) { } static compressability get_compressability( - test_value id, grpc_compression_algorithm algorithm) { - if (algorithm == GRPC_COMPRESS_NONE) return SHOULD_NOT_COMPRESS; + test_value id, grpc_message_compression_algorithm algorithm) { + if (algorithm == GRPC_MESSAGE_COMPRESS_NONE) return SHOULD_NOT_COMPRESS; switch (id) { case ONE_A: return SHOULD_NOT_COMPRESS; @@ -150,13 +152,13 @@ static void test_tiny_data_compress(void) { grpc_slice_buffer_init(&output); grpc_slice_buffer_add(&input, create_test_value(ONE_A)); - for (int i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { - if (i == GRPC_COMPRESS_NONE) continue; + for (int i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) { + if (i == GRPC_MESSAGE_COMPRESS_NONE) continue; grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(0 == - grpc_msg_compress(static_cast<grpc_compression_algorithm>(i), - &input, &output)); + GPR_ASSERT(0 == grpc_msg_compress( + static_cast<grpc_message_compression_algorithm>(i), + &input, &output)); GPR_ASSERT(1 == output.count); } @@ -178,7 +180,7 @@ static void test_bad_decompression_data_crc(void) { grpc_core::ExecCtx exec_ctx; /* compress it */ - grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted); + grpc_msg_compress(GRPC_MESSAGE_COMPRESS_GZIP, &input, &corrupted); /* corrupt the output by smashing the CRC */ GPR_ASSERT(corrupted.count > 1); GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8); @@ -186,7 +188,8 @@ static void test_bad_decompression_data_crc(void) { memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4); /* try (and fail) to decompress the corrupted compresed buffer */ - GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output)); + GPR_ASSERT(0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_GZIP, &corrupted, + &output)); grpc_slice_buffer_destroy(&input); grpc_slice_buffer_destroy(&corrupted); @@ -206,7 +209,8 @@ static void test_bad_decompression_data_trailing_garbage(void) { /* try (and fail) to decompress the invalid compresed buffer */ grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output)); + GPR_ASSERT( + 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output)); grpc_slice_buffer_destroy(&input); grpc_slice_buffer_destroy(&output); @@ -223,7 +227,8 @@ static void test_bad_decompression_data_stream(void) { /* try (and fail) to decompress the invalid compresed buffer */ grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output)); + GPR_ASSERT( + 0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_DEFLATE, &input, &output)); grpc_slice_buffer_destroy(&input); grpc_slice_buffer_destroy(&output); @@ -240,13 +245,14 @@ static void test_bad_compression_algorithm(void) { &input, grpc_slice_from_copied_string("Never gonna give you up")); grpc_core::ExecCtx exec_ctx; - was_compressed = - grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); + was_compressed = grpc_msg_compress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, + &input, &output); GPR_ASSERT(0 == was_compressed); - was_compressed = grpc_msg_compress(static_cast<grpc_compression_algorithm>( - GRPC_COMPRESS_ALGORITHMS_COUNT + 123), - &input, &output); + was_compressed = + grpc_msg_compress(static_cast<grpc_message_compression_algorithm>( + GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123), + &input, &output); GPR_ASSERT(0 == was_compressed); grpc_slice_buffer_destroy(&input); @@ -264,13 +270,13 @@ static void test_bad_decompression_algorithm(void) { grpc_slice_from_copied_string( "I'm not really compressed but it doesn't matter")); grpc_core::ExecCtx exec_ctx; - was_decompressed = - grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); + was_decompressed = grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT, + &input, &output); GPR_ASSERT(0 == was_decompressed); was_decompressed = - grpc_msg_decompress(static_cast<grpc_compression_algorithm>( - GRPC_COMPRESS_ALGORITHMS_COUNT + 123), + grpc_msg_decompress(static_cast<grpc_message_compression_algorithm>( + GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT + 123), &input, &output); GPR_ASSERT(0 == was_decompressed); @@ -289,17 +295,18 @@ int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); - for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { + for (i = 0; i < GRPC_MESSAGE_COMPRESS_ALGORITHMS_COUNT; i++) { for (j = 0; j < GPR_ARRAY_SIZE(uncompressed_split_modes); j++) { for (k = 0; k < GPR_ARRAY_SIZE(compressed_split_modes); k++) { for (m = 0; m < TEST_VALUE_COUNT; m++) { grpc_slice slice = create_test_value(static_cast<test_value>(m)); assert_passthrough( - slice, static_cast<grpc_compression_algorithm>(i), + slice, static_cast<grpc_message_compression_algorithm>(i), static_cast<grpc_slice_split_mode>(j), static_cast<grpc_slice_split_mode>(k), - get_compressability(static_cast<test_value>(m), - static_cast<grpc_compression_algorithm>(i))); + get_compressability( + static_cast<test_value>(m), + static_cast<grpc_message_compression_algorithm>(i))); grpc_slice_unref(slice); } } diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index a8e5e291c8..2b98620164 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -27,10 +27,10 @@ #include <grpc/grpc.h> #include <grpc/slice.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index ca6d17e7c8..ff830b47cd 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -20,11 +20,11 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/service_config.h" diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc index 7bf8ae0f6e..a7b37f3c12 100644 --- a/test/core/end2end/cq_verifier.cc +++ b/test/core/end2end/cq_verifier.cc @@ -28,7 +28,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/event_string.h" diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc index bb30547cd2..2dc72b885f 100644 --- a/test/core/end2end/dualstack_socket_test.cc +++ b/test/core/end2end/dualstack_socket_test.cc @@ -25,10 +25,10 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/resolve_address.h" diff --git a/test/core/end2end/end2end_test.sh b/test/core/end2end/end2end_test.sh index 3b18ae30af..b1b9a65a1b 100755 --- a/test/core/end2end/end2end_test.sh +++ b/test/core/end2end/end2end_test.sh @@ -15,4 +15,4 @@ # 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. -$1 $2 +"$1" "$2" diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 75c80aa1ff..423764ad07 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -21,16 +21,16 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index 5b9181586c..af7ddecd00 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -21,16 +21,16 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index 87d4668d50..bbf65fcd24 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -22,9 +22,10 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> + #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index b080591e85..88f24b937c 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -26,15 +26,15 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index 7104fbc581..4e0d66896b 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -26,16 +26,16 @@ #endif #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index 237841d185..ce0fed6fee 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -21,16 +21,17 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include <grpc/support/workaround_list.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index 6d15c28662..4b96fa268a 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -21,15 +21,15 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index e8e81f0930..da63f46018 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -21,17 +21,17 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/http_proxy_fixture.h" diff --git a/test/core/end2end/fixtures/h2_load_reporting.cc b/test/core/end2end/fixtures/h2_load_reporting.cc index fda5f4b052..dddeef5862 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.cc +++ b/test/core/end2end/fixtures/h2_load_reporting.cc @@ -21,17 +21,17 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 5fed4434de..795e94a9e8 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -22,9 +22,10 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> + #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/data/ssl_test_data.h" diff --git a/test/core/end2end/fixtures/h2_proxy.cc b/test/core/end2end/fixtures/h2_proxy.cc index 295654cb6a..4379cddf77 100644 --- a/test/core/end2end/fixtures/h2_proxy.cc +++ b/test/core/end2end/fixtures/h2_proxy.cc @@ -21,15 +21,15 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc index 236780b8d3..92b9a463c1 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.cc +++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc @@ -29,7 +29,7 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc index b68279fd71..46acf1f615 100644 --- a/test/core/end2end/fixtures/h2_sockpair.cc +++ b/test/core/end2end/fixtures/h2_sockpair.cc @@ -24,7 +24,7 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc index 350be138ca..6499c90271 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc @@ -24,7 +24,7 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index 8c5c8a2f3f..bbcc88e4f3 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -22,11 +22,11 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.cc b/test/core/end2end/fixtures/h2_ssl_proxy.cc index 3f0646cf0f..6b0b891b18 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.cc +++ b/test/core/end2end/fixtures/h2_ssl_proxy.cc @@ -22,11 +22,11 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/end2end/fixtures/h2_uds.cc b/test/core/end2end/fixtures/h2_uds.cc index 1944dd84a3..41045c278c 100644 --- a/test/core/end2end/fixtures/h2_uds.cc +++ b/test/core/end2end/fixtures/h2_uds.cc @@ -23,16 +23,16 @@ #include <unistd.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 8ec97df3e4..2d5e841aea 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -26,14 +26,13 @@ #include <grpc/slice_buffer.h> #include <grpc/support/alloc.h> #include <grpc/support/atm.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/closure.h" diff --git a/test/core/end2end/fixtures/inproc.cc b/test/core/end2end/fixtures/inproc.cc index b748fbf09a..796ef67ddb 100644 --- a/test/core/end2end/fixtures/inproc.cc +++ b/test/core/end2end/fixtures/inproc.cc @@ -21,15 +21,15 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index b1698c804c..7a35796e9c 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -21,12 +21,12 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/host_port.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/util/port.h" struct grpc_end2end_proxy { diff --git a/test/core/end2end/fuzzers/api_fuzzer_corpus/poc-2d730ebd78b3052e4367ad0d485208dcb205482cbcd6289f17907989b8de1fba b/test/core/end2end/fuzzers/api_fuzzer_corpus/poc-2d730ebd78b3052e4367ad0d485208dcb205482cbcd6289f17907989b8de1fba Binary files differnew file mode 100644 index 0000000000..89e28bbe37 --- /dev/null +++ b/test/core/end2end/fuzzers/api_fuzzer_corpus/poc-2d730ebd78b3052e4367ad0d485208dcb205482cbcd6289f17907989b8de1fba diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 7c77512aa9..3ed82e19bd 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -28,12 +28,13 @@ "\x1Egrpc.max_request_message_bytes" "\x1Fgrpc.max_response_message_bytes" "$/grpc.lb.v1.LoadBalancer/BalanceLoad" +"\x07deflate" +"\x04gzip" +"\x0Bstream/gzip" "\x010" "\x011" "\x012" "\x08identity" -"\x04gzip" -"\x07deflate" "\x08trailers" "\x10application/grpc" "\x04POST" diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 3383d6d5d1..cd62c3f4e2 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -22,11 +22,11 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/security/credentials/credentials.h" @@ -272,6 +272,20 @@ static void drain_cq(grpc_completion_queue* cq) { static void shutdown_server(grpc_end2end_test_fixture* f) { if (!f->server) return; + /* Perform a completion queue next, so that any pending operations can be + * finished, and resources can be released. This is so that, shutdown does not + * hang. For example, the server might be stuck in the handshaking code, which + * keeps a ref to a listener. Unless, it is unref'd, shutdown won't be able + * to proceed. + * + * (If shutdown times out, it is probably because 100ms wasn't enough. In that + * case, the deadline can be increased. Or, we could simply have another + * thread for the server to poll the completion queue while the shutdown + * progresses.) + */ + GPR_ASSERT(grpc_completion_queue_next( + f->cq, grpc_timeout_milliseconds_to_deadline(100), nullptr) + .type == GRPC_QUEUE_TIMEOUT); grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), @@ -288,8 +302,8 @@ static void shutdown_client(grpc_end2end_test_fixture* f) { } static void end_test(grpc_end2end_test_fixture* f) { - shutdown_server(f); shutdown_client(f); + shutdown_server(f); grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc index cb6b4c08ef..d2b26e7131 100644 --- a/test/core/end2end/invalid_call_argument_test.cc +++ b/test/core/end2end/invalid_call_argument_test.cc @@ -23,9 +23,9 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/end2end/tests/authority_not_supported.cc b/test/core/end2end/tests/authority_not_supported.cc index 9c8545058c..f2852f772e 100644 --- a/test/core/end2end/tests/authority_not_supported.cc +++ b/test/core/end2end/tests/authority_not_supported.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/bad_hostname.cc b/test/core/end2end/tests/bad_hostname.cc index 85e9ba1307..63bfd76120 100644 --- a/test/core/end2end/tests/bad_hostname.cc +++ b/test/core/end2end/tests/bad_hostname.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/bad_ping.cc b/test/core/end2end/tests/bad_ping.cc index 30a1b8de77..672c2f4c6e 100644 --- a/test/core/end2end/tests/bad_ping.cc +++ b/test/core/end2end/tests/bad_ping.cc @@ -25,8 +25,8 @@ #include <grpc/support/sync.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define MAX_PING_STRIKES 1 diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc index 381671e331..8a0d667428 100644 --- a/test/core/end2end/tests/binary_metadata.cc +++ b/test/core/end2end/tests/binary_metadata.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc index c5ea101c53..968dab1995 100644 --- a/test/core/end2end/tests/call_creds.cc +++ b/test/core/end2end/tests/call_creds.cc @@ -26,7 +26,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + #include "src/core/lib/gpr/string.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc index f59caf7e35..11bf4e79b7 100644 --- a/test/core/end2end/tests/cancel_after_accept.cc +++ b/test/core/end2end/tests/cancel_after_accept.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/tests/cancel_after_client_done.cc b/test/core/end2end/tests/cancel_after_client_done.cc index 9b832d435d..b0702b7f44 100644 --- a/test/core/end2end/tests/cancel_after_client_done.cc +++ b/test/core/end2end/tests/cancel_after_client_done.cc @@ -25,7 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" diff --git a/test/core/end2end/tests/cancel_after_invoke.cc b/test/core/end2end/tests/cancel_after_invoke.cc index d3891b160e..a3e36e0e3f 100644 --- a/test/core/end2end/tests/cancel_after_invoke.cc +++ b/test/core/end2end/tests/cancel_after_invoke.cc @@ -25,7 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc index b10b93978d..63e6505f0e 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.cc +++ b/test/core/end2end/tests/cancel_after_round_trip.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/tests/cancel_before_invoke.cc b/test/core/end2end/tests/cancel_before_invoke.cc index 1112375176..e9fa0466fb 100644 --- a/test/core/end2end/tests/cancel_before_invoke.cc +++ b/test/core/end2end/tests/cancel_before_invoke.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.cc b/test/core/end2end/tests/cancel_in_a_vacuum.cc index a6c534eb08..6be2d69095 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.cc +++ b/test/core/end2end/tests/cancel_in_a_vacuum.cc @@ -25,7 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" diff --git a/test/core/end2end/tests/cancel_with_status.cc b/test/core/end2end/tests/cancel_with_status.cc index 7937fd161f..6820ba5a2f 100644 --- a/test/core/end2end/tests/cancel_with_status.cc +++ b/test/core/end2end/tests/cancel_with_status.cc @@ -27,7 +27,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc index 944edc7a70..63bf472906 100644 --- a/test/core/end2end/tests/compressed_payload.cc +++ b/test/core/end2end/tests/compressed_payload.cc @@ -28,7 +28,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc index 7c94420540..33be5f1273 100644 --- a/test/core/end2end/tests/default_host.cc +++ b/test/core/end2end/tests/default_host.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/disappearing_server.cc b/test/core/end2end/tests/disappearing_server.cc index 29fb19463f..1b2f729ba8 100644 --- a/test/core/end2end/tests/disappearing_server.cc +++ b/test/core/end2end/tests/disappearing_server.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/empty_batch.cc b/test/core/end2end/tests/empty_batch.cc index c41e65ddd2..1de4b8fda8 100644 --- a/test/core/end2end/tests/empty_batch.cc +++ b/test/core/end2end/tests/empty_batch.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/filter_call_init_fails.cc b/test/core/end2end/tests/filter_call_init_fails.cc index 8f46f0bb91..f60a47f8ff 100644 --- a/test/core/end2end/tests/filter_call_init_fails.cc +++ b/test/core/end2end/tests/filter_call_init_fails.cc @@ -27,7 +27,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc index ec8f9dbe00..43f20d7cc0 100644 --- a/test/core/end2end/tests/filter_causes_close.cc +++ b/test/core/end2end/tests/filter_causes_close.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc index 845cbc01cf..d6cf3b034e 100644 --- a/test/core/end2end/tests/filter_latency.cc +++ b/test/core/end2end/tests/filter_latency.cc @@ -27,7 +27,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc index 61c658b95a..ad80f23d6f 100644 --- a/test/core/end2end/tests/filter_status_code.cc +++ b/test/core/end2end/tests/filter_status_code.cc @@ -27,7 +27,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/graceful_server_shutdown.cc b/test/core/end2end/tests/graceful_server_shutdown.cc index bf11b49fa4..3b6872bfd7 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.cc +++ b/test/core/end2end/tests/graceful_server_shutdown.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/high_initial_seqno.cc b/test/core/end2end/tests/high_initial_seqno.cc index d4d4f5a817..989cd5610f 100644 --- a/test/core/end2end/tests/high_initial_seqno.cc +++ b/test/core/end2end/tests/high_initial_seqno.cc @@ -27,7 +27,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/hpack_size.cc b/test/core/end2end/tests/hpack_size.cc index 0d6ec01e36..66b3a4019f 100644 --- a/test/core/end2end/tests/hpack_size.cc +++ b/test/core/end2end/tests/hpack_size.cc @@ -27,9 +27,9 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/idempotent_request.cc b/test/core/end2end/tests/idempotent_request.cc index 7487e4d83d..578510d407 100644 --- a/test/core/end2end/tests/idempotent_request.cc +++ b/test/core/end2end/tests/idempotent_request.cc @@ -26,7 +26,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/invoke_large_request.cc b/test/core/end2end/tests/invoke_large_request.cc index 8a67e3c2b1..b7afa97401 100644 --- a/test/core/end2end/tests/invoke_large_request.cc +++ b/test/core/end2end/tests/invoke_large_request.cc @@ -26,7 +26,8 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 6482b86825..0cdd12e9ca 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -25,10 +25,11 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + #include "src/core/ext/transport/chttp2/transport/frame_ping.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/large_metadata.cc b/test/core/end2end/tests/large_metadata.cc index 8ddf433ac0..c1343f902d 100644 --- a/test/core/end2end/tests/large_metadata.cc +++ b/test/core/end2end/tests/large_metadata.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc index e056bd547b..cfe5814755 100644 --- a/test/core/end2end/tests/load_reporting_hook.cc +++ b/test/core/end2end/tests/load_reporting_hook.cc @@ -24,7 +24,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" #include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" diff --git a/test/core/end2end/tests/max_concurrent_streams.cc b/test/core/end2end/tests/max_concurrent_streams.cc index c0539739e1..642c0f7ce6 100644 --- a/test/core/end2end/tests/max_concurrent_streams.cc +++ b/test/core/end2end/tests/max_concurrent_streams.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc index ddccfc3b51..df5fd5cc1e 100644 --- a/test/core/end2end/tests/max_connection_age.cc +++ b/test/core/end2end/tests/max_connection_age.cc @@ -24,8 +24,8 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define MAX_CONNECTION_AGE_MS 500 diff --git a/test/core/end2end/tests/max_connection_idle.cc b/test/core/end2end/tests/max_connection_idle.cc index 293ff7d1f2..09b4a54df3 100644 --- a/test/core/end2end/tests/max_connection_idle.cc +++ b/test/core/end2end/tests/max_connection_idle.cc @@ -25,8 +25,8 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define MAX_CONNECTION_IDLE_MS 500 diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc index e581f1fc20..b1757a9b0d 100644 --- a/test/core/end2end/tests/max_message_length.cc +++ b/test/core/end2end/tests/max_message_length.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/slice/slice_internal.h" diff --git a/test/core/end2end/tests/negative_deadline.cc b/test/core/end2end/tests/negative_deadline.cc index b752bf9482..b28bee0fb2 100644 --- a/test/core/end2end/tests/negative_deadline.cc +++ b/test/core/end2end/tests/negative_deadline.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/network_status_change.cc b/test/core/end2end/tests/network_status_change.cc index 7d0318fda6..809f8ffb5c 100644 --- a/test/core/end2end/tests/network_status_change.cc +++ b/test/core/end2end/tests/network_status_change.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" /* this is a private API but exposed here for testing*/ diff --git a/test/core/end2end/tests/no_logging.cc b/test/core/end2end/tests/no_logging.cc index d89918bd3e..b4908d4926 100644 --- a/test/core/end2end/tests/no_logging.cc +++ b/test/core/end2end/tests/no_logging.cc @@ -27,7 +27,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/error.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/no_op.cc b/test/core/end2end/tests/no_op.cc index 18c2367ac4..020f842219 100644 --- a/test/core/end2end/tests/no_op.cc +++ b/test/core/end2end/tests/no_op.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/payload.cc b/test/core/end2end/tests/payload.cc index 2e9513b9cb..3535d802e9 100644 --- a/test/core/end2end/tests/payload.cc +++ b/test/core/end2end/tests/payload.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/ping.cc b/test/core/end2end/tests/ping.cc index 725a425fbf..c01dfa858f 100644 --- a/test/core/end2end/tests/ping.cc +++ b/test/core/end2end/tests/ping.cc @@ -22,8 +22,8 @@ #include <grpc/support/sync.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/end2end/cq_verifier.h" #define PING_NUM 5 diff --git a/test/core/end2end/tests/ping_pong_streaming.cc b/test/core/end2end/tests/ping_pong_streaming.cc index ec7981fdcb..714a7681b2 100644 --- a/test/core/end2end/tests/ping_pong_streaming.cc +++ b/test/core/end2end/tests/ping_pong_streaming.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/proxy_auth.cc b/test/core/end2end/tests/proxy_auth.cc index 495151b592..c34505c878 100644 --- a/test/core/end2end/tests/proxy_auth.cc +++ b/test/core/end2end/tests/proxy_auth.cc @@ -31,7 +31,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/registered_call.cc b/test/core/end2end/tests/registered_call.cc index cefa89db4d..d1c37dca20 100644 --- a/test/core/end2end/tests/registered_call.cc +++ b/test/core/end2end/tests/registered_call.cc @@ -26,7 +26,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/request_with_flags.cc b/test/core/end2end/tests/request_with_flags.cc index 984d8b10f1..46023133ba 100644 --- a/test/core/end2end/tests/request_with_flags.cc +++ b/test/core/end2end/tests/request_with_flags.cc @@ -25,7 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/request_with_payload.cc b/test/core/end2end/tests/request_with_payload.cc index b3b9ee5726..28818c80e7 100644 --- a/test/core/end2end/tests/request_with_payload.cc +++ b/test/core/end2end/tests/request_with_payload.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/resource_quota_server.cc b/test/core/end2end/tests/resource_quota_server.cc index 0ee014f97d..6d35d086aa 100644 --- a/test/core/end2end/tests/resource_quota_server.cc +++ b/test/core/end2end/tests/resource_quota_server.cc @@ -25,7 +25,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/server_finishes_request.cc b/test/core/end2end/tests/server_finishes_request.cc index 743b3aeb91..f135851f86 100644 --- a/test/core/end2end/tests/server_finishes_request.cc +++ b/test/core/end2end/tests/server_finishes_request.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/shutdown_finishes_calls.cc b/test/core/end2end/tests/shutdown_finishes_calls.cc index fce23f3b6a..2e19e059ae 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.cc +++ b/test/core/end2end/tests/shutdown_finishes_calls.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/shutdown_finishes_tags.cc b/test/core/end2end/tests/shutdown_finishes_tags.cc index de64eba612..d160647295 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.cc +++ b/test/core/end2end/tests/shutdown_finishes_tags.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/simple_cacheable_request.cc b/test/core/end2end/tests/simple_cacheable_request.cc index d8034dcf6d..b4732aed3f 100644 --- a/test/core/end2end/tests/simple_cacheable_request.cc +++ b/test/core/end2end/tests/simple_cacheable_request.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" enum { TIMEOUT = 200000 }; diff --git a/test/core/end2end/tests/simple_delayed_request.cc b/test/core/end2end/tests/simple_delayed_request.cc index 0ad224f579..54517fb242 100644 --- a/test/core/end2end/tests/simple_delayed_request.cc +++ b/test/core/end2end/tests/simple_delayed_request.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/simple_metadata.cc b/test/core/end2end/tests/simple_metadata.cc index 1a741169d4..5911834c91 100644 --- a/test/core/end2end/tests/simple_metadata.cc +++ b/test/core/end2end/tests/simple_metadata.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index ae93f79c9d..6ec4a14959 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/debug/stats.h" #include "src/core/lib/gpr/string.h" #include "test/core/end2end/cq_verifier.h" diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc index ec3050ad45..637b7b2422 100644 --- a/test/core/end2end/tests/stream_compression_compressed_payload.cc +++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc @@ -28,7 +28,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" @@ -95,8 +94,8 @@ static void end_test(grpc_end2end_test_fixture* f) { static void request_for_disabled_algorithm( grpc_end2end_test_config config, const char* test_name, uint32_t send_flags_bitmask, - grpc_stream_compression_algorithm algorithm_to_disable, - grpc_stream_compression_algorithm requested_client_compression_algorithm, + grpc_compression_algorithm algorithm_to_disable, + grpc_compression_algorithm requested_client_compression_algorithm, grpc_status_code expected_error, grpc_metadata* client_metadata) { grpc_call* c; grpc_call* s; @@ -124,13 +123,13 @@ static void request_for_disabled_algorithm( request_payload_slice = grpc_slice_from_copied_string(str); request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - client_args = grpc_channel_args_set_stream_compression_algorithm( + client_args = grpc_channel_args_set_compression_algorithm( nullptr, requested_client_compression_algorithm); - server_args = grpc_channel_args_set_stream_compression_algorithm( - nullptr, GRPC_STREAM_COMPRESS_NONE); + server_args = + grpc_channel_args_set_compression_algorithm(nullptr, GRPC_COMPRESS_NONE); { grpc_core::ExecCtx exec_ctx; - server_args = grpc_channel_args_stream_compression_algorithm_set_state( + server_args = grpc_channel_args_compression_algorithm_set_state( &server_args, algorithm_to_disable, false); } @@ -229,11 +228,10 @@ static void request_for_disabled_algorithm( GPR_ASSERT(status == expected_error); const char* algo_name = nullptr; - GPR_ASSERT( - grpc_stream_compression_algorithm_name(algorithm_to_disable, &algo_name)); + GPR_ASSERT(grpc_compression_algorithm_name(algorithm_to_disable, &algo_name)); char* expected_details = nullptr; - gpr_asprintf(&expected_details, - "Stream compression algorithm '%s' is disabled.", algo_name); + gpr_asprintf(&expected_details, "Compression algorithm '%s' is disabled.", + algo_name); /* and we expect a specific reason for it */ GPR_ASSERT(0 == grpc_slice_str_cmp(details, expected_details)); gpr_free(expected_details); @@ -269,14 +267,12 @@ static void request_for_disabled_algorithm( static void request_with_payload_template( grpc_end2end_test_config config, const char* test_name, uint32_t client_send_flags_bitmask, - grpc_stream_compression_algorithm - default_client_channel_compression_algorithm, - grpc_stream_compression_algorithm - default_server_channel_compression_algorithm, - grpc_stream_compression_algorithm expected_client_compression_algorithm, - grpc_stream_compression_algorithm expected_server_compression_algorithm, + grpc_compression_algorithm default_client_channel_compression_algorithm, + grpc_compression_algorithm default_server_channel_compression_algorithm, + grpc_compression_algorithm expected_client_compression_algorithm, + grpc_compression_algorithm expected_server_compression_algorithm, grpc_metadata* client_init_metadata, bool set_server_level, - grpc_stream_compression_level server_compression_level, + grpc_compression_level server_compression_level, bool send_message_before_initial_metadata, bool set_default_server_message_compression_algorithm, grpc_compression_algorithm default_server_message_compression_algorithm) { @@ -314,13 +310,13 @@ static void request_with_payload_template( grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); - client_args = grpc_channel_args_set_stream_compression_algorithm( + client_args = grpc_channel_args_set_compression_algorithm( nullptr, default_client_channel_compression_algorithm); if (set_default_server_message_compression_algorithm) { server_args = grpc_channel_args_set_compression_algorithm( nullptr, default_server_message_compression_algorithm); } else { - server_args = grpc_channel_args_set_stream_compression_algorithm( + server_args = grpc_channel_args_set_compression_algorithm( nullptr, default_server_channel_compression_algorithm); } @@ -396,23 +392,18 @@ static void request_with_payload_template( GRPC_COMPRESS_DEFLATE) != 0); GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), GRPC_COMPRESS_GZIP) != 0); - GPR_ASSERT( - GPR_BITCOUNT(grpc_call_test_only_get_stream_encodings_accepted_by_peer( - s)) == GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT); - GPR_ASSERT( - GPR_BITGET(grpc_call_test_only_get_stream_encodings_accepted_by_peer(s), - GRPC_STREAM_COMPRESS_NONE) != 0); - GPR_ASSERT( - GPR_BITGET(grpc_call_test_only_get_stream_encodings_accepted_by_peer(s), - GRPC_STREAM_COMPRESS_GZIP) != 0); + GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_STREAM_GZIP) != 0); + GPR_ASSERT(GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer( + s)) == GRPC_COMPRESS_ALGORITHMS_COUNT); memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; if (set_server_level) { - op->data.send_initial_metadata.maybe_stream_compression_level.is_set = true; - op->data.send_initial_metadata.maybe_stream_compression_level.level = + op->data.send_initial_metadata.maybe_compression_level.is_set = true; + op->data.send_initial_metadata.maybe_compression_level.level = server_compression_level; } op->flags = 0; @@ -558,30 +549,20 @@ static void test_invoke_request_with_compressed_payload( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, nullptr, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, nullptr, false, /* ignored */ - GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); + GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); } static void test_invoke_request_with_send_message_before_initial_metadata( grpc_end2end_test_config config) { request_with_payload_template( config, "test_invoke_request_with_send_message_before_initial_metadata", - 0, GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, nullptr, + 0, GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, nullptr, false, /* ignored */ - GRPC_STREAM_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE); -} - -static void test_invoke_request_with_server_level( - grpc_end2end_test_config config) { - request_with_payload_template( - config, "test_invoke_request_with_server_level", 0, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_GZIP, - /* ignored */ nullptr, true, GRPC_STREAM_COMPRESS_LEVEL_HIGH, false, - false, GRPC_COMPRESS_NONE); + GRPC_COMPRESS_LEVEL_NONE, true, false, GRPC_COMPRESS_NONE); } static void test_invoke_request_with_compressed_payload_md_override( @@ -591,7 +572,8 @@ static void test_invoke_request_with_compressed_payload_md_override( gzip_compression_override.key = GRPC_MDSTR_GRPC_INTERNAL_STREAM_ENCODING_REQUEST; - gzip_compression_override.value = grpc_slice_from_static_string("gzip"); + gzip_compression_override.value = + grpc_slice_from_static_string("stream/gzip"); memset(&gzip_compression_override.internal_data, 0, sizeof(gzip_compression_override.internal_data)); @@ -605,49 +587,31 @@ static void test_invoke_request_with_compressed_payload_md_override( /* Channel default NONE (aka IDENTITY), call override to stream GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_1", 0, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_NONE, - &gzip_compression_override, false, - /*ignored*/ GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, - GRPC_COMPRESS_NONE); + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_STREAM_GZIP, + GRPC_COMPRESS_NONE, &gzip_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); /* Channel default stream GZIP, call override to NONE (aka IDENTITY) */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_3", 0, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - &identity_compression_override, false, - /*ignored*/ GRPC_STREAM_COMPRESS_LEVEL_NONE, false, false, - GRPC_COMPRESS_NONE); + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, + GRPC_COMPRESS_NONE, &identity_compression_override, false, + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false, false, GRPC_COMPRESS_NONE); } static void test_invoke_request_with_disabled_algorithm( grpc_end2end_test_config config) { request_for_disabled_algorithm( config, "test_invoke_request_with_disabled_algorithm", 0, - GRPC_STREAM_COMPRESS_GZIP, GRPC_STREAM_COMPRESS_GZIP, + GRPC_COMPRESS_STREAM_GZIP, GRPC_COMPRESS_STREAM_GZIP, GRPC_STATUS_UNIMPLEMENTED, nullptr); } -static void test_stream_compression_override_message_compression( - grpc_end2end_test_config config) { - grpc_stream_compression_level level = GRPC_STREAM_COMPRESS_LEVEL_MED; - request_with_payload_template( - config, "test_stream_compression_override_message_compression", 0, - GRPC_STREAM_COMPRESS_NONE, GRPC_STREAM_COMPRESS_NONE, - GRPC_STREAM_COMPRESS_NONE, - grpc_stream_compression_algorithm_for_level( - level, (1u << GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) - 1), - /* ignored */ nullptr, true, level, false, true, GRPC_COMPRESS_GZIP); -} - void stream_compression_compressed_payload(grpc_end2end_test_config config) { test_invoke_request_with_compressed_payload(config); test_invoke_request_with_send_message_before_initial_metadata(config); - test_invoke_request_with_server_level(config); test_invoke_request_with_compressed_payload_md_override(config); test_invoke_request_with_disabled_algorithm(config); - test_stream_compression_override_message_compression(config); } void stream_compression_compressed_payload_pre_init(void) {} diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc index b95e6528cd..6abb3bbf5d 100644 --- a/test/core/end2end/tests/stream_compression_payload.cc +++ b/test/core/end2end/tests/stream_compression_payload.cc @@ -26,7 +26,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" #include "test/core/end2end/cq_verifier.h" @@ -264,12 +263,10 @@ static void request_response_with_payload(grpc_end2end_test_config config, payload and status. */ static void test_invoke_request_response_with_payload( grpc_end2end_test_config config) { - grpc_channel_args* client_args = - grpc_channel_args_set_stream_compression_algorithm( - nullptr, GRPC_STREAM_COMPRESS_GZIP); - grpc_channel_args* server_args = - grpc_channel_args_set_stream_compression_algorithm( - nullptr, GRPC_STREAM_COMPRESS_GZIP); + grpc_channel_args* client_args = grpc_channel_args_set_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args* server_args = grpc_channel_args_set_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_invoke_request_response_with_payload", client_args, server_args); diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc index 2a8799ee67..8242c2cdd1 100644 --- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc +++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc @@ -26,7 +26,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" #include "test/core/end2end/cq_verifier.h" @@ -90,12 +90,10 @@ static void end_test(grpc_end2end_test_fixture* f) { /* Client pings and server pongs. Repeat messages rounds before finishing. */ static void test_pingpong_streaming(grpc_end2end_test_config config, int messages) { - grpc_channel_args* client_args = - grpc_channel_args_set_stream_compression_algorithm( - nullptr, GRPC_STREAM_COMPRESS_GZIP); - grpc_channel_args* server_args = - grpc_channel_args_set_stream_compression_algorithm( - nullptr, GRPC_STREAM_COMPRESS_GZIP); + grpc_channel_args* client_args = grpc_channel_args_set_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); + grpc_channel_args* server_args = grpc_channel_args_set_compression_algorithm( + nullptr, GRPC_COMPRESS_STREAM_GZIP); grpc_end2end_test_fixture f = begin_test(config, "test_pingpong_streaming", client_args, server_args); grpc_call* c; diff --git a/test/core/end2end/tests/streaming_error_response.cc b/test/core/end2end/tests/streaming_error_response.cc index fe53fda9ef..167530a6ae 100644 --- a/test/core/end2end/tests/streaming_error_response.cc +++ b/test/core/end2end/tests/streaming_error_response.cc @@ -28,7 +28,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } @@ -111,7 +110,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { grpc_byte_buffer* response_payload1_recv = nullptr; grpc_byte_buffer* response_payload2_recv = nullptr; grpc_call_details call_details; - grpc_status_code status; + grpc_status_code status = GRPC_STATUS_OK; grpc_call_error error; grpc_slice details; int was_cancelled = 2; diff --git a/test/core/end2end/tests/trailing_metadata.cc b/test/core/end2end/tests/trailing_metadata.cc index afc56c8dfa..150c1cbd51 100644 --- a/test/core/end2end/tests/trailing_metadata.cc +++ b/test/core/end2end/tests/trailing_metadata.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc index d4decce0aa..edf03d8ffc 100644 --- a/test/core/end2end/tests/workaround_cronet_compression.cc +++ b/test/core/end2end/tests/workaround_cronet_compression.cc @@ -28,7 +28,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/call.h" diff --git a/test/core/end2end/tests/write_buffering.cc b/test/core/end2end/tests/write_buffering.cc index 40821dd6f0..7f3d1abc39 100644 --- a/test/core/end2end/tests/write_buffering.cc +++ b/test/core/end2end/tests/write_buffering.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/end2end/tests/write_buffering_at_end.cc b/test/core/end2end/tests/write_buffering_at_end.cc index 1b9dc9632b..a1fbfef3fc 100644 --- a/test/core/end2end/tests/write_buffering_at_end.cc +++ b/test/core/end2end/tests/write_buffering_at_end.cc @@ -25,7 +25,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" static void* tag(intptr_t t) { return (void*)t; } diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc index 28e62e0e83..92f59b7fdb 100644 --- a/test/core/fling/client.cc +++ b/test/core/fling/client.cc @@ -21,11 +21,12 @@ #include <stdio.h> #include <string.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/profiling/timers.h" +#include "test/core/util/cmdline.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" #include "test/core/util/test_config.h" @@ -74,7 +75,7 @@ static void init_ping_pong_request(void) { } static void step_ping_pong_request(void) { - GPR_TIMER_BEGIN("ping_pong", 1); + GPR_TIMER_SCOPE("ping_pong", 1); grpc_slice host = grpc_slice_from_static_string("localhost"); call = grpc_channel_create_call( channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, @@ -87,7 +88,6 @@ static void step_ping_pong_request(void) { grpc_call_unref(call); grpc_byte_buffer_destroy(response_payload_recv); call = nullptr; - GPR_TIMER_END("ping_pong", 1); } static void init_ping_pong_stream(void) { @@ -117,13 +117,12 @@ static void init_ping_pong_stream(void) { } static void step_ping_pong_stream(void) { + GPR_TIMER_SCOPE("ping_pong", 1); grpc_call_error error; - GPR_TIMER_BEGIN("ping_pong", 1); error = grpc_call_start_batch(call, stream_step_ops, 2, (void*)1, nullptr); GPR_ASSERT(GRPC_CALL_OK == error); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_byte_buffer_destroy(response_payload_recv); - GPR_TIMER_END("ping_pong", 1); } static double now(void) { diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc index b5a5ce816e..d5fd7a8d46 100644 --- a/test/core/fling/fling_stream_test.cc +++ b/test/core/fling/fling_stream_test.cc @@ -20,11 +20,12 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" int main(int argc, char** argv) { char* me = argv[0]; diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc index 3792e45c42..d95317b7e6 100644 --- a/test/core/fling/fling_test.cc +++ b/test/core/fling/fling_test.cc @@ -20,11 +20,12 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" int main(int argc, const char** argv) { const char* me = argv[0]; diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc index f3a8a1ccf8..b19a25a185 100644 --- a/test/core/fling/server.cc +++ b/test/core/fling/server.cc @@ -30,12 +30,13 @@ #endif #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/time.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "test/core/end2end/data/ssl_test_data.h" +#include "test/core/util/cmdline.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" diff --git a/test/core/gpr/BUILD b/test/core/gpr/BUILD index 1be1036d04..9aa74cc132 100644 --- a/test/core/gpr/BUILD +++ b/test/core/gpr/BUILD @@ -29,26 +29,6 @@ grpc_cc_test( ) grpc_cc_test( - name = "avl_test", - srcs = ["avl_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:gpr_test_util", - ], -) - -grpc_cc_test( - name = "cmdline_test", - srcs = ["cmdline_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//test/core/util:gpr_test_util", - ], -) - -grpc_cc_test( name = "cpu_test", srcs = ["cpu_test.cc"], language = "C++", diff --git a/test/core/gpr/alloc_test.cc b/test/core/gpr/alloc_test.cc index 6074c6e6e7..bf4471c36f 100644 --- a/test/core/gpr/alloc_test.cc +++ b/test/core/gpr/alloc_test.cc @@ -16,8 +16,11 @@ * */ +#include <string.h> + #include <grpc/support/alloc.h> #include <grpc/support/log.h> + #include "test/core/util/test_config.h" static void* fake_malloc(size_t size) { return (void*)size; } @@ -48,8 +51,19 @@ static void test_custom_allocs() { gpr_free(i); } +static void test_malloc_aligned() { + for (size_t size = 1; size <= 256; ++size) { + void* ptr = gpr_malloc_aligned(size, 16); + GPR_ASSERT(ptr != nullptr); + GPR_ASSERT(((intptr_t)ptr & 0xf) == 0); + memset(ptr, 0, size); + gpr_free_aligned(ptr); + } +} + int main(int argc, char** argv) { grpc_test_init(argc, argv); test_custom_allocs(); + test_malloc_aligned(); return 0; } diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc index 59ea04c0ed..087a800462 100644 --- a/test/core/gpr/arena_test.cc +++ b/test/core/gpr/arena_test.cc @@ -23,11 +23,11 @@ #include <grpc/support/string_util.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> #include <inttypes.h> #include <string.h> #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static void test_noop(void) { gpr_arena_destroy(gpr_arena_create(1)); } @@ -53,6 +53,8 @@ static void test(const char* name, size_t init_size, const size_t* allocs, void** ps = static_cast<void**>(gpr_zalloc(sizeof(*ps) * nallocs)); for (size_t i = 0; i < nallocs; i++) { ps[i] = gpr_arena_alloc(a, allocs[i]); + // ensure the returned address is aligned + GPR_ASSERT(((intptr_t)ps[i] & 0xf) == 0); // ensure no duplicate results for (size_t j = 0; j < i; j++) { GPR_ASSERT(ps[i] != ps[j]); diff --git a/test/core/gpr/avl_test.cc b/test/core/gpr/avl_test.cc deleted file mode 100644 index 345db557b9..0000000000 --- a/test/core/gpr/avl_test.cc +++ /dev/null @@ -1,3659 +0,0 @@ -/* - * - * Copyright 2015 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/avl.h> - -#include <stdio.h> -#include <string.h> - -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/useful.h> - -#include "test/core/util/test_config.h" - -static int* box(int x) { - int* b = static_cast<int*>(gpr_malloc(sizeof(*b))); - *b = x; - return b; -} - -static long int_compare(void* int1, void* int2, void* unused) { - return (*(int*)int1) - (*(int*)int2); -} -static void* int_copy(void* p, void* unused) { return box(*(int*)p); } - -static void destroy(void* p, void* unused) { gpr_free(p); } - -static const gpr_avl_vtable int_int_vtable = {destroy, int_copy, int_compare, - destroy, int_copy}; - -static void check_get(gpr_avl avl, int key, int value) { - int* k = box(key); - GPR_ASSERT(*(int*)gpr_avl_get(avl, k, nullptr) == value); - gpr_free(k); -} - -static void check_negget(gpr_avl avl, int key) { - int* k = box(key); - GPR_ASSERT(gpr_avl_get(avl, k, nullptr) == nullptr); - gpr_free(k); -} - -static gpr_avl remove_int(gpr_avl avl, int key) { - int* k = box(key); - avl = gpr_avl_remove(avl, k, nullptr); - gpr_free(k); - return avl; -} - -static void test_get(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_get"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(1), box(11), nullptr); - avl = gpr_avl_add(avl, box(2), box(22), nullptr); - avl = gpr_avl_add(avl, box(3), box(33), nullptr); - check_get(avl, 1, 11); - check_get(avl, 2, 22); - check_get(avl, 3, 33); - check_negget(avl, 4); - gpr_avl_unref(avl, nullptr); -} - -static void test_ll(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_ll"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(5), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(3), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_lr(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_lr"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(5), box(1), nullptr); - avl = gpr_avl_add(avl, box(3), box(2), nullptr); - avl = gpr_avl_add(avl, box(4), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_rr(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_rr"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(3), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(5), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_rl(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_rl"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(3), box(1), nullptr); - avl = gpr_avl_add(avl, box(5), box(2), nullptr); - avl = gpr_avl_add(avl, box(4), box(3), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_unbalanced(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_unbalanced"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(5), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(3), box(3), nullptr); - avl = gpr_avl_add(avl, box(2), box(4), nullptr); - avl = gpr_avl_add(avl, box(1), box(5), nullptr); - GPR_ASSERT(*(int*)avl.root->key == 4); - GPR_ASSERT(*(int*)avl.root->left->key == 2); - GPR_ASSERT(*(int*)avl.root->left->left->key == 1); - GPR_ASSERT(*(int*)avl.root->left->right->key == 3); - GPR_ASSERT(*(int*)avl.root->right->key == 5); - gpr_avl_unref(avl, nullptr); -} - -static void test_replace(void) { - gpr_avl avl; - gpr_log(GPR_DEBUG, "test_replace"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(1), box(1), nullptr); - avl = gpr_avl_add(avl, box(1), box(2), nullptr); - check_get(avl, 1, 2); - check_negget(avl, 2); - gpr_avl_unref(avl, nullptr); -} - -static void test_remove(void) { - gpr_avl avl; - gpr_avl avl3, avl4, avl5, avln; - gpr_log(GPR_DEBUG, "test_remove"); - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(3), box(1), nullptr); - avl = gpr_avl_add(avl, box(4), box(2), nullptr); - avl = gpr_avl_add(avl, box(5), box(3), nullptr); - - avl3 = remove_int(gpr_avl_ref(avl, nullptr), 3); - avl4 = remove_int(gpr_avl_ref(avl, nullptr), 4); - avl5 = remove_int(gpr_avl_ref(avl, nullptr), 5); - avln = remove_int(gpr_avl_ref(avl, nullptr), 1); - - gpr_avl_unref(avl, nullptr); - - check_negget(avl3, 3); - check_get(avl3, 4, 2); - check_get(avl3, 5, 3); - gpr_avl_unref(avl3, nullptr); - - check_get(avl4, 3, 1); - check_negget(avl4, 4); - check_get(avl4, 5, 3); - gpr_avl_unref(avl4, nullptr); - - check_get(avl5, 3, 1); - check_get(avl5, 4, 2); - check_negget(avl5, 5); - gpr_avl_unref(avl5, nullptr); - - check_get(avln, 3, 1); - check_get(avln, 4, 2); - check_get(avln, 5, 3); - gpr_avl_unref(avln, nullptr); -} - -static void test_badcase1(void) { - gpr_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase1"); - - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(88), box(1), nullptr); - avl = remove_int(avl, 643); - avl = remove_int(avl, 983); - avl = gpr_avl_add(avl, box(985), box(4), nullptr); - avl = gpr_avl_add(avl, box(640), box(5), nullptr); - avl = gpr_avl_add(avl, box(41), box(6), nullptr); - avl = gpr_avl_add(avl, box(112), box(7), nullptr); - avl = gpr_avl_add(avl, box(342), box(8), nullptr); - avl = remove_int(avl, 1013); - avl = gpr_avl_add(avl, box(434), box(10), nullptr); - avl = gpr_avl_add(avl, box(520), box(11), nullptr); - avl = gpr_avl_add(avl, box(231), box(12), nullptr); - avl = gpr_avl_add(avl, box(852), box(13), nullptr); - avl = remove_int(avl, 461); - avl = gpr_avl_add(avl, box(108), box(15), nullptr); - avl = gpr_avl_add(avl, box(806), box(16), nullptr); - avl = gpr_avl_add(avl, box(827), box(17), nullptr); - avl = remove_int(avl, 796); - avl = gpr_avl_add(avl, box(340), box(19), nullptr); - avl = gpr_avl_add(avl, box(498), box(20), nullptr); - avl = gpr_avl_add(avl, box(203), box(21), nullptr); - avl = gpr_avl_add(avl, box(751), box(22), nullptr); - avl = gpr_avl_add(avl, box(150), box(23), nullptr); - avl = remove_int(avl, 237); - avl = gpr_avl_add(avl, box(830), box(25), nullptr); - avl = remove_int(avl, 1007); - avl = remove_int(avl, 394); - avl = gpr_avl_add(avl, box(65), box(28), nullptr); - avl = remove_int(avl, 904); - avl = remove_int(avl, 123); - avl = gpr_avl_add(avl, box(238), box(31), nullptr); - avl = gpr_avl_add(avl, box(184), box(32), nullptr); - avl = remove_int(avl, 331); - avl = gpr_avl_add(avl, box(827), box(34), nullptr); - - check_get(avl, 830, 25); - - gpr_avl_unref(avl, nullptr); -} - -static void test_badcase2(void) { - gpr_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase2"); - - avl = gpr_avl_create(&int_int_vtable); - avl = gpr_avl_add(avl, box(288), box(1), nullptr); - avl = remove_int(avl, 415); - avl = gpr_avl_add(avl, box(953), box(3), nullptr); - avl = gpr_avl_add(avl, box(101), box(4), nullptr); - avl = gpr_avl_add(avl, box(516), box(5), nullptr); - avl = gpr_avl_add(avl, box(547), box(6), nullptr); - avl = gpr_avl_add(avl, box(467), box(7), nullptr); - avl = gpr_avl_add(avl, box(793), box(8), nullptr); - avl = remove_int(avl, 190); - avl = gpr_avl_add(avl, box(687), box(10), nullptr); - avl = gpr_avl_add(avl, box(242), box(11), nullptr); - avl = gpr_avl_add(avl, box(142), box(12), nullptr); - avl = remove_int(avl, 705); - avl = remove_int(avl, 578); - avl = remove_int(avl, 767); - avl = remove_int(avl, 183); - avl = gpr_avl_add(avl, box(950), box(17), nullptr); - avl = gpr_avl_add(avl, box(622), box(18), nullptr); - avl = remove_int(avl, 513); - avl = remove_int(avl, 429); - avl = gpr_avl_add(avl, box(205), box(21), nullptr); - avl = remove_int(avl, 663); - avl = remove_int(avl, 953); - avl = remove_int(avl, 892); - avl = gpr_avl_add(avl, box(236), box(25), nullptr); - avl = remove_int(avl, 982); - avl = remove_int(avl, 201); - avl = remove_int(avl, 684); - avl = gpr_avl_add(avl, box(572), box(29), nullptr); - avl = remove_int(avl, 817); - avl = gpr_avl_add(avl, box(970), box(31), nullptr); - avl = remove_int(avl, 347); - avl = remove_int(avl, 574); - avl = gpr_avl_add(avl, box(752), box(34), nullptr); - avl = gpr_avl_add(avl, box(670), box(35), nullptr); - avl = gpr_avl_add(avl, box(69), box(36), nullptr); - avl = remove_int(avl, 111); - avl = remove_int(avl, 523); - avl = gpr_avl_add(avl, box(141), box(39), nullptr); - avl = remove_int(avl, 159); - avl = gpr_avl_add(avl, box(947), box(41), nullptr); - avl = gpr_avl_add(avl, box(855), box(42), nullptr); - avl = remove_int(avl, 218); - avl = remove_int(avl, 6); - avl = gpr_avl_add(avl, box(753), box(45), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 799); - avl = gpr_avl_add(avl, box(572), box(48), nullptr); - avl = remove_int(avl, 376); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(458), box(51), nullptr); - avl = remove_int(avl, 897); - avl = gpr_avl_add(avl, box(191), box(53), nullptr); - avl = gpr_avl_add(avl, box(609), box(54), nullptr); - avl = remove_int(avl, 787); - avl = remove_int(avl, 710); - avl = remove_int(avl, 886); - avl = remove_int(avl, 835); - avl = remove_int(avl, 33); - avl = gpr_avl_add(avl, box(871), box(60), nullptr); - avl = remove_int(avl, 641); - avl = gpr_avl_add(avl, box(462), box(62), nullptr); - avl = remove_int(avl, 359); - avl = remove_int(avl, 767); - avl = gpr_avl_add(avl, box(310), box(65), nullptr); - avl = remove_int(avl, 757); - avl = remove_int(avl, 639); - avl = remove_int(avl, 314); - avl = gpr_avl_add(avl, box(2), box(69), nullptr); - avl = remove_int(avl, 138); - avl = gpr_avl_add(avl, box(669), box(71), nullptr); - avl = remove_int(avl, 477); - avl = gpr_avl_add(avl, box(366), box(73), nullptr); - avl = gpr_avl_add(avl, box(612), box(74), nullptr); - avl = gpr_avl_add(avl, box(106), box(75), nullptr); - avl = remove_int(avl, 161); - avl = gpr_avl_add(avl, box(388), box(77), nullptr); - avl = gpr_avl_add(avl, box(141), box(78), nullptr); - avl = remove_int(avl, 633); - avl = remove_int(avl, 459); - avl = gpr_avl_add(avl, box(40), box(81), nullptr); - avl = remove_int(avl, 689); - avl = gpr_avl_add(avl, box(823), box(83), nullptr); - avl = remove_int(avl, 485); - avl = gpr_avl_add(avl, box(903), box(85), nullptr); - avl = gpr_avl_add(avl, box(592), box(86), nullptr); - avl = remove_int(avl, 448); - avl = gpr_avl_add(avl, box(56), box(88), nullptr); - avl = remove_int(avl, 333); - avl = gpr_avl_add(avl, box(189), box(90), nullptr); - avl = gpr_avl_add(avl, box(103), box(91), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 974); - avl = gpr_avl_add(avl, box(215), box(94), nullptr); - avl = remove_int(avl, 189); - avl = remove_int(avl, 504); - avl = gpr_avl_add(avl, box(868), box(97), nullptr); - avl = remove_int(avl, 909); - avl = remove_int(avl, 148); - avl = remove_int(avl, 469); - avl = gpr_avl_add(avl, box(994), box(101), nullptr); - avl = gpr_avl_add(avl, box(576), box(102), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 209); - avl = gpr_avl_add(avl, box(276), box(105), nullptr); - avl = remove_int(avl, 856); - avl = gpr_avl_add(avl, box(750), box(107), nullptr); - avl = remove_int(avl, 871); - avl = gpr_avl_add(avl, box(301), box(109), nullptr); - avl = remove_int(avl, 260); - avl = remove_int(avl, 737); - avl = remove_int(avl, 719); - avl = gpr_avl_add(avl, box(933), box(113), nullptr); - avl = gpr_avl_add(avl, box(225), box(114), nullptr); - avl = gpr_avl_add(avl, box(975), box(115), nullptr); - avl = gpr_avl_add(avl, box(86), box(116), nullptr); - avl = remove_int(avl, 732); - avl = gpr_avl_add(avl, box(340), box(118), nullptr); - avl = gpr_avl_add(avl, box(271), box(119), nullptr); - avl = remove_int(avl, 206); - avl = gpr_avl_add(avl, box(949), box(121), nullptr); - avl = gpr_avl_add(avl, box(927), box(122), nullptr); - avl = gpr_avl_add(avl, box(34), box(123), nullptr); - avl = gpr_avl_add(avl, box(351), box(124), nullptr); - avl = remove_int(avl, 836); - avl = gpr_avl_add(avl, box(825), box(126), nullptr); - avl = gpr_avl_add(avl, box(352), box(127), nullptr); - avl = remove_int(avl, 107); - avl = remove_int(avl, 101); - avl = gpr_avl_add(avl, box(320), box(130), nullptr); - avl = gpr_avl_add(avl, box(3), box(131), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 44); - avl = gpr_avl_add(avl, box(525), box(134), nullptr); - avl = gpr_avl_add(avl, box(864), box(135), nullptr); - avl = gpr_avl_add(avl, box(863), box(136), nullptr); - avl = remove_int(avl, 770); - avl = gpr_avl_add(avl, box(440), box(138), nullptr); - avl = remove_int(avl, 516); - avl = gpr_avl_add(avl, box(116), box(140), nullptr); - avl = remove_int(avl, 380); - avl = gpr_avl_add(avl, box(878), box(142), nullptr); - avl = remove_int(avl, 439); - avl = gpr_avl_add(avl, box(994), box(144), nullptr); - avl = remove_int(avl, 294); - avl = remove_int(avl, 593); - avl = gpr_avl_add(avl, box(696), box(147), nullptr); - avl = remove_int(avl, 8); - avl = gpr_avl_add(avl, box(881), box(149), nullptr); - avl = remove_int(avl, 32); - avl = remove_int(avl, 242); - avl = gpr_avl_add(avl, box(487), box(152), nullptr); - avl = gpr_avl_add(avl, box(637), box(153), nullptr); - avl = gpr_avl_add(avl, box(793), box(154), nullptr); - avl = gpr_avl_add(avl, box(696), box(155), nullptr); - avl = remove_int(avl, 458); - avl = gpr_avl_add(avl, box(828), box(157), nullptr); - avl = remove_int(avl, 784); - avl = remove_int(avl, 274); - avl = gpr_avl_add(avl, box(783), box(160), nullptr); - avl = remove_int(avl, 21); - avl = gpr_avl_add(avl, box(866), box(162), nullptr); - avl = remove_int(avl, 919); - avl = gpr_avl_add(avl, box(435), box(164), nullptr); - avl = remove_int(avl, 385); - avl = gpr_avl_add(avl, box(475), box(166), nullptr); - avl = remove_int(avl, 339); - avl = gpr_avl_add(avl, box(615), box(168), nullptr); - avl = remove_int(avl, 866); - avl = remove_int(avl, 82); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(590), box(172), nullptr); - avl = gpr_avl_add(avl, box(852), box(173), nullptr); - avl = remove_int(avl, 318); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(672), box(176), nullptr); - avl = remove_int(avl, 430); - avl = gpr_avl_add(avl, box(821), box(178), nullptr); - avl = gpr_avl_add(avl, box(365), box(179), nullptr); - avl = remove_int(avl, 78); - avl = gpr_avl_add(avl, box(700), box(181), nullptr); - avl = gpr_avl_add(avl, box(353), box(182), nullptr); - avl = remove_int(avl, 492); - avl = gpr_avl_add(avl, box(991), box(184), nullptr); - avl = remove_int(avl, 330); - avl = gpr_avl_add(avl, box(873), box(186), nullptr); - avl = remove_int(avl, 589); - avl = gpr_avl_add(avl, box(676), box(188), nullptr); - avl = gpr_avl_add(avl, box(790), box(189), nullptr); - avl = remove_int(avl, 521); - avl = remove_int(avl, 47); - avl = gpr_avl_add(avl, box(976), box(192), nullptr); - avl = gpr_avl_add(avl, box(683), box(193), nullptr); - avl = remove_int(avl, 803); - avl = remove_int(avl, 1006); - avl = gpr_avl_add(avl, box(775), box(196), nullptr); - avl = gpr_avl_add(avl, box(411), box(197), nullptr); - avl = gpr_avl_add(avl, box(697), box(198), nullptr); - avl = remove_int(avl, 50); - avl = gpr_avl_add(avl, box(213), box(200), nullptr); - avl = remove_int(avl, 714); - avl = gpr_avl_add(avl, box(981), box(202), nullptr); - avl = gpr_avl_add(avl, box(502), box(203), nullptr); - avl = gpr_avl_add(avl, box(697), box(204), nullptr); - avl = gpr_avl_add(avl, box(603), box(205), nullptr); - avl = gpr_avl_add(avl, box(117), box(206), nullptr); - avl = remove_int(avl, 363); - avl = gpr_avl_add(avl, box(104), box(208), nullptr); - avl = remove_int(avl, 842); - avl = gpr_avl_add(avl, box(48), box(210), nullptr); - avl = remove_int(avl, 764); - avl = gpr_avl_add(avl, box(482), box(212), nullptr); - avl = gpr_avl_add(avl, box(928), box(213), nullptr); - avl = gpr_avl_add(avl, box(30), box(214), nullptr); - avl = gpr_avl_add(avl, box(820), box(215), nullptr); - avl = gpr_avl_add(avl, box(334), box(216), nullptr); - avl = remove_int(avl, 306); - avl = gpr_avl_add(avl, box(789), box(218), nullptr); - avl = remove_int(avl, 924); - avl = gpr_avl_add(avl, box(53), box(220), nullptr); - avl = remove_int(avl, 657); - avl = gpr_avl_add(avl, box(130), box(222), nullptr); - avl = gpr_avl_add(avl, box(239), box(223), nullptr); - avl = remove_int(avl, 20); - avl = gpr_avl_add(avl, box(117), box(225), nullptr); - avl = remove_int(avl, 882); - avl = remove_int(avl, 891); - avl = gpr_avl_add(avl, box(9), box(228), nullptr); - avl = gpr_avl_add(avl, box(496), box(229), nullptr); - avl = gpr_avl_add(avl, box(750), box(230), nullptr); - avl = gpr_avl_add(avl, box(283), box(231), nullptr); - avl = gpr_avl_add(avl, box(802), box(232), nullptr); - avl = remove_int(avl, 352); - avl = gpr_avl_add(avl, box(374), box(234), nullptr); - avl = gpr_avl_add(avl, box(6), box(235), nullptr); - avl = gpr_avl_add(avl, box(756), box(236), nullptr); - avl = gpr_avl_add(avl, box(597), box(237), nullptr); - avl = gpr_avl_add(avl, box(661), box(238), nullptr); - avl = remove_int(avl, 96); - avl = gpr_avl_add(avl, box(894), box(240), nullptr); - avl = remove_int(avl, 749); - avl = gpr_avl_add(avl, box(71), box(242), nullptr); - avl = remove_int(avl, 68); - avl = gpr_avl_add(avl, box(388), box(244), nullptr); - avl = remove_int(avl, 119); - avl = remove_int(avl, 856); - avl = gpr_avl_add(avl, box(176), box(247), nullptr); - avl = gpr_avl_add(avl, box(993), box(248), nullptr); - avl = remove_int(avl, 178); - avl = remove_int(avl, 781); - avl = remove_int(avl, 771); - avl = remove_int(avl, 848); - avl = remove_int(avl, 376); - avl = remove_int(avl, 157); - avl = remove_int(avl, 142); - avl = remove_int(avl, 686); - avl = gpr_avl_add(avl, box(779), box(257), nullptr); - avl = gpr_avl_add(avl, box(484), box(258), nullptr); - avl = remove_int(avl, 837); - avl = gpr_avl_add(avl, box(388), box(260), nullptr); - avl = remove_int(avl, 987); - avl = gpr_avl_add(avl, box(336), box(262), nullptr); - avl = remove_int(avl, 855); - avl = gpr_avl_add(avl, box(668), box(264), nullptr); - avl = remove_int(avl, 648); - avl = gpr_avl_add(avl, box(193), box(266), nullptr); - avl = remove_int(avl, 939); - avl = gpr_avl_add(avl, box(740), box(268), nullptr); - avl = gpr_avl_add(avl, box(503), box(269), nullptr); - avl = gpr_avl_add(avl, box(765), box(270), nullptr); - avl = remove_int(avl, 924); - avl = remove_int(avl, 513); - avl = gpr_avl_add(avl, box(161), box(273), nullptr); - avl = gpr_avl_add(avl, box(502), box(274), nullptr); - avl = gpr_avl_add(avl, box(846), box(275), nullptr); - avl = remove_int(avl, 931); - avl = gpr_avl_add(avl, box(87), box(277), nullptr); - avl = gpr_avl_add(avl, box(949), box(278), nullptr); - avl = gpr_avl_add(avl, box(548), box(279), nullptr); - avl = gpr_avl_add(avl, box(951), box(280), nullptr); - avl = remove_int(avl, 1018); - avl = remove_int(avl, 568); - avl = gpr_avl_add(avl, box(138), box(283), nullptr); - avl = gpr_avl_add(avl, box(202), box(284), nullptr); - avl = gpr_avl_add(avl, box(157), box(285), nullptr); - avl = gpr_avl_add(avl, box(264), box(286), nullptr); - avl = gpr_avl_add(avl, box(370), box(287), nullptr); - avl = remove_int(avl, 736); - avl = remove_int(avl, 751); - avl = remove_int(avl, 506); - avl = remove_int(avl, 81); - avl = remove_int(avl, 358); - avl = remove_int(avl, 657); - avl = remove_int(avl, 86); - avl = gpr_avl_add(avl, box(876), box(295), nullptr); - avl = remove_int(avl, 354); - avl = gpr_avl_add(avl, box(134), box(297), nullptr); - avl = remove_int(avl, 781); - avl = remove_int(avl, 183); - avl = gpr_avl_add(avl, box(914), box(300), nullptr); - avl = remove_int(avl, 926); - avl = remove_int(avl, 398); - avl = remove_int(avl, 932); - avl = remove_int(avl, 804); - avl = remove_int(avl, 326); - avl = gpr_avl_add(avl, box(208), box(306), nullptr); - avl = gpr_avl_add(avl, box(699), box(307), nullptr); - avl = remove_int(avl, 576); - avl = remove_int(avl, 850); - avl = remove_int(avl, 514); - avl = remove_int(avl, 676); - avl = remove_int(avl, 549); - avl = remove_int(avl, 767); - avl = gpr_avl_add(avl, box(58), box(314), nullptr); - avl = gpr_avl_add(avl, box(265), box(315), nullptr); - avl = gpr_avl_add(avl, box(268), box(316), nullptr); - avl = gpr_avl_add(avl, box(103), box(317), nullptr); - avl = gpr_avl_add(avl, box(440), box(318), nullptr); - avl = remove_int(avl, 777); - avl = gpr_avl_add(avl, box(670), box(320), nullptr); - avl = remove_int(avl, 506); - avl = remove_int(avl, 487); - avl = gpr_avl_add(avl, box(421), box(323), nullptr); - avl = remove_int(avl, 514); - avl = gpr_avl_add(avl, box(701), box(325), nullptr); - avl = remove_int(avl, 949); - avl = remove_int(avl, 872); - avl = remove_int(avl, 139); - avl = gpr_avl_add(avl, box(781), box(329), nullptr); - avl = gpr_avl_add(avl, box(543), box(330), nullptr); - avl = gpr_avl_add(avl, box(147), box(331), nullptr); - avl = remove_int(avl, 190); - avl = gpr_avl_add(avl, box(453), box(333), nullptr); - avl = remove_int(avl, 262); - avl = remove_int(avl, 850); - avl = remove_int(avl, 286); - avl = remove_int(avl, 787); - avl = gpr_avl_add(avl, box(514), box(338), nullptr); - avl = remove_int(avl, 812); - avl = gpr_avl_add(avl, box(431), box(340), nullptr); - avl = gpr_avl_add(avl, box(8), box(341), nullptr); - avl = remove_int(avl, 843); - avl = gpr_avl_add(avl, box(831), box(343), nullptr); - avl = remove_int(avl, 472); - avl = remove_int(avl, 157); - avl = gpr_avl_add(avl, box(612), box(346), nullptr); - avl = gpr_avl_add(avl, box(802), box(347), nullptr); - avl = remove_int(avl, 554); - avl = gpr_avl_add(avl, box(409), box(349), nullptr); - avl = gpr_avl_add(avl, box(439), box(350), nullptr); - avl = gpr_avl_add(avl, box(725), box(351), nullptr); - avl = gpr_avl_add(avl, box(568), box(352), nullptr); - avl = remove_int(avl, 475); - avl = remove_int(avl, 672); - avl = remove_int(avl, 62); - avl = remove_int(avl, 753); - avl = gpr_avl_add(avl, box(435), box(357), nullptr); - avl = gpr_avl_add(avl, box(950), box(358), nullptr); - avl = gpr_avl_add(avl, box(532), box(359), nullptr); - avl = gpr_avl_add(avl, box(832), box(360), nullptr); - avl = remove_int(avl, 390); - avl = gpr_avl_add(avl, box(993), box(362), nullptr); - avl = remove_int(avl, 198); - avl = remove_int(avl, 401); - avl = gpr_avl_add(avl, box(316), box(365), nullptr); - avl = remove_int(avl, 843); - avl = gpr_avl_add(avl, box(541), box(367), nullptr); - avl = gpr_avl_add(avl, box(505), box(368), nullptr); - avl = remove_int(avl, 445); - avl = remove_int(avl, 256); - avl = gpr_avl_add(avl, box(232), box(371), nullptr); - avl = remove_int(avl, 577); - avl = remove_int(avl, 558); - avl = gpr_avl_add(avl, box(910), box(374), nullptr); - avl = remove_int(avl, 902); - avl = remove_int(avl, 755); - avl = remove_int(avl, 114); - avl = remove_int(avl, 438); - avl = remove_int(avl, 224); - avl = gpr_avl_add(avl, box(920), box(380), nullptr); - avl = gpr_avl_add(avl, box(655), box(381), nullptr); - avl = remove_int(avl, 557); - avl = remove_int(avl, 102); - avl = remove_int(avl, 165); - avl = gpr_avl_add(avl, box(191), box(385), nullptr); - avl = remove_int(avl, 30); - avl = gpr_avl_add(avl, box(406), box(387), nullptr); - avl = gpr_avl_add(avl, box(66), box(388), nullptr); - avl = gpr_avl_add(avl, box(87), box(389), nullptr); - avl = remove_int(avl, 7); - avl = remove_int(avl, 671); - avl = gpr_avl_add(avl, box(234), box(392), nullptr); - avl = remove_int(avl, 463); - avl = gpr_avl_add(avl, box(75), box(394), nullptr); - avl = gpr_avl_add(avl, box(487), box(395), nullptr); - avl = remove_int(avl, 203); - avl = gpr_avl_add(avl, box(711), box(397), nullptr); - avl = remove_int(avl, 291); - avl = remove_int(avl, 798); - avl = remove_int(avl, 337); - avl = gpr_avl_add(avl, box(877), box(401), nullptr); - avl = gpr_avl_add(avl, box(388), box(402), nullptr); - avl = remove_int(avl, 975); - avl = gpr_avl_add(avl, box(200), box(404), nullptr); - avl = gpr_avl_add(avl, box(408), box(405), nullptr); - avl = gpr_avl_add(avl, box(3), box(406), nullptr); - avl = gpr_avl_add(avl, box(971), box(407), nullptr); - avl = remove_int(avl, 841); - avl = remove_int(avl, 910); - avl = remove_int(avl, 74); - avl = remove_int(avl, 888); - avl = gpr_avl_add(avl, box(492), box(412), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 364); - avl = gpr_avl_add(avl, box(215), box(415), nullptr); - avl = remove_int(avl, 778); - avl = remove_int(avl, 45); - avl = gpr_avl_add(avl, box(328), box(418), nullptr); - avl = gpr_avl_add(avl, box(597), box(419), nullptr); - avl = remove_int(avl, 34); - avl = gpr_avl_add(avl, box(736), box(421), nullptr); - avl = remove_int(avl, 37); - avl = gpr_avl_add(avl, box(275), box(423), nullptr); - avl = gpr_avl_add(avl, box(70), box(424), nullptr); - avl = gpr_avl_add(avl, box(771), box(425), nullptr); - avl = remove_int(avl, 536); - avl = remove_int(avl, 421); - avl = gpr_avl_add(avl, box(186), box(428), nullptr); - avl = gpr_avl_add(avl, box(788), box(429), nullptr); - avl = gpr_avl_add(avl, box(224), box(430), nullptr); - avl = remove_int(avl, 228); - avl = gpr_avl_add(avl, box(48), box(432), nullptr); - avl = gpr_avl_add(avl, box(120), box(433), nullptr); - avl = gpr_avl_add(avl, box(269), box(434), nullptr); - avl = gpr_avl_add(avl, box(904), box(435), nullptr); - avl = remove_int(avl, 699); - avl = gpr_avl_add(avl, box(340), box(437), nullptr); - avl = remove_int(avl, 276); - avl = gpr_avl_add(avl, box(591), box(439), nullptr); - avl = gpr_avl_add(avl, box(778), box(440), nullptr); - avl = remove_int(avl, 490); - avl = remove_int(avl, 973); - avl = gpr_avl_add(avl, box(294), box(443), nullptr); - avl = gpr_avl_add(avl, box(323), box(444), nullptr); - avl = remove_int(avl, 685); - avl = gpr_avl_add(avl, box(38), box(446), nullptr); - avl = gpr_avl_add(avl, box(525), box(447), nullptr); - avl = remove_int(avl, 162); - avl = gpr_avl_add(avl, box(462), box(449), nullptr); - avl = gpr_avl_add(avl, box(340), box(450), nullptr); - avl = remove_int(avl, 734); - avl = remove_int(avl, 959); - avl = gpr_avl_add(avl, box(752), box(453), nullptr); - avl = gpr_avl_add(avl, box(667), box(454), nullptr); - avl = remove_int(avl, 558); - avl = remove_int(avl, 657); - avl = gpr_avl_add(avl, box(711), box(457), nullptr); - avl = remove_int(avl, 937); - avl = gpr_avl_add(avl, box(741), box(459), nullptr); - avl = gpr_avl_add(avl, box(40), box(460), nullptr); - avl = remove_int(avl, 784); - avl = gpr_avl_add(avl, box(292), box(462), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 931); - avl = remove_int(avl, 886); - avl = gpr_avl_add(avl, box(968), box(466), nullptr); - avl = remove_int(avl, 263); - avl = gpr_avl_add(avl, box(647), box(468), nullptr); - avl = gpr_avl_add(avl, box(92), box(469), nullptr); - avl = remove_int(avl, 310); - avl = gpr_avl_add(avl, box(711), box(471), nullptr); - avl = gpr_avl_add(avl, box(675), box(472), nullptr); - avl = remove_int(avl, 549); - avl = gpr_avl_add(avl, box(380), box(474), nullptr); - avl = remove_int(avl, 825); - avl = gpr_avl_add(avl, box(668), box(476), nullptr); - avl = remove_int(avl, 498); - avl = gpr_avl_add(avl, box(870), box(478), nullptr); - avl = gpr_avl_add(avl, box(391), box(479), nullptr); - avl = gpr_avl_add(avl, box(264), box(480), nullptr); - avl = remove_int(avl, 1); - avl = remove_int(avl, 849); - avl = remove_int(avl, 88); - avl = remove_int(avl, 255); - avl = remove_int(avl, 763); - avl = remove_int(avl, 831); - avl = gpr_avl_add(avl, box(508), box(487), nullptr); - avl = remove_int(avl, 849); - avl = remove_int(avl, 47); - avl = gpr_avl_add(avl, box(299), box(490), nullptr); - avl = remove_int(avl, 625); - avl = remove_int(avl, 433); - avl = remove_int(avl, 904); - avl = remove_int(avl, 761); - avl = gpr_avl_add(avl, box(33), box(495), nullptr); - avl = gpr_avl_add(avl, box(524), box(496), nullptr); - avl = remove_int(avl, 210); - avl = remove_int(avl, 299); - avl = gpr_avl_add(avl, box(823), box(499), nullptr); - avl = remove_int(avl, 479); - avl = remove_int(avl, 96); - avl = remove_int(avl, 1013); - avl = gpr_avl_add(avl, box(768), box(503), nullptr); - avl = remove_int(avl, 638); - avl = remove_int(avl, 20); - avl = gpr_avl_add(avl, box(663), box(506), nullptr); - avl = remove_int(avl, 882); - avl = gpr_avl_add(avl, box(745), box(508), nullptr); - avl = remove_int(avl, 352); - avl = gpr_avl_add(avl, box(10), box(510), nullptr); - avl = remove_int(avl, 484); - avl = gpr_avl_add(avl, box(420), box(512), nullptr); - avl = gpr_avl_add(avl, box(884), box(513), nullptr); - avl = gpr_avl_add(avl, box(993), box(514), nullptr); - avl = gpr_avl_add(avl, box(251), box(515), nullptr); - avl = remove_int(avl, 222); - avl = gpr_avl_add(avl, box(734), box(517), nullptr); - avl = gpr_avl_add(avl, box(952), box(518), nullptr); - avl = remove_int(avl, 26); - avl = remove_int(avl, 270); - avl = remove_int(avl, 481); - avl = remove_int(avl, 693); - avl = remove_int(avl, 1006); - avl = gpr_avl_add(avl, box(77), box(524), nullptr); - avl = remove_int(avl, 897); - avl = gpr_avl_add(avl, box(719), box(526), nullptr); - avl = gpr_avl_add(avl, box(622), box(527), nullptr); - avl = remove_int(avl, 28); - avl = remove_int(avl, 836); - avl = remove_int(avl, 142); - avl = gpr_avl_add(avl, box(445), box(531), nullptr); - avl = gpr_avl_add(avl, box(410), box(532), nullptr); - avl = remove_int(avl, 575); - avl = gpr_avl_add(avl, box(634), box(534), nullptr); - avl = gpr_avl_add(avl, box(906), box(535), nullptr); - avl = remove_int(avl, 649); - avl = gpr_avl_add(avl, box(813), box(537), nullptr); - avl = remove_int(avl, 702); - avl = remove_int(avl, 732); - avl = gpr_avl_add(avl, box(105), box(540), nullptr); - avl = gpr_avl_add(avl, box(867), box(541), nullptr); - avl = remove_int(avl, 964); - avl = remove_int(avl, 941); - avl = gpr_avl_add(avl, box(947), box(544), nullptr); - avl = remove_int(avl, 990); - avl = gpr_avl_add(avl, box(816), box(546), nullptr); - avl = remove_int(avl, 429); - avl = remove_int(avl, 567); - avl = remove_int(avl, 541); - avl = remove_int(avl, 583); - avl = gpr_avl_add(avl, box(57), box(551), nullptr); - avl = gpr_avl_add(avl, box(786), box(552), nullptr); - avl = gpr_avl_add(avl, box(526), box(553), nullptr); - avl = remove_int(avl, 642); - avl = remove_int(avl, 220); - avl = remove_int(avl, 840); - avl = remove_int(avl, 548); - avl = gpr_avl_add(avl, box(528), box(558), nullptr); - avl = gpr_avl_add(avl, box(749), box(559), nullptr); - avl = gpr_avl_add(avl, box(194), box(560), nullptr); - avl = remove_int(avl, 517); - avl = gpr_avl_add(avl, box(102), box(562), nullptr); - avl = remove_int(avl, 189); - avl = gpr_avl_add(avl, box(927), box(564), nullptr); - avl = remove_int(avl, 846); - avl = remove_int(avl, 130); - avl = gpr_avl_add(avl, box(694), box(567), nullptr); - avl = remove_int(avl, 750); - avl = gpr_avl_add(avl, box(357), box(569), nullptr); - avl = remove_int(avl, 431); - avl = remove_int(avl, 91); - avl = gpr_avl_add(avl, box(640), box(572), nullptr); - avl = remove_int(avl, 4); - avl = gpr_avl_add(avl, box(81), box(574), nullptr); - avl = gpr_avl_add(avl, box(595), box(575), nullptr); - avl = remove_int(avl, 444); - avl = remove_int(avl, 262); - avl = remove_int(avl, 11); - avl = gpr_avl_add(avl, box(192), box(579), nullptr); - avl = gpr_avl_add(avl, box(158), box(580), nullptr); - avl = remove_int(avl, 401); - avl = remove_int(avl, 918); - avl = gpr_avl_add(avl, box(180), box(583), nullptr); - avl = remove_int(avl, 268); - avl = gpr_avl_add(avl, box(1012), box(585), nullptr); - avl = gpr_avl_add(avl, box(90), box(586), nullptr); - avl = gpr_avl_add(avl, box(946), box(587), nullptr); - avl = remove_int(avl, 719); - avl = gpr_avl_add(avl, box(874), box(589), nullptr); - avl = gpr_avl_add(avl, box(679), box(590), nullptr); - avl = remove_int(avl, 53); - avl = remove_int(avl, 534); - avl = gpr_avl_add(avl, box(646), box(593), nullptr); - avl = gpr_avl_add(avl, box(767), box(594), nullptr); - avl = gpr_avl_add(avl, box(460), box(595), nullptr); - avl = gpr_avl_add(avl, box(852), box(596), nullptr); - avl = gpr_avl_add(avl, box(189), box(597), nullptr); - avl = remove_int(avl, 932); - avl = remove_int(avl, 366); - avl = remove_int(avl, 907); - avl = gpr_avl_add(avl, box(875), box(601), nullptr); - avl = gpr_avl_add(avl, box(434), box(602), nullptr); - avl = gpr_avl_add(avl, box(704), box(603), nullptr); - avl = gpr_avl_add(avl, box(724), box(604), nullptr); - avl = gpr_avl_add(avl, box(930), box(605), nullptr); - avl = gpr_avl_add(avl, box(1000), box(606), nullptr); - avl = remove_int(avl, 479); - avl = gpr_avl_add(avl, box(275), box(608), nullptr); - avl = remove_int(avl, 32); - avl = gpr_avl_add(avl, box(939), box(610), nullptr); - avl = remove_int(avl, 943); - avl = remove_int(avl, 329); - avl = gpr_avl_add(avl, box(490), box(613), nullptr); - avl = remove_int(avl, 477); - avl = remove_int(avl, 414); - avl = remove_int(avl, 187); - avl = remove_int(avl, 334); - avl = gpr_avl_add(avl, box(40), box(618), nullptr); - avl = remove_int(avl, 751); - avl = gpr_avl_add(avl, box(568), box(620), nullptr); - avl = gpr_avl_add(avl, box(120), box(621), nullptr); - avl = gpr_avl_add(avl, box(617), box(622), nullptr); - avl = gpr_avl_add(avl, box(32), box(623), nullptr); - avl = remove_int(avl, 701); - avl = gpr_avl_add(avl, box(910), box(625), nullptr); - avl = remove_int(avl, 557); - avl = remove_int(avl, 361); - avl = remove_int(avl, 937); - avl = remove_int(avl, 100); - avl = remove_int(avl, 684); - avl = gpr_avl_add(avl, box(751), box(631), nullptr); - avl = remove_int(avl, 781); - avl = remove_int(avl, 469); - avl = remove_int(avl, 75); - avl = remove_int(avl, 561); - avl = gpr_avl_add(avl, box(854), box(636), nullptr); - avl = remove_int(avl, 164); - avl = remove_int(avl, 258); - avl = remove_int(avl, 315); - avl = remove_int(avl, 261); - avl = gpr_avl_add(avl, box(552), box(641), nullptr); - avl = gpr_avl_add(avl, box(6), box(642), nullptr); - avl = gpr_avl_add(avl, box(680), box(643), nullptr); - avl = remove_int(avl, 741); - avl = remove_int(avl, 309); - avl = remove_int(avl, 272); - avl = gpr_avl_add(avl, box(249), box(647), nullptr); - avl = remove_int(avl, 97); - avl = remove_int(avl, 850); - avl = gpr_avl_add(avl, box(915), box(650), nullptr); - avl = gpr_avl_add(avl, box(816), box(651), nullptr); - avl = gpr_avl_add(avl, box(45), box(652), nullptr); - avl = gpr_avl_add(avl, box(168), box(653), nullptr); - avl = remove_int(avl, 153); - avl = remove_int(avl, 239); - avl = gpr_avl_add(avl, box(684), box(656), nullptr); - avl = gpr_avl_add(avl, box(208), box(657), nullptr); - avl = gpr_avl_add(avl, box(681), box(658), nullptr); - avl = gpr_avl_add(avl, box(609), box(659), nullptr); - avl = gpr_avl_add(avl, box(645), box(660), nullptr); - avl = remove_int(avl, 799); - avl = gpr_avl_add(avl, box(955), box(662), nullptr); - avl = gpr_avl_add(avl, box(946), box(663), nullptr); - avl = gpr_avl_add(avl, box(744), box(664), nullptr); - avl = gpr_avl_add(avl, box(201), box(665), nullptr); - avl = gpr_avl_add(avl, box(136), box(666), nullptr); - avl = remove_int(avl, 357); - avl = gpr_avl_add(avl, box(974), box(668), nullptr); - avl = remove_int(avl, 485); - avl = gpr_avl_add(avl, box(1009), box(670), nullptr); - avl = gpr_avl_add(avl, box(517), box(671), nullptr); - avl = remove_int(avl, 491); - avl = gpr_avl_add(avl, box(336), box(673), nullptr); - avl = gpr_avl_add(avl, box(589), box(674), nullptr); - avl = remove_int(avl, 546); - avl = remove_int(avl, 840); - avl = remove_int(avl, 104); - avl = remove_int(avl, 347); - avl = gpr_avl_add(avl, box(801), box(679), nullptr); - avl = remove_int(avl, 799); - avl = remove_int(avl, 702); - avl = remove_int(avl, 996); - avl = remove_int(avl, 93); - avl = gpr_avl_add(avl, box(561), box(684), nullptr); - avl = gpr_avl_add(avl, box(25), box(685), nullptr); - avl = remove_int(avl, 278); - avl = gpr_avl_add(avl, box(191), box(687), nullptr); - avl = remove_int(avl, 243); - avl = remove_int(avl, 918); - avl = remove_int(avl, 449); - avl = gpr_avl_add(avl, box(19), box(691), nullptr); - avl = gpr_avl_add(avl, box(762), box(692), nullptr); - avl = gpr_avl_add(avl, box(13), box(693), nullptr); - avl = gpr_avl_add(avl, box(151), box(694), nullptr); - avl = gpr_avl_add(avl, box(152), box(695), nullptr); - avl = gpr_avl_add(avl, box(793), box(696), nullptr); - avl = remove_int(avl, 862); - avl = remove_int(avl, 890); - avl = gpr_avl_add(avl, box(687), box(699), nullptr); - avl = gpr_avl_add(avl, box(509), box(700), nullptr); - avl = gpr_avl_add(avl, box(973), box(701), nullptr); - avl = remove_int(avl, 230); - avl = gpr_avl_add(avl, box(532), box(703), nullptr); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(281), box(705), nullptr); - avl = gpr_avl_add(avl, box(867), box(706), nullptr); - avl = gpr_avl_add(avl, box(359), box(707), nullptr); - avl = remove_int(avl, 425); - avl = gpr_avl_add(avl, box(691), box(709), nullptr); - avl = gpr_avl_add(avl, box(163), box(710), nullptr); - avl = gpr_avl_add(avl, box(502), box(711), nullptr); - avl = remove_int(avl, 674); - avl = gpr_avl_add(avl, box(697), box(713), nullptr); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(968), box(715), nullptr); - avl = gpr_avl_add(avl, box(48), box(716), nullptr); - avl = remove_int(avl, 543); - avl = gpr_avl_add(avl, box(35), box(718), nullptr); - avl = gpr_avl_add(avl, box(751), box(719), nullptr); - avl = gpr_avl_add(avl, box(478), box(720), nullptr); - avl = remove_int(avl, 797); - avl = remove_int(avl, 309); - avl = gpr_avl_add(avl, box(927), box(723), nullptr); - avl = remove_int(avl, 504); - avl = gpr_avl_add(avl, box(286), box(725), nullptr); - avl = gpr_avl_add(avl, box(413), box(726), nullptr); - avl = gpr_avl_add(avl, box(599), box(727), nullptr); - avl = remove_int(avl, 105); - avl = remove_int(avl, 605); - avl = gpr_avl_add(avl, box(632), box(730), nullptr); - avl = gpr_avl_add(avl, box(133), box(731), nullptr); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(958), box(733), nullptr); - avl = gpr_avl_add(avl, box(729), box(734), nullptr); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(694), box(736), nullptr); - avl = gpr_avl_add(avl, box(505), box(737), nullptr); - avl = remove_int(avl, 63); - avl = remove_int(avl, 714); - avl = gpr_avl_add(avl, box(1002), box(740), nullptr); - avl = remove_int(avl, 211); - avl = gpr_avl_add(avl, box(765), box(742), nullptr); - avl = gpr_avl_add(avl, box(455), box(743), nullptr); - avl = remove_int(avl, 59); - avl = remove_int(avl, 224); - avl = gpr_avl_add(avl, box(586), box(746), nullptr); - avl = gpr_avl_add(avl, box(348), box(747), nullptr); - avl = remove_int(avl, 10); - avl = remove_int(avl, 484); - avl = gpr_avl_add(avl, box(968), box(750), nullptr); - avl = gpr_avl_add(avl, box(923), box(751), nullptr); - avl = remove_int(avl, 573); - avl = remove_int(avl, 617); - avl = gpr_avl_add(avl, box(812), box(754), nullptr); - avl = gpr_avl_add(avl, box(179), box(755), nullptr); - avl = remove_int(avl, 284); - avl = remove_int(avl, 157); - avl = remove_int(avl, 177); - avl = remove_int(avl, 896); - avl = gpr_avl_add(avl, box(649), box(760), nullptr); - avl = gpr_avl_add(avl, box(927), box(761), nullptr); - avl = gpr_avl_add(avl, box(454), box(762), nullptr); - avl = gpr_avl_add(avl, box(217), box(763), nullptr); - avl = remove_int(avl, 534); - avl = gpr_avl_add(avl, box(180), box(765), nullptr); - avl = gpr_avl_add(avl, box(319), box(766), nullptr); - avl = remove_int(avl, 92); - avl = gpr_avl_add(avl, box(483), box(768), nullptr); - avl = remove_int(avl, 504); - avl = remove_int(avl, 1017); - avl = remove_int(avl, 37); - avl = remove_int(avl, 50); - avl = gpr_avl_add(avl, box(302), box(773), nullptr); - avl = remove_int(avl, 807); - avl = gpr_avl_add(avl, box(463), box(775), nullptr); - avl = gpr_avl_add(avl, box(271), box(776), nullptr); - avl = gpr_avl_add(avl, box(644), box(777), nullptr); - avl = remove_int(avl, 618); - avl = gpr_avl_add(avl, box(166), box(779), nullptr); - avl = gpr_avl_add(avl, box(538), box(780), nullptr); - avl = remove_int(avl, 606); - avl = gpr_avl_add(avl, box(425), box(782), nullptr); - avl = remove_int(avl, 725); - avl = remove_int(avl, 383); - avl = gpr_avl_add(avl, box(155), box(785), nullptr); - avl = remove_int(avl, 889); - avl = gpr_avl_add(avl, box(653), box(787), nullptr); - avl = remove_int(avl, 386); - avl = gpr_avl_add(avl, box(142), box(789), nullptr); - avl = remove_int(avl, 107); - avl = remove_int(avl, 603); - avl = remove_int(avl, 971); - avl = gpr_avl_add(avl, box(80), box(793), nullptr); - avl = gpr_avl_add(avl, box(61), box(794), nullptr); - avl = gpr_avl_add(avl, box(693), box(795), nullptr); - avl = gpr_avl_add(avl, box(592), box(796), nullptr); - avl = gpr_avl_add(avl, box(433), box(797), nullptr); - avl = gpr_avl_add(avl, box(973), box(798), nullptr); - avl = remove_int(avl, 901); - avl = remove_int(avl, 340); - avl = remove_int(avl, 709); - avl = gpr_avl_add(avl, box(224), box(802), nullptr); - avl = remove_int(avl, 120); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(780), box(805), nullptr); - avl = gpr_avl_add(avl, box(867), box(806), nullptr); - avl = gpr_avl_add(avl, box(756), box(807), nullptr); - avl = gpr_avl_add(avl, box(583), box(808), nullptr); - avl = gpr_avl_add(avl, box(356), box(809), nullptr); - avl = gpr_avl_add(avl, box(58), box(810), nullptr); - avl = remove_int(avl, 219); - avl = gpr_avl_add(avl, box(301), box(812), nullptr); - avl = remove_int(avl, 643); - avl = remove_int(avl, 787); - avl = remove_int(avl, 583); - avl = remove_int(avl, 552); - avl = remove_int(avl, 308); - avl = remove_int(avl, 608); - avl = remove_int(avl, 363); - avl = remove_int(avl, 690); - avl = gpr_avl_add(avl, box(233), box(821), nullptr); - avl = gpr_avl_add(avl, box(479), box(822), nullptr); - avl = gpr_avl_add(avl, box(323), box(823), nullptr); - avl = gpr_avl_add(avl, box(802), box(824), nullptr); - avl = remove_int(avl, 682); - avl = remove_int(avl, 705); - avl = remove_int(avl, 487); - avl = gpr_avl_add(avl, box(530), box(828), nullptr); - avl = gpr_avl_add(avl, box(232), box(829), nullptr); - avl = remove_int(avl, 627); - avl = gpr_avl_add(avl, box(396), box(831), nullptr); - avl = gpr_avl_add(avl, box(61), box(832), nullptr); - avl = gpr_avl_add(avl, box(932), box(833), nullptr); - avl = gpr_avl_add(avl, box(108), box(834), nullptr); - avl = gpr_avl_add(avl, box(524), box(835), nullptr); - avl = remove_int(avl, 390); - avl = remove_int(avl, 307); - avl = gpr_avl_add(avl, box(722), box(838), nullptr); - avl = gpr_avl_add(avl, box(907), box(839), nullptr); - avl = remove_int(avl, 286); - avl = remove_int(avl, 337); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(973), box(843), nullptr); - avl = remove_int(avl, 930); - avl = remove_int(avl, 242); - avl = gpr_avl_add(avl, box(997), box(846), nullptr); - avl = gpr_avl_add(avl, box(689), box(847), nullptr); - avl = remove_int(avl, 318); - avl = gpr_avl_add(avl, box(703), box(849), nullptr); - avl = gpr_avl_add(avl, box(868), box(850), nullptr); - avl = gpr_avl_add(avl, box(200), box(851), nullptr); - avl = gpr_avl_add(avl, box(960), box(852), nullptr); - avl = gpr_avl_add(avl, box(80), box(853), nullptr); - avl = remove_int(avl, 113); - avl = gpr_avl_add(avl, box(135), box(855), nullptr); - avl = remove_int(avl, 529); - avl = gpr_avl_add(avl, box(366), box(857), nullptr); - avl = remove_int(avl, 272); - avl = gpr_avl_add(avl, box(921), box(859), nullptr); - avl = remove_int(avl, 497); - avl = gpr_avl_add(avl, box(712), box(861), nullptr); - avl = remove_int(avl, 777); - avl = remove_int(avl, 505); - avl = remove_int(avl, 974); - avl = remove_int(avl, 497); - avl = gpr_avl_add(avl, box(388), box(866), nullptr); - avl = gpr_avl_add(avl, box(29), box(867), nullptr); - avl = gpr_avl_add(avl, box(180), box(868), nullptr); - avl = gpr_avl_add(avl, box(983), box(869), nullptr); - avl = gpr_avl_add(avl, box(72), box(870), nullptr); - avl = gpr_avl_add(avl, box(693), box(871), nullptr); - avl = gpr_avl_add(avl, box(567), box(872), nullptr); - avl = remove_int(avl, 549); - avl = remove_int(avl, 351); - avl = gpr_avl_add(avl, box(1019), box(875), nullptr); - avl = remove_int(avl, 585); - avl = remove_int(avl, 294); - avl = remove_int(avl, 61); - avl = gpr_avl_add(avl, box(409), box(879), nullptr); - avl = gpr_avl_add(avl, box(984), box(880), nullptr); - avl = gpr_avl_add(avl, box(830), box(881), nullptr); - avl = remove_int(avl, 579); - avl = gpr_avl_add(avl, box(672), box(883), nullptr); - avl = remove_int(avl, 968); - - gpr_avl_unref(avl, nullptr); -} - -static void test_badcase3(void) { - gpr_avl avl; - - gpr_log(GPR_DEBUG, "test_badcase3"); - - avl = gpr_avl_create(&int_int_vtable); - avl = remove_int(avl, 624); - avl = gpr_avl_add(avl, box(59), box(2), nullptr); - avl = gpr_avl_add(avl, box(494), box(3), nullptr); - avl = gpr_avl_add(avl, box(226), box(4), nullptr); - avl = remove_int(avl, 524); - avl = gpr_avl_add(avl, box(540), box(6), nullptr); - avl = remove_int(avl, 1008); - avl = gpr_avl_add(avl, box(502), box(8), nullptr); - avl = remove_int(avl, 267); - avl = remove_int(avl, 764); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(8), box(12), nullptr); - avl = remove_int(avl, 291); - avl = remove_int(avl, 796); - avl = remove_int(avl, 1002); - avl = gpr_avl_add(avl, box(778), box(16), nullptr); - avl = remove_int(avl, 621); - avl = remove_int(avl, 891); - avl = remove_int(avl, 880); - avl = gpr_avl_add(avl, box(197), box(20), nullptr); - avl = gpr_avl_add(avl, box(441), box(21), nullptr); - avl = gpr_avl_add(avl, box(719), box(22), nullptr); - avl = remove_int(avl, 109); - avl = gpr_avl_add(avl, box(458), box(24), nullptr); - avl = remove_int(avl, 86); - avl = gpr_avl_add(avl, box(897), box(26), nullptr); - avl = gpr_avl_add(avl, box(997), box(27), nullptr); - avl = remove_int(avl, 235); - avl = remove_int(avl, 425); - avl = remove_int(avl, 186); - avl = gpr_avl_add(avl, box(887), box(31), nullptr); - avl = gpr_avl_add(avl, box(1005), box(32), nullptr); - avl = gpr_avl_add(avl, box(778), box(33), nullptr); - avl = gpr_avl_add(avl, box(575), box(34), nullptr); - avl = remove_int(avl, 966); - avl = remove_int(avl, 1015); - avl = gpr_avl_add(avl, box(486), box(37), nullptr); - avl = gpr_avl_add(avl, box(809), box(38), nullptr); - avl = gpr_avl_add(avl, box(907), box(39), nullptr); - avl = gpr_avl_add(avl, box(971), box(40), nullptr); - avl = remove_int(avl, 441); - avl = remove_int(avl, 498); - avl = gpr_avl_add(avl, box(727), box(43), nullptr); - avl = remove_int(avl, 679); - avl = remove_int(avl, 740); - avl = remove_int(avl, 532); - avl = gpr_avl_add(avl, box(805), box(47), nullptr); - avl = remove_int(avl, 64); - avl = gpr_avl_add(avl, box(362), box(49), nullptr); - avl = gpr_avl_add(avl, box(170), box(50), nullptr); - avl = gpr_avl_add(avl, box(389), box(51), nullptr); - avl = gpr_avl_add(avl, box(689), box(52), nullptr); - avl = remove_int(avl, 871); - avl = gpr_avl_add(avl, box(447), box(54), nullptr); - avl = remove_int(avl, 718); - avl = gpr_avl_add(avl, box(724), box(56), nullptr); - avl = remove_int(avl, 215); - avl = gpr_avl_add(avl, box(550), box(58), nullptr); - avl = remove_int(avl, 932); - avl = gpr_avl_add(avl, box(47), box(60), nullptr); - avl = remove_int(avl, 46); - avl = remove_int(avl, 229); - avl = gpr_avl_add(avl, box(68), box(63), nullptr); - avl = gpr_avl_add(avl, box(387), box(64), nullptr); - avl = remove_int(avl, 933); - avl = remove_int(avl, 736); - avl = remove_int(avl, 719); - avl = gpr_avl_add(avl, box(150), box(68), nullptr); - avl = remove_int(avl, 875); - avl = remove_int(avl, 298); - avl = gpr_avl_add(avl, box(991), box(71), nullptr); - avl = remove_int(avl, 705); - avl = gpr_avl_add(avl, box(197), box(73), nullptr); - avl = gpr_avl_add(avl, box(101), box(74), nullptr); - avl = remove_int(avl, 436); - avl = gpr_avl_add(avl, box(755), box(76), nullptr); - avl = gpr_avl_add(avl, box(727), box(77), nullptr); - avl = remove_int(avl, 309); - avl = remove_int(avl, 253); - avl = gpr_avl_add(avl, box(203), box(80), nullptr); - avl = remove_int(avl, 231); - avl = gpr_avl_add(avl, box(461), box(82), nullptr); - avl = remove_int(avl, 316); - avl = remove_int(avl, 493); - avl = gpr_avl_add(avl, box(184), box(85), nullptr); - avl = remove_int(avl, 737); - avl = gpr_avl_add(avl, box(790), box(87), nullptr); - avl = gpr_avl_add(avl, box(335), box(88), nullptr); - avl = remove_int(avl, 649); - avl = gpr_avl_add(avl, box(69), box(90), nullptr); - avl = remove_int(avl, 585); - avl = remove_int(avl, 543); - avl = gpr_avl_add(avl, box(784), box(93), nullptr); - avl = gpr_avl_add(avl, box(60), box(94), nullptr); - avl = gpr_avl_add(avl, box(525), box(95), nullptr); - avl = gpr_avl_add(avl, box(177), box(96), nullptr); - avl = gpr_avl_add(avl, box(178), box(97), nullptr); - avl = gpr_avl_add(avl, box(683), box(98), nullptr); - avl = gpr_avl_add(avl, box(226), box(99), nullptr); - avl = gpr_avl_add(avl, box(662), box(100), nullptr); - avl = remove_int(avl, 944); - avl = gpr_avl_add(avl, box(562), box(102), nullptr); - avl = gpr_avl_add(avl, box(793), box(103), nullptr); - avl = remove_int(avl, 673); - avl = gpr_avl_add(avl, box(310), box(105), nullptr); - avl = remove_int(avl, 479); - avl = remove_int(avl, 543); - avl = remove_int(avl, 159); - avl = remove_int(avl, 850); - avl = gpr_avl_add(avl, box(318), box(110), nullptr); - avl = gpr_avl_add(avl, box(483), box(111), nullptr); - avl = gpr_avl_add(avl, box(84), box(112), nullptr); - avl = remove_int(avl, 109); - avl = gpr_avl_add(avl, box(132), box(114), nullptr); - avl = gpr_avl_add(avl, box(920), box(115), nullptr); - avl = remove_int(avl, 746); - avl = gpr_avl_add(avl, box(145), box(117), nullptr); - avl = gpr_avl_add(avl, box(526), box(118), nullptr); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(332), box(120), nullptr); - avl = gpr_avl_add(avl, box(918), box(121), nullptr); - avl = remove_int(avl, 339); - avl = gpr_avl_add(avl, box(809), box(123), nullptr); - avl = gpr_avl_add(avl, box(742), box(124), nullptr); - avl = gpr_avl_add(avl, box(718), box(125), nullptr); - avl = remove_int(avl, 988); - avl = remove_int(avl, 531); - avl = remove_int(avl, 840); - avl = gpr_avl_add(avl, box(816), box(129), nullptr); - avl = gpr_avl_add(avl, box(976), box(130), nullptr); - avl = remove_int(avl, 743); - avl = remove_int(avl, 528); - avl = remove_int(avl, 982); - avl = gpr_avl_add(avl, box(803), box(134), nullptr); - avl = gpr_avl_add(avl, box(205), box(135), nullptr); - avl = gpr_avl_add(avl, box(584), box(136), nullptr); - avl = remove_int(avl, 923); - avl = remove_int(avl, 538); - avl = remove_int(avl, 398); - avl = remove_int(avl, 320); - avl = remove_int(avl, 292); - avl = gpr_avl_add(avl, box(270), box(142), nullptr); - avl = gpr_avl_add(avl, box(333), box(143), nullptr); - avl = remove_int(avl, 439); - avl = gpr_avl_add(avl, box(35), box(145), nullptr); - avl = gpr_avl_add(avl, box(837), box(146), nullptr); - avl = remove_int(avl, 65); - avl = remove_int(avl, 642); - avl = remove_int(avl, 371); - avl = remove_int(avl, 140); - avl = remove_int(avl, 533); - avl = remove_int(avl, 676); - avl = gpr_avl_add(avl, box(624), box(153), nullptr); - avl = gpr_avl_add(avl, box(116), box(154), nullptr); - avl = gpr_avl_add(avl, box(446), box(155), nullptr); - avl = remove_int(avl, 91); - avl = remove_int(avl, 721); - avl = remove_int(avl, 537); - avl = gpr_avl_add(avl, box(448), box(159), nullptr); - avl = remove_int(avl, 155); - avl = remove_int(avl, 344); - avl = remove_int(avl, 237); - avl = gpr_avl_add(avl, box(309), box(163), nullptr); - avl = gpr_avl_add(avl, box(434), box(164), nullptr); - avl = gpr_avl_add(avl, box(277), box(165), nullptr); - avl = remove_int(avl, 233); - avl = gpr_avl_add(avl, box(275), box(167), nullptr); - avl = gpr_avl_add(avl, box(218), box(168), nullptr); - avl = gpr_avl_add(avl, box(76), box(169), nullptr); - avl = gpr_avl_add(avl, box(898), box(170), nullptr); - avl = remove_int(avl, 771); - avl = gpr_avl_add(avl, box(237), box(172), nullptr); - avl = remove_int(avl, 327); - avl = gpr_avl_add(avl, box(499), box(174), nullptr); - avl = remove_int(avl, 727); - avl = remove_int(avl, 234); - avl = remove_int(avl, 623); - avl = remove_int(avl, 458); - avl = remove_int(avl, 326); - avl = remove_int(avl, 589); - avl = gpr_avl_add(avl, box(442), box(181), nullptr); - avl = remove_int(avl, 389); - avl = gpr_avl_add(avl, box(708), box(183), nullptr); - avl = gpr_avl_add(avl, box(594), box(184), nullptr); - avl = gpr_avl_add(avl, box(942), box(185), nullptr); - avl = gpr_avl_add(avl, box(282), box(186), nullptr); - avl = remove_int(avl, 434); - avl = remove_int(avl, 134); - avl = remove_int(avl, 270); - avl = remove_int(avl, 512); - avl = remove_int(avl, 265); - avl = remove_int(avl, 21); - avl = remove_int(avl, 193); - avl = remove_int(avl, 797); - avl = remove_int(avl, 347); - avl = gpr_avl_add(avl, box(99), box(196), nullptr); - avl = gpr_avl_add(avl, box(161), box(197), nullptr); - avl = remove_int(avl, 484); - avl = gpr_avl_add(avl, box(72), box(199), nullptr); - avl = remove_int(avl, 629); - avl = gpr_avl_add(avl, box(522), box(201), nullptr); - avl = remove_int(avl, 679); - avl = gpr_avl_add(avl, box(407), box(203), nullptr); - avl = remove_int(avl, 693); - avl = gpr_avl_add(avl, box(424), box(205), nullptr); - avl = gpr_avl_add(avl, box(651), box(206), nullptr); - avl = gpr_avl_add(avl, box(927), box(207), nullptr); - avl = remove_int(avl, 553); - avl = gpr_avl_add(avl, box(128), box(209), nullptr); - avl = gpr_avl_add(avl, box(616), box(210), nullptr); - avl = gpr_avl_add(avl, box(690), box(211), nullptr); - avl = remove_int(avl, 241); - avl = remove_int(avl, 179); - avl = gpr_avl_add(avl, box(697), box(214), nullptr); - avl = remove_int(avl, 779); - avl = gpr_avl_add(avl, box(241), box(216), nullptr); - avl = remove_int(avl, 190); - avl = remove_int(avl, 210); - avl = gpr_avl_add(avl, box(711), box(219), nullptr); - avl = remove_int(avl, 251); - avl = remove_int(avl, 61); - avl = gpr_avl_add(avl, box(800), box(222), nullptr); - avl = remove_int(avl, 551); - avl = gpr_avl_add(avl, box(61), box(224), nullptr); - avl = gpr_avl_add(avl, box(656), box(225), nullptr); - avl = remove_int(avl, 130); - avl = remove_int(avl, 368); - avl = remove_int(avl, 150); - avl = remove_int(avl, 73); - avl = gpr_avl_add(avl, box(799), box(230), nullptr); - avl = gpr_avl_add(avl, box(125), box(231), nullptr); - avl = remove_int(avl, 107); - avl = gpr_avl_add(avl, box(938), box(233), nullptr); - avl = gpr_avl_add(avl, box(914), box(234), nullptr); - avl = gpr_avl_add(avl, box(197), box(235), nullptr); - avl = remove_int(avl, 736); - avl = gpr_avl_add(avl, box(20), box(237), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 841); - avl = gpr_avl_add(avl, box(226), box(240), nullptr); - avl = remove_int(avl, 963); - avl = remove_int(avl, 796); - avl = remove_int(avl, 728); - avl = gpr_avl_add(avl, box(855), box(244), nullptr); - avl = gpr_avl_add(avl, box(769), box(245), nullptr); - avl = gpr_avl_add(avl, box(631), box(246), nullptr); - avl = remove_int(avl, 648); - avl = gpr_avl_add(avl, box(187), box(248), nullptr); - avl = gpr_avl_add(avl, box(31), box(249), nullptr); - avl = remove_int(avl, 163); - avl = gpr_avl_add(avl, box(218), box(251), nullptr); - avl = gpr_avl_add(avl, box(488), box(252), nullptr); - avl = gpr_avl_add(avl, box(387), box(253), nullptr); - avl = gpr_avl_add(avl, box(809), box(254), nullptr); - avl = gpr_avl_add(avl, box(997), box(255), nullptr); - avl = remove_int(avl, 678); - avl = gpr_avl_add(avl, box(368), box(257), nullptr); - avl = gpr_avl_add(avl, box(220), box(258), nullptr); - avl = gpr_avl_add(avl, box(373), box(259), nullptr); - avl = remove_int(avl, 874); - avl = remove_int(avl, 682); - avl = remove_int(avl, 1014); - avl = remove_int(avl, 195); - avl = gpr_avl_add(avl, box(868), box(264), nullptr); - avl = remove_int(avl, 254); - avl = remove_int(avl, 456); - avl = gpr_avl_add(avl, box(906), box(267), nullptr); - avl = remove_int(avl, 711); - avl = gpr_avl_add(avl, box(632), box(269), nullptr); - avl = remove_int(avl, 474); - avl = gpr_avl_add(avl, box(508), box(271), nullptr); - avl = gpr_avl_add(avl, box(518), box(272), nullptr); - avl = remove_int(avl, 579); - avl = remove_int(avl, 948); - avl = gpr_avl_add(avl, box(789), box(275), nullptr); - avl = gpr_avl_add(avl, box(48), box(276), nullptr); - avl = gpr_avl_add(avl, box(256), box(277), nullptr); - avl = gpr_avl_add(avl, box(754), box(278), nullptr); - avl = remove_int(avl, 215); - avl = gpr_avl_add(avl, box(679), box(280), nullptr); - avl = gpr_avl_add(avl, box(606), box(281), nullptr); - avl = remove_int(avl, 941); - avl = remove_int(avl, 31); - avl = gpr_avl_add(avl, box(758), box(284), nullptr); - avl = remove_int(avl, 101); - avl = gpr_avl_add(avl, box(244), box(286), nullptr); - avl = gpr_avl_add(avl, box(337), box(287), nullptr); - avl = gpr_avl_add(avl, box(461), box(288), nullptr); - avl = remove_int(avl, 476); - avl = gpr_avl_add(avl, box(845), box(290), nullptr); - avl = remove_int(avl, 160); - avl = gpr_avl_add(avl, box(690), box(292), nullptr); - avl = remove_int(avl, 931); - avl = gpr_avl_add(avl, box(869), box(294), nullptr); - avl = gpr_avl_add(avl, box(1019), box(295), nullptr); - avl = remove_int(avl, 591); - avl = remove_int(avl, 635); - avl = remove_int(avl, 67); - avl = gpr_avl_add(avl, box(113), box(299), nullptr); - avl = remove_int(avl, 305); - avl = gpr_avl_add(avl, box(10), box(301), nullptr); - avl = remove_int(avl, 823); - avl = remove_int(avl, 288); - avl = remove_int(avl, 239); - avl = gpr_avl_add(avl, box(646), box(305), nullptr); - avl = gpr_avl_add(avl, box(1006), box(306), nullptr); - avl = gpr_avl_add(avl, box(954), box(307), nullptr); - avl = gpr_avl_add(avl, box(199), box(308), nullptr); - avl = gpr_avl_add(avl, box(69), box(309), nullptr); - avl = gpr_avl_add(avl, box(984), box(310), nullptr); - avl = remove_int(avl, 568); - avl = remove_int(avl, 666); - avl = remove_int(avl, 37); - avl = gpr_avl_add(avl, box(845), box(314), nullptr); - avl = remove_int(avl, 535); - avl = remove_int(avl, 365); - avl = remove_int(avl, 676); - avl = remove_int(avl, 892); - avl = remove_int(avl, 425); - avl = remove_int(avl, 704); - avl = remove_int(avl, 168); - avl = gpr_avl_add(avl, box(853), box(322), nullptr); - avl = gpr_avl_add(avl, box(335), box(323), nullptr); - avl = gpr_avl_add(avl, box(961), box(324), nullptr); - avl = gpr_avl_add(avl, box(73), box(325), nullptr); - avl = remove_int(avl, 469); - avl = gpr_avl_add(avl, box(449), box(327), nullptr); - avl = remove_int(avl, 821); - avl = gpr_avl_add(avl, box(845), box(329), nullptr); - avl = remove_int(avl, 637); - avl = gpr_avl_add(avl, box(769), box(331), nullptr); - avl = gpr_avl_add(avl, box(901), box(332), nullptr); - avl = remove_int(avl, 142); - avl = remove_int(avl, 361); - avl = remove_int(avl, 876); - avl = gpr_avl_add(avl, box(614), box(336), nullptr); - avl = gpr_avl_add(avl, box(729), box(337), nullptr); - avl = remove_int(avl, 120); - avl = remove_int(avl, 473); - avl = remove_int(avl, 445); - avl = gpr_avl_add(avl, box(978), box(341), nullptr); - avl = gpr_avl_add(avl, box(164), box(342), nullptr); - avl = gpr_avl_add(avl, box(1), box(343), nullptr); - avl = remove_int(avl, 890); - avl = gpr_avl_add(avl, box(605), box(345), nullptr); - avl = gpr_avl_add(avl, box(178), box(346), nullptr); - avl = gpr_avl_add(avl, box(481), box(347), nullptr); - avl = gpr_avl_add(avl, box(772), box(348), nullptr); - avl = remove_int(avl, 824); - avl = remove_int(avl, 167); - avl = remove_int(avl, 151); - avl = gpr_avl_add(avl, box(698), box(352), nullptr); - avl = gpr_avl_add(avl, box(202), box(353), nullptr); - avl = gpr_avl_add(avl, box(921), box(354), nullptr); - avl = gpr_avl_add(avl, box(875), box(355), nullptr); - avl = remove_int(avl, 197); - avl = remove_int(avl, 232); - avl = gpr_avl_add(avl, box(209), box(358), nullptr); - avl = remove_int(avl, 324); - avl = remove_int(avl, 56); - avl = remove_int(avl, 579); - avl = remove_int(avl, 255); - avl = remove_int(avl, 290); - avl = gpr_avl_add(avl, box(661), box(364), nullptr); - avl = gpr_avl_add(avl, box(113), box(365), nullptr); - avl = remove_int(avl, 767); - avl = gpr_avl_add(avl, box(586), box(367), nullptr); - avl = gpr_avl_add(avl, box(121), box(368), nullptr); - avl = remove_int(avl, 235); - avl = remove_int(avl, 439); - avl = remove_int(avl, 360); - avl = gpr_avl_add(avl, box(916), box(372), nullptr); - avl = remove_int(avl, 999); - avl = gpr_avl_add(avl, box(825), box(374), nullptr); - avl = gpr_avl_add(avl, box(177), box(375), nullptr); - avl = remove_int(avl, 204); - avl = remove_int(avl, 92); - avl = gpr_avl_add(avl, box(794), box(378), nullptr); - avl = gpr_avl_add(avl, box(463), box(379), nullptr); - avl = gpr_avl_add(avl, box(472), box(380), nullptr); - avl = remove_int(avl, 235); - avl = gpr_avl_add(avl, box(840), box(382), nullptr); - avl = remove_int(avl, 657); - avl = gpr_avl_add(avl, box(586), box(384), nullptr); - avl = gpr_avl_add(avl, box(979), box(385), nullptr); - avl = remove_int(avl, 979); - avl = gpr_avl_add(avl, box(639), box(387), nullptr); - avl = remove_int(avl, 907); - avl = remove_int(avl, 973); - avl = gpr_avl_add(avl, box(913), box(390), nullptr); - avl = gpr_avl_add(avl, box(566), box(391), nullptr); - avl = gpr_avl_add(avl, box(883), box(392), nullptr); - avl = gpr_avl_add(avl, box(552), box(393), nullptr); - avl = gpr_avl_add(avl, box(16), box(394), nullptr); - avl = remove_int(avl, 60); - avl = gpr_avl_add(avl, box(567), box(396), nullptr); - avl = gpr_avl_add(avl, box(705), box(397), nullptr); - avl = gpr_avl_add(avl, box(94), box(398), nullptr); - avl = remove_int(avl, 321); - avl = gpr_avl_add(avl, box(207), box(400), nullptr); - avl = gpr_avl_add(avl, box(682), box(401), nullptr); - avl = gpr_avl_add(avl, box(592), box(402), nullptr); - avl = gpr_avl_add(avl, box(10), box(403), nullptr); - avl = remove_int(avl, 911); - avl = remove_int(avl, 161); - avl = gpr_avl_add(avl, box(86), box(406), nullptr); - avl = remove_int(avl, 893); - avl = remove_int(avl, 362); - avl = gpr_avl_add(avl, box(599), box(409), nullptr); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(867), box(411), nullptr); - avl = remove_int(avl, 955); - avl = gpr_avl_add(avl, box(341), box(413), nullptr); - avl = gpr_avl_add(avl, box(887), box(414), nullptr); - avl = remove_int(avl, 706); - avl = gpr_avl_add(avl, box(939), box(416), nullptr); - avl = remove_int(avl, 233); - avl = remove_int(avl, 662); - avl = remove_int(avl, 984); - avl = remove_int(avl, 203); - avl = gpr_avl_add(avl, box(326), box(421), nullptr); - avl = remove_int(avl, 848); - avl = gpr_avl_add(avl, box(235), box(423), nullptr); - avl = remove_int(avl, 617); - avl = gpr_avl_add(avl, box(565), box(425), nullptr); - avl = remove_int(avl, 469); - avl = gpr_avl_add(avl, box(988), box(427), nullptr); - avl = remove_int(avl, 957); - avl = gpr_avl_add(avl, box(426), box(429), nullptr); - avl = remove_int(avl, 967); - avl = gpr_avl_add(avl, box(890), box(431), nullptr); - avl = gpr_avl_add(avl, box(473), box(432), nullptr); - avl = remove_int(avl, 367); - avl = remove_int(avl, 344); - avl = remove_int(avl, 660); - avl = remove_int(avl, 448); - avl = remove_int(avl, 837); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(459), box(439), nullptr); - avl = remove_int(avl, 882); - avl = remove_int(avl, 782); - avl = gpr_avl_add(avl, box(408), box(442), nullptr); - avl = gpr_avl_add(avl, box(728), box(443), nullptr); - avl = remove_int(avl, 27); - avl = gpr_avl_add(avl, box(137), box(445), nullptr); - avl = gpr_avl_add(avl, box(239), box(446), nullptr); - avl = remove_int(avl, 854); - avl = gpr_avl_add(avl, box(104), box(448), nullptr); - avl = gpr_avl_add(avl, box(823), box(449), nullptr); - avl = gpr_avl_add(avl, box(524), box(450), nullptr); - avl = gpr_avl_add(avl, box(995), box(451), nullptr); - avl = remove_int(avl, 422); - avl = remove_int(avl, 220); - avl = gpr_avl_add(avl, box(856), box(454), nullptr); - avl = remove_int(avl, 332); - avl = gpr_avl_add(avl, box(679), box(456), nullptr); - avl = remove_int(avl, 18); - avl = gpr_avl_add(avl, box(837), box(458), nullptr); - avl = remove_int(avl, 405); - avl = remove_int(avl, 877); - avl = remove_int(avl, 835); - avl = gpr_avl_add(avl, box(547), box(462), nullptr); - avl = remove_int(avl, 805); - avl = remove_int(avl, 862); - avl = gpr_avl_add(avl, box(75), box(465), nullptr); - avl = remove_int(avl, 41); - avl = gpr_avl_add(avl, box(310), box(467), nullptr); - avl = remove_int(avl, 855); - avl = gpr_avl_add(avl, box(20), box(469), nullptr); - avl = remove_int(avl, 186); - avl = remove_int(avl, 378); - avl = remove_int(avl, 442); - avl = remove_int(avl, 930); - avl = gpr_avl_add(avl, box(118), box(474), nullptr); - avl = gpr_avl_add(avl, box(96), box(475), nullptr); - avl = remove_int(avl, 854); - avl = gpr_avl_add(avl, box(65), box(477), nullptr); - avl = gpr_avl_add(avl, box(573), box(478), nullptr); - avl = gpr_avl_add(avl, box(4), box(479), nullptr); - avl = gpr_avl_add(avl, box(451), box(480), nullptr); - avl = gpr_avl_add(avl, box(774), box(481), nullptr); - avl = gpr_avl_add(avl, box(126), box(482), nullptr); - avl = remove_int(avl, 956); - avl = remove_int(avl, 591); - avl = remove_int(avl, 644); - avl = gpr_avl_add(avl, box(304), box(486), nullptr); - avl = remove_int(avl, 620); - avl = remove_int(avl, 394); - avl = gpr_avl_add(avl, box(1002), box(489), nullptr); - avl = gpr_avl_add(avl, box(837), box(490), nullptr); - avl = remove_int(avl, 485); - avl = gpr_avl_add(avl, box(1005), box(492), nullptr); - avl = remove_int(avl, 21); - avl = gpr_avl_add(avl, box(396), box(494), nullptr); - avl = remove_int(avl, 966); - avl = gpr_avl_add(avl, box(105), box(496), nullptr); - avl = gpr_avl_add(avl, box(316), box(497), nullptr); - avl = remove_int(avl, 776); - avl = gpr_avl_add(avl, box(188), box(499), nullptr); - avl = remove_int(avl, 200); - avl = gpr_avl_add(avl, box(98), box(501), nullptr); - avl = gpr_avl_add(avl, box(831), box(502), nullptr); - avl = gpr_avl_add(avl, box(227), box(503), nullptr); - avl = gpr_avl_add(avl, box(220), box(504), nullptr); - avl = remove_int(avl, 715); - avl = remove_int(avl, 279); - avl = gpr_avl_add(avl, box(701), box(507), nullptr); - avl = gpr_avl_add(avl, box(726), box(508), nullptr); - avl = gpr_avl_add(avl, box(815), box(509), nullptr); - avl = gpr_avl_add(avl, box(749), box(510), nullptr); - avl = remove_int(avl, 946); - avl = remove_int(avl, 449); - avl = remove_int(avl, 62); - avl = remove_int(avl, 487); - avl = gpr_avl_add(avl, box(545), box(515), nullptr); - avl = remove_int(avl, 59); - avl = gpr_avl_add(avl, box(168), box(517), nullptr); - avl = remove_int(avl, 337); - avl = gpr_avl_add(avl, box(69), box(519), nullptr); - avl = remove_int(avl, 600); - avl = gpr_avl_add(avl, box(591), box(521), nullptr); - avl = gpr_avl_add(avl, box(960), box(522), nullptr); - avl = gpr_avl_add(avl, box(116), box(523), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(760), box(525), nullptr); - avl = gpr_avl_add(avl, box(664), box(526), nullptr); - avl = gpr_avl_add(avl, box(547), box(527), nullptr); - avl = remove_int(avl, 922); - avl = gpr_avl_add(avl, box(290), box(529), nullptr); - avl = gpr_avl_add(avl, box(859), box(530), nullptr); - avl = gpr_avl_add(avl, box(49), box(531), nullptr); - avl = remove_int(avl, 455); - avl = remove_int(avl, 786); - avl = gpr_avl_add(avl, box(613), box(534), nullptr); - avl = gpr_avl_add(avl, box(326), box(535), nullptr); - avl = remove_int(avl, 615); - avl = gpr_avl_add(avl, box(45), box(537), nullptr); - avl = gpr_avl_add(avl, box(162), box(538), nullptr); - avl = gpr_avl_add(avl, box(189), box(539), nullptr); - avl = remove_int(avl, 68); - avl = remove_int(avl, 846); - avl = gpr_avl_add(avl, box(608), box(542), nullptr); - avl = remove_int(avl, 821); - avl = gpr_avl_add(avl, box(978), box(544), nullptr); - avl = gpr_avl_add(avl, box(892), box(545), nullptr); - avl = remove_int(avl, 924); - avl = gpr_avl_add(avl, box(708), box(547), nullptr); - avl = remove_int(avl, 135); - avl = remove_int(avl, 124); - avl = gpr_avl_add(avl, box(301), box(550), nullptr); - avl = gpr_avl_add(avl, box(939), box(551), nullptr); - avl = gpr_avl_add(avl, box(344), box(552), nullptr); - avl = remove_int(avl, 443); - avl = remove_int(avl, 122); - avl = gpr_avl_add(avl, box(636), box(555), nullptr); - avl = remove_int(avl, 558); - avl = gpr_avl_add(avl, box(923), box(557), nullptr); - avl = remove_int(avl, 827); - avl = gpr_avl_add(avl, box(649), box(559), nullptr); - avl = gpr_avl_add(avl, box(808), box(560), nullptr); - avl = remove_int(avl, 570); - avl = remove_int(avl, 434); - avl = gpr_avl_add(avl, box(40), box(563), nullptr); - avl = gpr_avl_add(avl, box(725), box(564), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 615); - avl = remove_int(avl, 919); - avl = remove_int(avl, 170); - avl = remove_int(avl, 442); - avl = remove_int(avl, 971); - avl = gpr_avl_add(avl, box(483), box(571), nullptr); - avl = gpr_avl_add(avl, box(512), box(572), nullptr); - avl = remove_int(avl, 648); - avl = remove_int(avl, 78); - avl = remove_int(avl, 72); - avl = remove_int(avl, 790); - avl = remove_int(avl, 571); - avl = gpr_avl_add(avl, box(898), box(578), nullptr); - avl = remove_int(avl, 770); - avl = remove_int(avl, 776); - avl = gpr_avl_add(avl, box(602), box(581), nullptr); - avl = remove_int(avl, 251); - avl = gpr_avl_add(avl, box(303), box(583), nullptr); - avl = remove_int(avl, 837); - avl = gpr_avl_add(avl, box(714), box(585), nullptr); - avl = remove_int(avl, 800); - avl = gpr_avl_add(avl, box(266), box(587), nullptr); - avl = gpr_avl_add(avl, box(555), box(588), nullptr); - avl = remove_int(avl, 604); - avl = remove_int(avl, 163); - avl = remove_int(avl, 497); - avl = gpr_avl_add(avl, box(296), box(592), nullptr); - avl = remove_int(avl, 129); - avl = gpr_avl_add(avl, box(656), box(594), nullptr); - avl = remove_int(avl, 769); - avl = remove_int(avl, 941); - avl = gpr_avl_add(avl, box(775), box(597), nullptr); - avl = gpr_avl_add(avl, box(846), box(598), nullptr); - avl = remove_int(avl, 591); - avl = remove_int(avl, 801); - avl = remove_int(avl, 419); - avl = remove_int(avl, 455); - avl = gpr_avl_add(avl, box(866), box(603), nullptr); - avl = gpr_avl_add(avl, box(575), box(604), nullptr); - avl = gpr_avl_add(avl, box(620), box(605), nullptr); - avl = remove_int(avl, 100); - avl = remove_int(avl, 667); - avl = gpr_avl_add(avl, box(138), box(608), nullptr); - avl = gpr_avl_add(avl, box(566), box(609), nullptr); - avl = gpr_avl_add(avl, box(673), box(610), nullptr); - avl = gpr_avl_add(avl, box(178), box(611), nullptr); - avl = remove_int(avl, 659); - avl = gpr_avl_add(avl, box(759), box(613), nullptr); - avl = gpr_avl_add(avl, box(1008), box(614), nullptr); - avl = remove_int(avl, 116); - avl = gpr_avl_add(avl, box(608), box(616), nullptr); - avl = gpr_avl_add(avl, box(339), box(617), nullptr); - avl = gpr_avl_add(avl, box(197), box(618), nullptr); - avl = remove_int(avl, 25); - avl = remove_int(avl, 628); - avl = gpr_avl_add(avl, box(487), box(621), nullptr); - avl = remove_int(avl, 739); - avl = remove_int(avl, 100); - avl = remove_int(avl, 928); - avl = gpr_avl_add(avl, box(647), box(625), nullptr); - avl = remove_int(avl, 978); - avl = remove_int(avl, 143); - avl = remove_int(avl, 755); - avl = gpr_avl_add(avl, box(71), box(629), nullptr); - avl = remove_int(avl, 205); - avl = gpr_avl_add(avl, box(501), box(631), nullptr); - avl = remove_int(avl, 723); - avl = remove_int(avl, 852); - avl = remove_int(avl, 1021); - avl = remove_int(avl, 670); - avl = remove_int(avl, 500); - avl = gpr_avl_add(avl, box(330), box(637), nullptr); - avl = remove_int(avl, 264); - avl = gpr_avl_add(avl, box(69), box(639), nullptr); - avl = remove_int(avl, 73); - avl = gpr_avl_add(avl, box(745), box(641), nullptr); - avl = remove_int(avl, 518); - avl = remove_int(avl, 641); - avl = remove_int(avl, 768); - avl = gpr_avl_add(avl, box(988), box(645), nullptr); - avl = gpr_avl_add(avl, box(899), box(646), nullptr); - avl = remove_int(avl, 763); - avl = remove_int(avl, 281); - avl = remove_int(avl, 496); - avl = gpr_avl_add(avl, box(445), box(650), nullptr); - avl = remove_int(avl, 905); - avl = gpr_avl_add(avl, box(275), box(652), nullptr); - avl = gpr_avl_add(avl, box(137), box(653), nullptr); - avl = remove_int(avl, 642); - avl = gpr_avl_add(avl, box(708), box(655), nullptr); - avl = remove_int(avl, 922); - avl = gpr_avl_add(avl, box(743), box(657), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 665); - avl = remove_int(avl, 48); - avl = gpr_avl_add(avl, box(1012), box(661), nullptr); - avl = remove_int(avl, 71); - avl = remove_int(avl, 523); - avl = gpr_avl_add(avl, box(319), box(664), nullptr); - avl = remove_int(avl, 632); - avl = gpr_avl_add(avl, box(137), box(666), nullptr); - avl = gpr_avl_add(avl, box(686), box(667), nullptr); - avl = gpr_avl_add(avl, box(724), box(668), nullptr); - avl = gpr_avl_add(avl, box(952), box(669), nullptr); - avl = gpr_avl_add(avl, box(5), box(670), nullptr); - avl = remove_int(avl, 35); - avl = gpr_avl_add(avl, box(43), box(672), nullptr); - avl = gpr_avl_add(avl, box(320), box(673), nullptr); - avl = gpr_avl_add(avl, box(115), box(674), nullptr); - avl = remove_int(avl, 377); - avl = remove_int(avl, 591); - avl = remove_int(avl, 87); - avl = remove_int(avl, 93); - avl = gpr_avl_add(avl, box(1016), box(679), nullptr); - avl = gpr_avl_add(avl, box(605), box(680), nullptr); - avl = gpr_avl_add(avl, box(152), box(681), nullptr); - avl = gpr_avl_add(avl, box(113), box(682), nullptr); - avl = remove_int(avl, 131); - avl = remove_int(avl, 637); - avl = gpr_avl_add(avl, box(156), box(685), nullptr); - avl = remove_int(avl, 696); - avl = gpr_avl_add(avl, box(546), box(687), nullptr); - avl = remove_int(avl, 970); - avl = remove_int(avl, 53); - avl = remove_int(avl, 827); - avl = remove_int(avl, 224); - avl = remove_int(avl, 796); - avl = remove_int(avl, 34); - avl = remove_int(avl, 922); - avl = remove_int(avl, 277); - avl = remove_int(avl, 650); - avl = remove_int(avl, 222); - avl = remove_int(avl, 244); - avl = remove_int(avl, 576); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(500), box(701), nullptr); - avl = remove_int(avl, 924); - avl = gpr_avl_add(avl, box(825), box(703), nullptr); - avl = remove_int(avl, 888); - avl = remove_int(avl, 931); - avl = gpr_avl_add(avl, box(285), box(706), nullptr); - avl = remove_int(avl, 62); - avl = remove_int(avl, 444); - avl = remove_int(avl, 946); - avl = gpr_avl_add(avl, box(122), box(710), nullptr); - avl = gpr_avl_add(avl, box(846), box(711), nullptr); - avl = remove_int(avl, 628); - avl = gpr_avl_add(avl, box(511), box(713), nullptr); - avl = gpr_avl_add(avl, box(398), box(714), nullptr); - avl = remove_int(avl, 730); - avl = gpr_avl_add(avl, box(797), box(716), nullptr); - avl = remove_int(avl, 897); - avl = remove_int(avl, 228); - avl = remove_int(avl, 544); - avl = remove_int(avl, 552); - avl = remove_int(avl, 783); - avl = remove_int(avl, 583); - avl = remove_int(avl, 894); - avl = remove_int(avl, 942); - avl = gpr_avl_add(avl, box(346), box(725), nullptr); - avl = gpr_avl_add(avl, box(1015), box(726), nullptr); - avl = remove_int(avl, 813); - avl = gpr_avl_add(avl, box(213), box(728), nullptr); - avl = remove_int(avl, 468); - avl = remove_int(avl, 365); - avl = remove_int(avl, 399); - avl = gpr_avl_add(avl, box(380), box(732), nullptr); - avl = remove_int(avl, 835); - avl = remove_int(avl, 970); - avl = gpr_avl_add(avl, box(700), box(735), nullptr); - avl = gpr_avl_add(avl, box(807), box(736), nullptr); - avl = remove_int(avl, 312); - avl = remove_int(avl, 282); - avl = remove_int(avl, 370); - avl = remove_int(avl, 999); - avl = remove_int(avl, 241); - avl = remove_int(avl, 884); - avl = gpr_avl_add(avl, box(587), box(743), nullptr); - avl = gpr_avl_add(avl, box(332), box(744), nullptr); - avl = remove_int(avl, 686); - avl = remove_int(avl, 206); - avl = remove_int(avl, 835); - avl = gpr_avl_add(avl, box(334), box(748), nullptr); - avl = remove_int(avl, 171); - avl = gpr_avl_add(avl, box(1002), box(750), nullptr); - avl = gpr_avl_add(avl, box(779), box(751), nullptr); - avl = gpr_avl_add(avl, box(307), box(752), nullptr); - avl = gpr_avl_add(avl, box(127), box(753), nullptr); - avl = gpr_avl_add(avl, box(251), box(754), nullptr); - avl = remove_int(avl, 790); - avl = remove_int(avl, 189); - avl = remove_int(avl, 193); - avl = remove_int(avl, 38); - avl = remove_int(avl, 124); - avl = gpr_avl_add(avl, box(812), box(760), nullptr); - avl = remove_int(avl, 43); - avl = gpr_avl_add(avl, box(871), box(762), nullptr); - avl = gpr_avl_add(avl, box(580), box(763), nullptr); - avl = remove_int(avl, 501); - avl = remove_int(avl, 462); - avl = remove_int(avl, 599); - avl = gpr_avl_add(avl, box(240), box(767), nullptr); - avl = gpr_avl_add(avl, box(285), box(768), nullptr); - avl = gpr_avl_add(avl, box(472), box(769), nullptr); - avl = remove_int(avl, 865); - avl = remove_int(avl, 763); - avl = remove_int(avl, 245); - avl = remove_int(avl, 80); - avl = remove_int(avl, 713); - avl = remove_int(avl, 654); - avl = remove_int(avl, 1014); - avl = gpr_avl_add(avl, box(495), box(777), nullptr); - avl = gpr_avl_add(avl, box(552), box(778), nullptr); - avl = remove_int(avl, 19); - avl = remove_int(avl, 803); - avl = gpr_avl_add(avl, box(508), box(781), nullptr); - avl = remove_int(avl, 699); - avl = remove_int(avl, 260); - avl = remove_int(avl, 92); - avl = remove_int(avl, 497); - avl = gpr_avl_add(avl, box(970), box(786), nullptr); - avl = remove_int(avl, 987); - avl = remove_int(avl, 168); - avl = remove_int(avl, 476); - avl = remove_int(avl, 248); - avl = gpr_avl_add(avl, box(358), box(791), nullptr); - avl = remove_int(avl, 804); - avl = remove_int(avl, 77); - avl = remove_int(avl, 905); - avl = remove_int(avl, 362); - avl = gpr_avl_add(avl, box(578), box(796), nullptr); - avl = remove_int(avl, 38); - avl = remove_int(avl, 595); - avl = gpr_avl_add(avl, box(213), box(799), nullptr); - avl = remove_int(avl, 7); - avl = remove_int(avl, 620); - avl = gpr_avl_add(avl, box(946), box(802), nullptr); - avl = remove_int(avl, 145); - avl = gpr_avl_add(avl, box(628), box(804), nullptr); - avl = remove_int(avl, 972); - avl = gpr_avl_add(avl, box(728), box(806), nullptr); - avl = remove_int(avl, 91); - avl = gpr_avl_add(avl, box(136), box(808), nullptr); - avl = gpr_avl_add(avl, box(841), box(809), nullptr); - avl = gpr_avl_add(avl, box(265), box(810), nullptr); - avl = gpr_avl_add(avl, box(701), box(811), nullptr); - avl = gpr_avl_add(avl, box(27), box(812), nullptr); - avl = remove_int(avl, 72); - avl = remove_int(avl, 14); - avl = gpr_avl_add(avl, box(286), box(815), nullptr); - avl = remove_int(avl, 996); - avl = remove_int(avl, 998); - avl = gpr_avl_add(avl, box(466), box(818), nullptr); - avl = remove_int(avl, 1009); - avl = remove_int(avl, 741); - avl = remove_int(avl, 947); - avl = remove_int(avl, 241); - avl = remove_int(avl, 954); - avl = remove_int(avl, 183); - avl = remove_int(avl, 395); - avl = remove_int(avl, 951); - avl = gpr_avl_add(avl, box(267), box(827), nullptr); - avl = remove_int(avl, 812); - avl = gpr_avl_add(avl, box(577), box(829), nullptr); - avl = remove_int(avl, 624); - avl = remove_int(avl, 847); - avl = remove_int(avl, 745); - avl = gpr_avl_add(avl, box(491), box(833), nullptr); - avl = gpr_avl_add(avl, box(941), box(834), nullptr); - avl = remove_int(avl, 258); - avl = gpr_avl_add(avl, box(410), box(836), nullptr); - avl = gpr_avl_add(avl, box(80), box(837), nullptr); - avl = gpr_avl_add(avl, box(196), box(838), nullptr); - avl = gpr_avl_add(avl, box(5), box(839), nullptr); - avl = remove_int(avl, 782); - avl = gpr_avl_add(avl, box(827), box(841), nullptr); - avl = remove_int(avl, 472); - avl = remove_int(avl, 664); - avl = gpr_avl_add(avl, box(409), box(844), nullptr); - avl = gpr_avl_add(avl, box(62), box(845), nullptr); - avl = remove_int(avl, 56); - avl = remove_int(avl, 606); - avl = remove_int(avl, 707); - avl = remove_int(avl, 989); - avl = remove_int(avl, 549); - avl = remove_int(avl, 259); - avl = gpr_avl_add(avl, box(405), box(852), nullptr); - avl = remove_int(avl, 587); - avl = remove_int(avl, 350); - avl = gpr_avl_add(avl, box(980), box(855), nullptr); - avl = gpr_avl_add(avl, box(992), box(856), nullptr); - avl = gpr_avl_add(avl, box(818), box(857), nullptr); - avl = remove_int(avl, 853); - avl = remove_int(avl, 701); - avl = gpr_avl_add(avl, box(675), box(860), nullptr); - avl = remove_int(avl, 248); - avl = remove_int(avl, 649); - avl = gpr_avl_add(avl, box(508), box(863), nullptr); - avl = remove_int(avl, 927); - avl = gpr_avl_add(avl, box(957), box(865), nullptr); - avl = gpr_avl_add(avl, box(698), box(866), nullptr); - avl = gpr_avl_add(avl, box(388), box(867), nullptr); - avl = gpr_avl_add(avl, box(532), box(868), nullptr); - avl = gpr_avl_add(avl, box(681), box(869), nullptr); - avl = remove_int(avl, 544); - avl = remove_int(avl, 991); - avl = remove_int(avl, 397); - avl = gpr_avl_add(avl, box(954), box(873), nullptr); - avl = gpr_avl_add(avl, box(219), box(874), nullptr); - avl = gpr_avl_add(avl, box(465), box(875), nullptr); - avl = remove_int(avl, 371); - avl = gpr_avl_add(avl, box(601), box(877), nullptr); - avl = gpr_avl_add(avl, box(543), box(878), nullptr); - avl = remove_int(avl, 329); - avl = gpr_avl_add(avl, box(560), box(880), nullptr); - avl = remove_int(avl, 898); - avl = gpr_avl_add(avl, box(455), box(882), nullptr); - avl = remove_int(avl, 313); - avl = gpr_avl_add(avl, box(215), box(884), nullptr); - avl = remove_int(avl, 846); - avl = gpr_avl_add(avl, box(608), box(886), nullptr); - avl = remove_int(avl, 248); - avl = gpr_avl_add(avl, box(575), box(888), nullptr); - avl = remove_int(avl, 207); - avl = remove_int(avl, 810); - avl = remove_int(avl, 665); - avl = remove_int(avl, 361); - avl = gpr_avl_add(avl, box(154), box(893), nullptr); - avl = gpr_avl_add(avl, box(329), box(894), nullptr); - avl = gpr_avl_add(avl, box(326), box(895), nullptr); - avl = remove_int(avl, 746); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(464), box(898), nullptr); - avl = gpr_avl_add(avl, box(141), box(899), nullptr); - avl = remove_int(avl, 383); - avl = gpr_avl_add(avl, box(414), box(901), nullptr); - avl = gpr_avl_add(avl, box(777), box(902), nullptr); - avl = remove_int(avl, 972); - avl = remove_int(avl, 841); - avl = remove_int(avl, 100); - avl = gpr_avl_add(avl, box(828), box(906), nullptr); - avl = remove_int(avl, 785); - avl = gpr_avl_add(avl, box(1008), box(908), nullptr); - avl = gpr_avl_add(avl, box(46), box(909), nullptr); - avl = remove_int(avl, 399); - avl = gpr_avl_add(avl, box(178), box(911), nullptr); - avl = gpr_avl_add(avl, box(573), box(912), nullptr); - avl = remove_int(avl, 299); - avl = gpr_avl_add(avl, box(690), box(914), nullptr); - avl = gpr_avl_add(avl, box(692), box(915), nullptr); - avl = remove_int(avl, 404); - avl = remove_int(avl, 16); - avl = remove_int(avl, 746); - avl = remove_int(avl, 486); - avl = remove_int(avl, 119); - avl = gpr_avl_add(avl, box(167), box(921), nullptr); - avl = remove_int(avl, 328); - avl = gpr_avl_add(avl, box(89), box(923), nullptr); - avl = remove_int(avl, 867); - avl = remove_int(avl, 626); - avl = remove_int(avl, 507); - avl = gpr_avl_add(avl, box(365), box(927), nullptr); - avl = gpr_avl_add(avl, box(58), box(928), nullptr); - avl = gpr_avl_add(avl, box(70), box(929), nullptr); - avl = remove_int(avl, 81); - avl = remove_int(avl, 797); - avl = gpr_avl_add(avl, box(846), box(932), nullptr); - avl = remove_int(avl, 642); - avl = gpr_avl_add(avl, box(777), box(934), nullptr); - avl = remove_int(avl, 107); - avl = gpr_avl_add(avl, box(691), box(936), nullptr); - avl = gpr_avl_add(avl, box(820), box(937), nullptr); - avl = gpr_avl_add(avl, box(202), box(938), nullptr); - avl = gpr_avl_add(avl, box(308), box(939), nullptr); - avl = gpr_avl_add(avl, box(20), box(940), nullptr); - avl = remove_int(avl, 289); - avl = gpr_avl_add(avl, box(714), box(942), nullptr); - avl = gpr_avl_add(avl, box(584), box(943), nullptr); - avl = remove_int(avl, 294); - avl = gpr_avl_add(avl, box(496), box(945), nullptr); - avl = gpr_avl_add(avl, box(394), box(946), nullptr); - avl = gpr_avl_add(avl, box(860), box(947), nullptr); - avl = gpr_avl_add(avl, box(58), box(948), nullptr); - avl = remove_int(avl, 784); - avl = remove_int(avl, 584); - avl = remove_int(avl, 708); - avl = gpr_avl_add(avl, box(142), box(952), nullptr); - avl = gpr_avl_add(avl, box(247), box(953), nullptr); - avl = gpr_avl_add(avl, box(389), box(954), nullptr); - avl = remove_int(avl, 390); - avl = gpr_avl_add(avl, box(465), box(956), nullptr); - avl = gpr_avl_add(avl, box(936), box(957), nullptr); - avl = gpr_avl_add(avl, box(309), box(958), nullptr); - avl = remove_int(avl, 928); - avl = remove_int(avl, 128); - avl = remove_int(avl, 979); - avl = remove_int(avl, 670); - avl = remove_int(avl, 738); - avl = remove_int(avl, 271); - avl = remove_int(avl, 540); - avl = gpr_avl_add(avl, box(365), box(966), nullptr); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(728), box(968), nullptr); - avl = remove_int(avl, 852); - avl = gpr_avl_add(avl, box(884), box(970), nullptr); - avl = gpr_avl_add(avl, box(502), box(971), nullptr); - avl = remove_int(avl, 898); - avl = remove_int(avl, 481); - avl = gpr_avl_add(avl, box(911), box(974), nullptr); - avl = remove_int(avl, 787); - avl = remove_int(avl, 785); - avl = remove_int(avl, 537); - avl = remove_int(avl, 535); - avl = remove_int(avl, 136); - avl = remove_int(avl, 749); - avl = remove_int(avl, 637); - avl = remove_int(avl, 900); - avl = gpr_avl_add(avl, box(598), box(983), nullptr); - avl = remove_int(avl, 25); - avl = remove_int(avl, 697); - avl = gpr_avl_add(avl, box(645), box(986), nullptr); - avl = gpr_avl_add(avl, box(211), box(987), nullptr); - avl = gpr_avl_add(avl, box(589), box(988), nullptr); - avl = remove_int(avl, 702); - avl = gpr_avl_add(avl, box(53), box(990), nullptr); - avl = remove_int(avl, 492); - avl = remove_int(avl, 185); - avl = remove_int(avl, 246); - avl = remove_int(avl, 257); - avl = remove_int(avl, 502); - avl = remove_int(avl, 34); - avl = gpr_avl_add(avl, box(74), box(997), nullptr); - avl = gpr_avl_add(avl, box(834), box(998), nullptr); - avl = gpr_avl_add(avl, box(514), box(999), nullptr); - avl = gpr_avl_add(avl, box(75), box(1000), nullptr); - avl = remove_int(avl, 745); - avl = gpr_avl_add(avl, box(362), box(1002), nullptr); - avl = remove_int(avl, 215); - avl = gpr_avl_add(avl, box(624), box(1004), nullptr); - avl = remove_int(avl, 404); - avl = remove_int(avl, 359); - avl = remove_int(avl, 491); - avl = gpr_avl_add(avl, box(903), box(1008), nullptr); - avl = gpr_avl_add(avl, box(240), box(1009), nullptr); - avl = remove_int(avl, 95); - avl = gpr_avl_add(avl, box(119), box(1011), nullptr); - avl = gpr_avl_add(avl, box(857), box(1012), nullptr); - avl = remove_int(avl, 39); - avl = remove_int(avl, 866); - avl = gpr_avl_add(avl, box(503), box(1015), nullptr); - avl = gpr_avl_add(avl, box(740), box(1016), nullptr); - avl = remove_int(avl, 637); - avl = remove_int(avl, 156); - avl = remove_int(avl, 6); - avl = remove_int(avl, 745); - avl = remove_int(avl, 433); - avl = remove_int(avl, 283); - avl = gpr_avl_add(avl, box(625), box(1023), nullptr); - avl = remove_int(avl, 638); - avl = gpr_avl_add(avl, box(299), box(1025), nullptr); - avl = gpr_avl_add(avl, box(584), box(1026), nullptr); - avl = remove_int(avl, 863); - avl = gpr_avl_add(avl, box(612), box(1028), nullptr); - avl = gpr_avl_add(avl, box(62), box(1029), nullptr); - avl = gpr_avl_add(avl, box(432), box(1030), nullptr); - avl = remove_int(avl, 371); - avl = remove_int(avl, 790); - avl = remove_int(avl, 227); - avl = remove_int(avl, 836); - avl = gpr_avl_add(avl, box(703), box(1035), nullptr); - avl = gpr_avl_add(avl, box(644), box(1036), nullptr); - avl = remove_int(avl, 638); - avl = gpr_avl_add(avl, box(13), box(1038), nullptr); - avl = remove_int(avl, 66); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(362), box(1041), nullptr); - avl = gpr_avl_add(avl, box(783), box(1042), nullptr); - avl = remove_int(avl, 60); - avl = gpr_avl_add(avl, box(80), box(1044), nullptr); - avl = gpr_avl_add(avl, box(825), box(1045), nullptr); - avl = gpr_avl_add(avl, box(688), box(1046), nullptr); - avl = gpr_avl_add(avl, box(662), box(1047), nullptr); - avl = remove_int(avl, 156); - avl = remove_int(avl, 376); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(526), box(1051), nullptr); - avl = gpr_avl_add(avl, box(168), box(1052), nullptr); - avl = remove_int(avl, 646); - avl = remove_int(avl, 380); - avl = remove_int(avl, 833); - avl = gpr_avl_add(avl, box(53), box(1056), nullptr); - avl = remove_int(avl, 105); - avl = gpr_avl_add(avl, box(373), box(1058), nullptr); - avl = gpr_avl_add(avl, box(184), box(1059), nullptr); - avl = remove_int(avl, 288); - avl = gpr_avl_add(avl, box(966), box(1061), nullptr); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(406), box(1063), nullptr); - avl = remove_int(avl, 470); - avl = gpr_avl_add(avl, box(283), box(1065), nullptr); - avl = gpr_avl_add(avl, box(838), box(1066), nullptr); - avl = gpr_avl_add(avl, box(288), box(1067), nullptr); - avl = gpr_avl_add(avl, box(950), box(1068), nullptr); - avl = gpr_avl_add(avl, box(163), box(1069), nullptr); - avl = remove_int(avl, 623); - avl = remove_int(avl, 769); - avl = gpr_avl_add(avl, box(144), box(1072), nullptr); - avl = gpr_avl_add(avl, box(489), box(1073), nullptr); - avl = remove_int(avl, 15); - avl = gpr_avl_add(avl, box(971), box(1075), nullptr); - avl = remove_int(avl, 660); - avl = gpr_avl_add(avl, box(255), box(1077), nullptr); - avl = remove_int(avl, 494); - avl = gpr_avl_add(avl, box(109), box(1079), nullptr); - avl = gpr_avl_add(avl, box(420), box(1080), nullptr); - avl = gpr_avl_add(avl, box(509), box(1081), nullptr); - avl = remove_int(avl, 178); - avl = gpr_avl_add(avl, box(216), box(1083), nullptr); - avl = gpr_avl_add(avl, box(707), box(1084), nullptr); - avl = gpr_avl_add(avl, box(411), box(1085), nullptr); - avl = gpr_avl_add(avl, box(352), box(1086), nullptr); - avl = remove_int(avl, 983); - avl = gpr_avl_add(avl, box(6), box(1088), nullptr); - avl = gpr_avl_add(avl, box(1014), box(1089), nullptr); - avl = remove_int(avl, 98); - avl = remove_int(avl, 325); - avl = gpr_avl_add(avl, box(851), box(1092), nullptr); - avl = remove_int(avl, 553); - avl = gpr_avl_add(avl, box(218), box(1094), nullptr); - avl = gpr_avl_add(avl, box(261), box(1095), nullptr); - avl = remove_int(avl, 31); - avl = gpr_avl_add(avl, box(872), box(1097), nullptr); - avl = remove_int(avl, 543); - avl = remove_int(avl, 314); - avl = remove_int(avl, 443); - avl = gpr_avl_add(avl, box(533), box(1101), nullptr); - avl = remove_int(avl, 881); - avl = remove_int(avl, 269); - avl = remove_int(avl, 940); - avl = remove_int(avl, 909); - avl = remove_int(avl, 197); - avl = remove_int(avl, 773); - avl = remove_int(avl, 790); - avl = remove_int(avl, 345); - avl = gpr_avl_add(avl, box(965), box(1110), nullptr); - avl = remove_int(avl, 622); - avl = gpr_avl_add(avl, box(352), box(1112), nullptr); - avl = remove_int(avl, 182); - avl = gpr_avl_add(avl, box(534), box(1114), nullptr); - avl = gpr_avl_add(avl, box(97), box(1115), nullptr); - avl = gpr_avl_add(avl, box(198), box(1116), nullptr); - avl = remove_int(avl, 750); - avl = gpr_avl_add(avl, box(98), box(1118), nullptr); - avl = remove_int(avl, 943); - avl = gpr_avl_add(avl, box(254), box(1120), nullptr); - avl = gpr_avl_add(avl, box(30), box(1121), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 475); - avl = remove_int(avl, 82); - avl = gpr_avl_add(avl, box(789), box(1125), nullptr); - avl = gpr_avl_add(avl, box(402), box(1126), nullptr); - avl = remove_int(avl, 1019); - avl = gpr_avl_add(avl, box(858), box(1128), nullptr); - avl = gpr_avl_add(avl, box(625), box(1129), nullptr); - avl = remove_int(avl, 675); - avl = remove_int(avl, 323); - avl = gpr_avl_add(avl, box(329), box(1132), nullptr); - avl = remove_int(avl, 929); - avl = remove_int(avl, 44); - avl = gpr_avl_add(avl, box(443), box(1135), nullptr); - avl = gpr_avl_add(avl, box(653), box(1136), nullptr); - avl = gpr_avl_add(avl, box(750), box(1137), nullptr); - avl = gpr_avl_add(avl, box(252), box(1138), nullptr); - avl = gpr_avl_add(avl, box(449), box(1139), nullptr); - avl = remove_int(avl, 1022); - avl = remove_int(avl, 357); - avl = remove_int(avl, 602); - avl = remove_int(avl, 131); - avl = gpr_avl_add(avl, box(531), box(1144), nullptr); - avl = remove_int(avl, 806); - avl = gpr_avl_add(avl, box(455), box(1146), nullptr); - avl = remove_int(avl, 31); - avl = gpr_avl_add(avl, box(154), box(1148), nullptr); - avl = gpr_avl_add(avl, box(189), box(1149), nullptr); - avl = remove_int(avl, 786); - avl = gpr_avl_add(avl, box(496), box(1151), nullptr); - avl = gpr_avl_add(avl, box(81), box(1152), nullptr); - avl = gpr_avl_add(avl, box(59), box(1153), nullptr); - avl = remove_int(avl, 424); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(723), box(1156), nullptr); - avl = gpr_avl_add(avl, box(822), box(1157), nullptr); - avl = gpr_avl_add(avl, box(354), box(1158), nullptr); - avl = remove_int(avl, 738); - avl = gpr_avl_add(avl, box(686), box(1160), nullptr); - avl = gpr_avl_add(avl, box(43), box(1161), nullptr); - avl = gpr_avl_add(avl, box(625), box(1162), nullptr); - avl = gpr_avl_add(avl, box(902), box(1163), nullptr); - avl = gpr_avl_add(avl, box(12), box(1164), nullptr); - avl = gpr_avl_add(avl, box(977), box(1165), nullptr); - avl = gpr_avl_add(avl, box(699), box(1166), nullptr); - avl = gpr_avl_add(avl, box(189), box(1167), nullptr); - avl = remove_int(avl, 672); - avl = remove_int(avl, 90); - avl = remove_int(avl, 757); - avl = remove_int(avl, 494); - avl = gpr_avl_add(avl, box(759), box(1172), nullptr); - avl = remove_int(avl, 758); - avl = remove_int(avl, 222); - avl = gpr_avl_add(avl, box(975), box(1175), nullptr); - avl = remove_int(avl, 993); - avl = gpr_avl_add(avl, box(2), box(1177), nullptr); - avl = gpr_avl_add(avl, box(70), box(1178), nullptr); - avl = remove_int(avl, 350); - avl = remove_int(avl, 972); - avl = remove_int(avl, 880); - avl = gpr_avl_add(avl, box(753), box(1182), nullptr); - avl = remove_int(avl, 404); - avl = gpr_avl_add(avl, box(294), box(1184), nullptr); - avl = remove_int(avl, 474); - avl = gpr_avl_add(avl, box(228), box(1186), nullptr); - avl = gpr_avl_add(avl, box(484), box(1187), nullptr); - avl = remove_int(avl, 238); - avl = remove_int(avl, 53); - avl = remove_int(avl, 691); - avl = gpr_avl_add(avl, box(345), box(1191), nullptr); - avl = remove_int(avl, 0); - avl = gpr_avl_add(avl, box(230), box(1193), nullptr); - avl = remove_int(avl, 227); - avl = remove_int(avl, 152); - avl = gpr_avl_add(avl, box(884), box(1196), nullptr); - avl = remove_int(avl, 823); - avl = remove_int(avl, 53); - avl = gpr_avl_add(avl, box(1015), box(1199), nullptr); - avl = gpr_avl_add(avl, box(697), box(1200), nullptr); - avl = gpr_avl_add(avl, box(376), box(1201), nullptr); - avl = remove_int(avl, 411); - avl = gpr_avl_add(avl, box(888), box(1203), nullptr); - avl = remove_int(avl, 55); - avl = gpr_avl_add(avl, box(85), box(1205), nullptr); - avl = remove_int(avl, 947); - avl = remove_int(avl, 382); - avl = remove_int(avl, 777); - avl = gpr_avl_add(avl, box(1017), box(1209), nullptr); - avl = gpr_avl_add(avl, box(169), box(1210), nullptr); - avl = gpr_avl_add(avl, box(156), box(1211), nullptr); - avl = remove_int(avl, 153); - avl = remove_int(avl, 642); - avl = remove_int(avl, 158); - avl = gpr_avl_add(avl, box(554), box(1215), nullptr); - avl = gpr_avl_add(avl, box(76), box(1216), nullptr); - avl = gpr_avl_add(avl, box(756), box(1217), nullptr); - avl = remove_int(avl, 767); - avl = remove_int(avl, 112); - avl = remove_int(avl, 539); - avl = remove_int(avl, 544); - avl = remove_int(avl, 628); - avl = remove_int(avl, 385); - avl = remove_int(avl, 514); - avl = remove_int(avl, 362); - avl = gpr_avl_add(avl, box(523), box(1226), nullptr); - avl = gpr_avl_add(avl, box(712), box(1227), nullptr); - avl = gpr_avl_add(avl, box(474), box(1228), nullptr); - avl = gpr_avl_add(avl, box(882), box(1229), nullptr); - avl = gpr_avl_add(avl, box(965), box(1230), nullptr); - avl = remove_int(avl, 464); - avl = gpr_avl_add(avl, box(319), box(1232), nullptr); - avl = gpr_avl_add(avl, box(504), box(1233), nullptr); - avl = remove_int(avl, 818); - avl = gpr_avl_add(avl, box(884), box(1235), nullptr); - avl = gpr_avl_add(avl, box(813), box(1236), nullptr); - avl = gpr_avl_add(avl, box(795), box(1237), nullptr); - avl = remove_int(avl, 306); - avl = gpr_avl_add(avl, box(799), box(1239), nullptr); - avl = remove_int(avl, 534); - avl = gpr_avl_add(avl, box(480), box(1241), nullptr); - avl = gpr_avl_add(avl, box(656), box(1242), nullptr); - avl = gpr_avl_add(avl, box(709), box(1243), nullptr); - avl = gpr_avl_add(avl, box(500), box(1244), nullptr); - avl = remove_int(avl, 740); - avl = gpr_avl_add(avl, box(980), box(1246), nullptr); - avl = gpr_avl_add(avl, box(458), box(1247), nullptr); - avl = remove_int(avl, 377); - avl = remove_int(avl, 338); - avl = gpr_avl_add(avl, box(554), box(1250), nullptr); - avl = gpr_avl_add(avl, box(504), box(1251), nullptr); - avl = gpr_avl_add(avl, box(603), box(1252), nullptr); - avl = gpr_avl_add(avl, box(761), box(1253), nullptr); - avl = remove_int(avl, 431); - avl = gpr_avl_add(avl, box(707), box(1255), nullptr); - avl = gpr_avl_add(avl, box(673), box(1256), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 332); - avl = remove_int(avl, 413); - avl = remove_int(avl, 227); - avl = remove_int(avl, 249); - avl = remove_int(avl, 309); - avl = remove_int(avl, 459); - avl = gpr_avl_add(avl, box(645), box(1264), nullptr); - avl = remove_int(avl, 858); - avl = remove_int(avl, 997); - avl = gpr_avl_add(avl, box(519), box(1267), nullptr); - avl = remove_int(avl, 614); - avl = remove_int(avl, 462); - avl = remove_int(avl, 792); - avl = gpr_avl_add(avl, box(987), box(1271), nullptr); - avl = gpr_avl_add(avl, box(309), box(1272), nullptr); - avl = remove_int(avl, 747); - avl = gpr_avl_add(avl, box(621), box(1274), nullptr); - avl = gpr_avl_add(avl, box(450), box(1275), nullptr); - avl = remove_int(avl, 265); - avl = remove_int(avl, 8); - avl = remove_int(avl, 383); - avl = gpr_avl_add(avl, box(238), box(1279), nullptr); - avl = remove_int(avl, 241); - avl = gpr_avl_add(avl, box(180), box(1281), nullptr); - avl = gpr_avl_add(avl, box(411), box(1282), nullptr); - avl = gpr_avl_add(avl, box(791), box(1283), nullptr); - avl = gpr_avl_add(avl, box(955), box(1284), nullptr); - avl = remove_int(avl, 24); - avl = remove_int(avl, 375); - avl = gpr_avl_add(avl, box(140), box(1287), nullptr); - avl = remove_int(avl, 949); - avl = gpr_avl_add(avl, box(301), box(1289), nullptr); - avl = gpr_avl_add(avl, box(0), box(1290), nullptr); - avl = remove_int(avl, 371); - avl = remove_int(avl, 427); - avl = remove_int(avl, 841); - avl = remove_int(avl, 847); - avl = gpr_avl_add(avl, box(814), box(1295), nullptr); - avl = gpr_avl_add(avl, box(127), box(1296), nullptr); - avl = gpr_avl_add(avl, box(279), box(1297), nullptr); - avl = remove_int(avl, 669); - avl = remove_int(avl, 541); - avl = remove_int(avl, 275); - avl = remove_int(avl, 299); - avl = remove_int(avl, 552); - avl = gpr_avl_add(avl, box(310), box(1303), nullptr); - avl = gpr_avl_add(avl, box(304), box(1304), nullptr); - avl = gpr_avl_add(avl, box(1), box(1305), nullptr); - avl = gpr_avl_add(avl, box(339), box(1306), nullptr); - avl = remove_int(avl, 570); - avl = remove_int(avl, 752); - avl = remove_int(avl, 552); - avl = remove_int(avl, 442); - avl = remove_int(avl, 639); - avl = gpr_avl_add(avl, box(313), box(1312), nullptr); - avl = remove_int(avl, 85); - avl = gpr_avl_add(avl, box(964), box(1314), nullptr); - avl = gpr_avl_add(avl, box(559), box(1315), nullptr); - avl = remove_int(avl, 167); - avl = gpr_avl_add(avl, box(866), box(1317), nullptr); - avl = remove_int(avl, 275); - avl = gpr_avl_add(avl, box(173), box(1319), nullptr); - avl = gpr_avl_add(avl, box(765), box(1320), nullptr); - avl = remove_int(avl, 883); - avl = gpr_avl_add(avl, box(547), box(1322), nullptr); - avl = gpr_avl_add(avl, box(847), box(1323), nullptr); - avl = remove_int(avl, 817); - avl = remove_int(avl, 850); - avl = remove_int(avl, 718); - avl = gpr_avl_add(avl, box(806), box(1327), nullptr); - avl = gpr_avl_add(avl, box(360), box(1328), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(493), box(1330), nullptr); - avl = remove_int(avl, 516); - avl = gpr_avl_add(avl, box(361), box(1332), nullptr); - avl = remove_int(avl, 355); - avl = gpr_avl_add(avl, box(512), box(1334), nullptr); - avl = gpr_avl_add(avl, box(191), box(1335), nullptr); - avl = remove_int(avl, 703); - avl = gpr_avl_add(avl, box(333), box(1337), nullptr); - avl = remove_int(avl, 481); - avl = gpr_avl_add(avl, box(501), box(1339), nullptr); - avl = remove_int(avl, 532); - avl = remove_int(avl, 510); - avl = gpr_avl_add(avl, box(793), box(1342), nullptr); - avl = gpr_avl_add(avl, box(234), box(1343), nullptr); - avl = remove_int(avl, 159); - avl = remove_int(avl, 429); - avl = remove_int(avl, 728); - avl = remove_int(avl, 288); - avl = gpr_avl_add(avl, box(281), box(1348), nullptr); - avl = gpr_avl_add(avl, box(702), box(1349), nullptr); - avl = gpr_avl_add(avl, box(149), box(1350), nullptr); - avl = remove_int(avl, 22); - avl = remove_int(avl, 944); - avl = remove_int(avl, 55); - avl = remove_int(avl, 512); - avl = remove_int(avl, 676); - avl = remove_int(avl, 884); - avl = gpr_avl_add(avl, box(246), box(1357), nullptr); - avl = gpr_avl_add(avl, box(455), box(1358), nullptr); - avl = remove_int(avl, 782); - avl = remove_int(avl, 682); - avl = gpr_avl_add(avl, box(243), box(1361), nullptr); - avl = gpr_avl_add(avl, box(109), box(1362), nullptr); - avl = gpr_avl_add(avl, box(452), box(1363), nullptr); - avl = remove_int(avl, 151); - avl = gpr_avl_add(avl, box(159), box(1365), nullptr); - avl = remove_int(avl, 1023); - avl = gpr_avl_add(avl, box(129), box(1367), nullptr); - avl = gpr_avl_add(avl, box(537), box(1368), nullptr); - avl = remove_int(avl, 321); - avl = gpr_avl_add(avl, box(740), box(1370), nullptr); - avl = remove_int(avl, 45); - avl = remove_int(avl, 136); - avl = gpr_avl_add(avl, box(229), box(1373), nullptr); - avl = remove_int(avl, 772); - avl = gpr_avl_add(avl, box(181), box(1375), nullptr); - avl = remove_int(avl, 175); - avl = gpr_avl_add(avl, box(817), box(1377), nullptr); - avl = remove_int(avl, 956); - avl = gpr_avl_add(avl, box(675), box(1379), nullptr); - avl = gpr_avl_add(avl, box(375), box(1380), nullptr); - avl = remove_int(avl, 384); - avl = gpr_avl_add(avl, box(1016), box(1382), nullptr); - avl = remove_int(avl, 295); - avl = remove_int(avl, 697); - avl = remove_int(avl, 554); - avl = remove_int(avl, 590); - avl = remove_int(avl, 1014); - avl = gpr_avl_add(avl, box(890), box(1388), nullptr); - avl = gpr_avl_add(avl, box(293), box(1389), nullptr); - avl = remove_int(avl, 207); - avl = remove_int(avl, 46); - avl = gpr_avl_add(avl, box(899), box(1392), nullptr); - avl = gpr_avl_add(avl, box(666), box(1393), nullptr); - avl = gpr_avl_add(avl, box(85), box(1394), nullptr); - avl = gpr_avl_add(avl, box(914), box(1395), nullptr); - avl = gpr_avl_add(avl, box(128), box(1396), nullptr); - avl = gpr_avl_add(avl, box(835), box(1397), nullptr); - avl = gpr_avl_add(avl, box(787), box(1398), nullptr); - avl = gpr_avl_add(avl, box(649), box(1399), nullptr); - avl = gpr_avl_add(avl, box(723), box(1400), nullptr); - avl = remove_int(avl, 874); - avl = gpr_avl_add(avl, box(778), box(1402), nullptr); - avl = gpr_avl_add(avl, box(1015), box(1403), nullptr); - avl = gpr_avl_add(avl, box(59), box(1404), nullptr); - avl = gpr_avl_add(avl, box(259), box(1405), nullptr); - avl = gpr_avl_add(avl, box(758), box(1406), nullptr); - avl = remove_int(avl, 648); - avl = gpr_avl_add(avl, box(145), box(1408), nullptr); - avl = gpr_avl_add(avl, box(440), box(1409), nullptr); - avl = remove_int(avl, 608); - avl = remove_int(avl, 690); - avl = gpr_avl_add(avl, box(605), box(1412), nullptr); - avl = remove_int(avl, 856); - avl = remove_int(avl, 608); - avl = gpr_avl_add(avl, box(829), box(1415), nullptr); - avl = gpr_avl_add(avl, box(660), box(1416), nullptr); - avl = remove_int(avl, 596); - avl = gpr_avl_add(avl, box(519), box(1418), nullptr); - avl = gpr_avl_add(avl, box(35), box(1419), nullptr); - avl = gpr_avl_add(avl, box(871), box(1420), nullptr); - avl = remove_int(avl, 845); - avl = gpr_avl_add(avl, box(600), box(1422), nullptr); - avl = gpr_avl_add(avl, box(215), box(1423), nullptr); - avl = remove_int(avl, 761); - avl = gpr_avl_add(avl, box(975), box(1425), nullptr); - avl = remove_int(avl, 987); - avl = gpr_avl_add(avl, box(58), box(1427), nullptr); - avl = remove_int(avl, 119); - avl = gpr_avl_add(avl, box(937), box(1429), nullptr); - avl = gpr_avl_add(avl, box(372), box(1430), nullptr); - avl = gpr_avl_add(avl, box(11), box(1431), nullptr); - avl = gpr_avl_add(avl, box(398), box(1432), nullptr); - avl = gpr_avl_add(avl, box(423), box(1433), nullptr); - avl = remove_int(avl, 171); - avl = gpr_avl_add(avl, box(473), box(1435), nullptr); - avl = remove_int(avl, 752); - avl = remove_int(avl, 625); - avl = remove_int(avl, 764); - avl = remove_int(avl, 49); - avl = gpr_avl_add(avl, box(472), box(1440), nullptr); - avl = remove_int(avl, 847); - avl = remove_int(avl, 642); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 795); - avl = remove_int(avl, 465); - avl = gpr_avl_add(avl, box(636), box(1446), nullptr); - avl = remove_int(avl, 152); - avl = gpr_avl_add(avl, box(61), box(1448), nullptr); - avl = remove_int(avl, 929); - avl = remove_int(avl, 9); - avl = gpr_avl_add(avl, box(251), box(1451), nullptr); - avl = gpr_avl_add(avl, box(672), box(1452), nullptr); - avl = gpr_avl_add(avl, box(66), box(1453), nullptr); - avl = remove_int(avl, 693); - avl = remove_int(avl, 914); - avl = remove_int(avl, 116); - avl = remove_int(avl, 577); - avl = gpr_avl_add(avl, box(618), box(1458), nullptr); - avl = gpr_avl_add(avl, box(495), box(1459), nullptr); - avl = remove_int(avl, 450); - avl = gpr_avl_add(avl, box(533), box(1461), nullptr); - avl = gpr_avl_add(avl, box(414), box(1462), nullptr); - avl = remove_int(avl, 74); - avl = remove_int(avl, 236); - avl = gpr_avl_add(avl, box(707), box(1465), nullptr); - avl = gpr_avl_add(avl, box(357), box(1466), nullptr); - avl = gpr_avl_add(avl, box(1007), box(1467), nullptr); - avl = gpr_avl_add(avl, box(811), box(1468), nullptr); - avl = gpr_avl_add(avl, box(418), box(1469), nullptr); - avl = gpr_avl_add(avl, box(164), box(1470), nullptr); - avl = gpr_avl_add(avl, box(622), box(1471), nullptr); - avl = remove_int(avl, 22); - avl = remove_int(avl, 14); - avl = remove_int(avl, 732); - avl = remove_int(avl, 7); - avl = remove_int(avl, 447); - avl = gpr_avl_add(avl, box(221), box(1477), nullptr); - avl = gpr_avl_add(avl, box(202), box(1478), nullptr); - avl = gpr_avl_add(avl, box(312), box(1479), nullptr); - avl = remove_int(avl, 274); - avl = gpr_avl_add(avl, box(684), box(1481), nullptr); - avl = gpr_avl_add(avl, box(954), box(1482), nullptr); - avl = gpr_avl_add(avl, box(637), box(1483), nullptr); - avl = remove_int(avl, 716); - avl = gpr_avl_add(avl, box(198), box(1485), nullptr); - avl = remove_int(avl, 340); - avl = remove_int(avl, 137); - avl = remove_int(avl, 995); - avl = remove_int(avl, 1004); - avl = gpr_avl_add(avl, box(661), box(1490), nullptr); - avl = gpr_avl_add(avl, box(862), box(1491), nullptr); - avl = remove_int(avl, 527); - avl = gpr_avl_add(avl, box(945), box(1493), nullptr); - avl = remove_int(avl, 355); - avl = remove_int(avl, 144); - avl = gpr_avl_add(avl, box(229), box(1496), nullptr); - avl = gpr_avl_add(avl, box(237), box(1497), nullptr); - avl = remove_int(avl, 471); - avl = remove_int(avl, 901); - avl = gpr_avl_add(avl, box(905), box(1500), nullptr); - avl = remove_int(avl, 19); - avl = remove_int(avl, 896); - avl = remove_int(avl, 585); - avl = remove_int(avl, 308); - avl = gpr_avl_add(avl, box(547), box(1505), nullptr); - avl = gpr_avl_add(avl, box(552), box(1506), nullptr); - avl = gpr_avl_add(avl, box(30), box(1507), nullptr); - avl = gpr_avl_add(avl, box(445), box(1508), nullptr); - avl = remove_int(avl, 785); - avl = remove_int(avl, 185); - avl = gpr_avl_add(avl, box(405), box(1511), nullptr); - avl = gpr_avl_add(avl, box(733), box(1512), nullptr); - avl = gpr_avl_add(avl, box(573), box(1513), nullptr); - avl = gpr_avl_add(avl, box(492), box(1514), nullptr); - avl = gpr_avl_add(avl, box(343), box(1515), nullptr); - avl = gpr_avl_add(avl, box(527), box(1516), nullptr); - avl = gpr_avl_add(avl, box(596), box(1517), nullptr); - avl = gpr_avl_add(avl, box(519), box(1518), nullptr); - avl = remove_int(avl, 243); - avl = remove_int(avl, 722); - avl = gpr_avl_add(avl, box(772), box(1521), nullptr); - avl = remove_int(avl, 152); - avl = remove_int(avl, 305); - avl = gpr_avl_add(avl, box(754), box(1524), nullptr); - avl = gpr_avl_add(avl, box(373), box(1525), nullptr); - avl = remove_int(avl, 995); - avl = gpr_avl_add(avl, box(329), box(1527), nullptr); - avl = remove_int(avl, 397); - avl = gpr_avl_add(avl, box(884), box(1529), nullptr); - avl = remove_int(avl, 329); - avl = remove_int(avl, 240); - avl = gpr_avl_add(avl, box(566), box(1532), nullptr); - avl = gpr_avl_add(avl, box(232), box(1533), nullptr); - avl = remove_int(avl, 993); - avl = gpr_avl_add(avl, box(888), box(1535), nullptr); - avl = remove_int(avl, 242); - avl = gpr_avl_add(avl, box(941), box(1537), nullptr); - avl = remove_int(avl, 415); - avl = gpr_avl_add(avl, box(992), box(1539), nullptr); - avl = remove_int(avl, 289); - avl = gpr_avl_add(avl, box(60), box(1541), nullptr); - avl = gpr_avl_add(avl, box(97), box(1542), nullptr); - avl = remove_int(avl, 965); - avl = remove_int(avl, 267); - avl = remove_int(avl, 360); - avl = gpr_avl_add(avl, box(5), box(1546), nullptr); - avl = remove_int(avl, 429); - avl = gpr_avl_add(avl, box(412), box(1548), nullptr); - avl = remove_int(avl, 632); - avl = remove_int(avl, 113); - avl = gpr_avl_add(avl, box(48), box(1551), nullptr); - avl = gpr_avl_add(avl, box(108), box(1552), nullptr); - avl = gpr_avl_add(avl, box(750), box(1553), nullptr); - avl = remove_int(avl, 188); - avl = gpr_avl_add(avl, box(668), box(1555), nullptr); - avl = remove_int(avl, 37); - avl = remove_int(avl, 737); - avl = gpr_avl_add(avl, box(93), box(1558), nullptr); - avl = gpr_avl_add(avl, box(628), box(1559), nullptr); - avl = gpr_avl_add(avl, box(480), box(1560), nullptr); - avl = remove_int(avl, 958); - avl = remove_int(avl, 565); - avl = remove_int(avl, 32); - avl = remove_int(avl, 1); - avl = remove_int(avl, 335); - avl = gpr_avl_add(avl, box(136), box(1566), nullptr); - avl = gpr_avl_add(avl, box(469), box(1567), nullptr); - avl = remove_int(avl, 349); - avl = gpr_avl_add(avl, box(768), box(1569), nullptr); - avl = gpr_avl_add(avl, box(915), box(1570), nullptr); - avl = remove_int(avl, 1014); - avl = gpr_avl_add(avl, box(117), box(1572), nullptr); - avl = remove_int(avl, 62); - avl = gpr_avl_add(avl, box(382), box(1574), nullptr); - avl = remove_int(avl, 571); - avl = gpr_avl_add(avl, box(655), box(1576), nullptr); - avl = gpr_avl_add(avl, box(323), box(1577), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 151); - avl = gpr_avl_add(avl, box(1019), box(1580), nullptr); - avl = gpr_avl_add(avl, box(984), box(1581), nullptr); - avl = gpr_avl_add(avl, box(870), box(1582), nullptr); - avl = gpr_avl_add(avl, box(376), box(1583), nullptr); - avl = remove_int(avl, 625); - avl = gpr_avl_add(avl, box(733), box(1585), nullptr); - avl = remove_int(avl, 532); - avl = remove_int(avl, 444); - avl = gpr_avl_add(avl, box(428), box(1588), nullptr); - avl = gpr_avl_add(avl, box(860), box(1589), nullptr); - avl = gpr_avl_add(avl, box(173), box(1590), nullptr); - avl = remove_int(avl, 649); - avl = remove_int(avl, 913); - avl = remove_int(avl, 1); - avl = remove_int(avl, 304); - avl = gpr_avl_add(avl, box(604), box(1595), nullptr); - avl = gpr_avl_add(avl, box(639), box(1596), nullptr); - avl = remove_int(avl, 431); - avl = gpr_avl_add(avl, box(993), box(1598), nullptr); - avl = remove_int(avl, 681); - avl = remove_int(avl, 927); - avl = gpr_avl_add(avl, box(87), box(1601), nullptr); - avl = gpr_avl_add(avl, box(91), box(1602), nullptr); - avl = remove_int(avl, 61); - avl = remove_int(avl, 14); - avl = remove_int(avl, 305); - avl = remove_int(avl, 304); - avl = remove_int(avl, 1016); - avl = gpr_avl_add(avl, box(903), box(1608), nullptr); - avl = gpr_avl_add(avl, box(951), box(1609), nullptr); - avl = gpr_avl_add(avl, box(146), box(1610), nullptr); - avl = gpr_avl_add(avl, box(482), box(1611), nullptr); - avl = gpr_avl_add(avl, box(71), box(1612), nullptr); - avl = remove_int(avl, 246); - avl = remove_int(avl, 696); - avl = gpr_avl_add(avl, box(636), box(1615), nullptr); - avl = gpr_avl_add(avl, box(295), box(1616), nullptr); - avl = remove_int(avl, 11); - avl = remove_int(avl, 231); - avl = gpr_avl_add(avl, box(905), box(1619), nullptr); - avl = gpr_avl_add(avl, box(993), box(1620), nullptr); - avl = gpr_avl_add(avl, box(433), box(1621), nullptr); - avl = gpr_avl_add(avl, box(117), box(1622), nullptr); - avl = gpr_avl_add(avl, box(467), box(1623), nullptr); - avl = remove_int(avl, 419); - avl = gpr_avl_add(avl, box(179), box(1625), nullptr); - avl = remove_int(avl, 926); - avl = remove_int(avl, 326); - avl = gpr_avl_add(avl, box(551), box(1628), nullptr); - avl = remove_int(avl, 14); - avl = remove_int(avl, 476); - avl = remove_int(avl, 823); - avl = gpr_avl_add(avl, box(350), box(1632), nullptr); - avl = gpr_avl_add(avl, box(133), box(1633), nullptr); - avl = remove_int(avl, 906); - avl = gpr_avl_add(avl, box(827), box(1635), nullptr); - avl = gpr_avl_add(avl, box(201), box(1636), nullptr); - avl = remove_int(avl, 124); - avl = remove_int(avl, 662); - avl = gpr_avl_add(avl, box(314), box(1639), nullptr); - avl = gpr_avl_add(avl, box(986), box(1640), nullptr); - avl = gpr_avl_add(avl, box(622), box(1641), nullptr); - avl = remove_int(avl, 130); - avl = gpr_avl_add(avl, box(861), box(1643), nullptr); - avl = remove_int(avl, 497); - avl = remove_int(avl, 905); - avl = gpr_avl_add(avl, box(502), box(1646), nullptr); - avl = remove_int(avl, 721); - avl = gpr_avl_add(avl, box(514), box(1648), nullptr); - avl = gpr_avl_add(avl, box(410), box(1649), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 247); - avl = gpr_avl_add(avl, box(450), box(1652), nullptr); - avl = remove_int(avl, 364); - avl = gpr_avl_add(avl, box(963), box(1654), nullptr); - avl = gpr_avl_add(avl, box(146), box(1655), nullptr); - avl = remove_int(avl, 147); - avl = remove_int(avl, 789); - avl = gpr_avl_add(avl, box(693), box(1658), nullptr); - avl = gpr_avl_add(avl, box(959), box(1659), nullptr); - avl = remove_int(avl, 478); - avl = gpr_avl_add(avl, box(116), box(1661), nullptr); - avl = gpr_avl_add(avl, box(520), box(1662), nullptr); - avl = gpr_avl_add(avl, box(809), box(1663), nullptr); - avl = gpr_avl_add(avl, box(667), box(1664), nullptr); - avl = gpr_avl_add(avl, box(406), box(1665), nullptr); - avl = remove_int(avl, 409); - avl = gpr_avl_add(avl, box(558), box(1667), nullptr); - avl = gpr_avl_add(avl, box(0), box(1668), nullptr); - avl = gpr_avl_add(avl, box(948), box(1669), nullptr); - avl = gpr_avl_add(avl, box(576), box(1670), nullptr); - avl = remove_int(avl, 864); - avl = remove_int(avl, 840); - avl = remove_int(avl, 1001); - avl = gpr_avl_add(avl, box(232), box(1674), nullptr); - avl = remove_int(avl, 676); - avl = remove_int(avl, 752); - avl = remove_int(avl, 667); - avl = remove_int(avl, 605); - avl = gpr_avl_add(avl, box(258), box(1679), nullptr); - avl = gpr_avl_add(avl, box(648), box(1680), nullptr); - avl = gpr_avl_add(avl, box(761), box(1681), nullptr); - avl = remove_int(avl, 293); - avl = remove_int(avl, 893); - avl = gpr_avl_add(avl, box(194), box(1684), nullptr); - avl = remove_int(avl, 233); - avl = gpr_avl_add(avl, box(888), box(1686), nullptr); - avl = remove_int(avl, 470); - avl = remove_int(avl, 703); - avl = remove_int(avl, 190); - avl = remove_int(avl, 359); - avl = gpr_avl_add(avl, box(621), box(1691), nullptr); - avl = remove_int(avl, 634); - avl = remove_int(avl, 335); - avl = gpr_avl_add(avl, box(718), box(1694), nullptr); - avl = gpr_avl_add(avl, box(463), box(1695), nullptr); - avl = gpr_avl_add(avl, box(233), box(1696), nullptr); - avl = remove_int(avl, 376); - avl = remove_int(avl, 496); - avl = remove_int(avl, 819); - avl = remove_int(avl, 38); - avl = remove_int(avl, 436); - avl = remove_int(avl, 102); - avl = gpr_avl_add(avl, box(607), box(1703), nullptr); - avl = remove_int(avl, 329); - avl = gpr_avl_add(avl, box(716), box(1705), nullptr); - avl = remove_int(avl, 639); - avl = remove_int(avl, 775); - avl = remove_int(avl, 578); - avl = remove_int(avl, 464); - avl = remove_int(avl, 679); - avl = remove_int(avl, 615); - avl = remove_int(avl, 104); - avl = gpr_avl_add(avl, box(414), box(1713), nullptr); - avl = gpr_avl_add(avl, box(212), box(1714), nullptr); - avl = gpr_avl_add(avl, box(266), box(1715), nullptr); - avl = gpr_avl_add(avl, box(238), box(1716), nullptr); - avl = remove_int(avl, 153); - avl = gpr_avl_add(avl, box(585), box(1718), nullptr); - avl = remove_int(avl, 121); - avl = gpr_avl_add(avl, box(534), box(1720), nullptr); - avl = remove_int(avl, 579); - avl = gpr_avl_add(avl, box(127), box(1722), nullptr); - avl = gpr_avl_add(avl, box(399), box(1723), nullptr); - avl = remove_int(avl, 417); - avl = gpr_avl_add(avl, box(978), box(1725), nullptr); - avl = gpr_avl_add(avl, box(768), box(1726), nullptr); - avl = remove_int(avl, 985); - avl = gpr_avl_add(avl, box(536), box(1728), nullptr); - avl = gpr_avl_add(avl, box(449), box(1729), nullptr); - avl = gpr_avl_add(avl, box(586), box(1730), nullptr); - avl = remove_int(avl, 998); - avl = remove_int(avl, 394); - avl = remove_int(avl, 141); - avl = gpr_avl_add(avl, box(889), box(1734), nullptr); - avl = gpr_avl_add(avl, box(871), box(1735), nullptr); - avl = gpr_avl_add(avl, box(76), box(1736), nullptr); - avl = gpr_avl_add(avl, box(549), box(1737), nullptr); - avl = gpr_avl_add(avl, box(757), box(1738), nullptr); - avl = remove_int(avl, 908); - avl = gpr_avl_add(avl, box(789), box(1740), nullptr); - avl = remove_int(avl, 224); - avl = gpr_avl_add(avl, box(407), box(1742), nullptr); - avl = gpr_avl_add(avl, box(381), box(1743), nullptr); - avl = gpr_avl_add(avl, box(561), box(1744), nullptr); - avl = gpr_avl_add(avl, box(667), box(1745), nullptr); - avl = gpr_avl_add(avl, box(522), box(1746), nullptr); - avl = gpr_avl_add(avl, box(948), box(1747), nullptr); - avl = remove_int(avl, 770); - avl = gpr_avl_add(avl, box(872), box(1749), nullptr); - avl = gpr_avl_add(avl, box(327), box(1750), nullptr); - avl = remove_int(avl, 10); - avl = gpr_avl_add(avl, box(122), box(1752), nullptr); - avl = remove_int(avl, 606); - avl = gpr_avl_add(avl, box(485), box(1754), nullptr); - avl = remove_int(avl, 6); - avl = gpr_avl_add(avl, box(329), box(1756), nullptr); - avl = gpr_avl_add(avl, box(783), box(1757), nullptr); - avl = remove_int(avl, 416); - avl = gpr_avl_add(avl, box(656), box(1759), nullptr); - avl = gpr_avl_add(avl, box(971), box(1760), nullptr); - avl = gpr_avl_add(avl, box(77), box(1761), nullptr); - avl = gpr_avl_add(avl, box(942), box(1762), nullptr); - avl = remove_int(avl, 361); - avl = gpr_avl_add(avl, box(66), box(1764), nullptr); - avl = gpr_avl_add(avl, box(299), box(1765), nullptr); - avl = gpr_avl_add(avl, box(929), box(1766), nullptr); - avl = gpr_avl_add(avl, box(797), box(1767), nullptr); - avl = remove_int(avl, 869); - avl = remove_int(avl, 907); - avl = gpr_avl_add(avl, box(870), box(1770), nullptr); - avl = remove_int(avl, 580); - avl = remove_int(avl, 120); - avl = gpr_avl_add(avl, box(913), box(1773), nullptr); - avl = remove_int(avl, 480); - avl = gpr_avl_add(avl, box(489), box(1775), nullptr); - avl = remove_int(avl, 845); - avl = gpr_avl_add(avl, box(896), box(1777), nullptr); - avl = remove_int(avl, 567); - avl = remove_int(avl, 427); - avl = gpr_avl_add(avl, box(443), box(1780), nullptr); - avl = gpr_avl_add(avl, box(3), box(1781), nullptr); - avl = remove_int(avl, 12); - avl = gpr_avl_add(avl, box(376), box(1783), nullptr); - avl = gpr_avl_add(avl, box(155), box(1784), nullptr); - avl = gpr_avl_add(avl, box(188), box(1785), nullptr); - avl = gpr_avl_add(avl, box(149), box(1786), nullptr); - avl = gpr_avl_add(avl, box(178), box(1787), nullptr); - avl = remove_int(avl, 84); - avl = gpr_avl_add(avl, box(805), box(1789), nullptr); - avl = gpr_avl_add(avl, box(612), box(1790), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(837), box(1792), nullptr); - avl = remove_int(avl, 173); - avl = remove_int(avl, 72); - avl = gpr_avl_add(avl, box(1014), box(1795), nullptr); - avl = remove_int(avl, 303); - avl = gpr_avl_add(avl, box(865), box(1797), nullptr); - avl = gpr_avl_add(avl, box(793), box(1798), nullptr); - avl = remove_int(avl, 173); - avl = remove_int(avl, 477); - avl = gpr_avl_add(avl, box(950), box(1801), nullptr); - avl = gpr_avl_add(avl, box(105), box(1802), nullptr); - avl = gpr_avl_add(avl, box(895), box(1803), nullptr); - avl = gpr_avl_add(avl, box(171), box(1804), nullptr); - avl = gpr_avl_add(avl, box(753), box(1805), nullptr); - avl = gpr_avl_add(avl, box(946), box(1806), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 559); - avl = remove_int(avl, 116); - avl = gpr_avl_add(avl, box(968), box(1810), nullptr); - avl = remove_int(avl, 124); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(563), box(1813), nullptr); - avl = remove_int(avl, 182); - avl = gpr_avl_add(avl, box(816), box(1815), nullptr); - avl = remove_int(avl, 73); - avl = remove_int(avl, 261); - avl = gpr_avl_add(avl, box(847), box(1818), nullptr); - avl = gpr_avl_add(avl, box(368), box(1819), nullptr); - avl = gpr_avl_add(avl, box(808), box(1820), nullptr); - avl = gpr_avl_add(avl, box(779), box(1821), nullptr); - avl = remove_int(avl, 818); - avl = gpr_avl_add(avl, box(466), box(1823), nullptr); - avl = remove_int(avl, 316); - avl = gpr_avl_add(avl, box(986), box(1825), nullptr); - avl = gpr_avl_add(avl, box(688), box(1826), nullptr); - avl = gpr_avl_add(avl, box(509), box(1827), nullptr); - avl = gpr_avl_add(avl, box(51), box(1828), nullptr); - avl = remove_int(avl, 655); - avl = remove_int(avl, 785); - avl = remove_int(avl, 893); - avl = gpr_avl_add(avl, box(167), box(1832), nullptr); - avl = remove_int(avl, 13); - avl = remove_int(avl, 263); - avl = gpr_avl_add(avl, box(1009), box(1835), nullptr); - avl = remove_int(avl, 480); - avl = remove_int(avl, 778); - avl = remove_int(avl, 713); - avl = remove_int(avl, 628); - avl = gpr_avl_add(avl, box(803), box(1840), nullptr); - avl = remove_int(avl, 267); - avl = gpr_avl_add(avl, box(676), box(1842), nullptr); - avl = gpr_avl_add(avl, box(231), box(1843), nullptr); - avl = gpr_avl_add(avl, box(824), box(1844), nullptr); - avl = remove_int(avl, 961); - avl = gpr_avl_add(avl, box(311), box(1846), nullptr); - avl = gpr_avl_add(avl, box(420), box(1847), nullptr); - avl = gpr_avl_add(avl, box(960), box(1848), nullptr); - avl = gpr_avl_add(avl, box(468), box(1849), nullptr); - avl = gpr_avl_add(avl, box(815), box(1850), nullptr); - avl = remove_int(avl, 247); - avl = remove_int(avl, 194); - avl = gpr_avl_add(avl, box(546), box(1853), nullptr); - avl = remove_int(avl, 222); - avl = remove_int(avl, 914); - avl = remove_int(avl, 741); - avl = gpr_avl_add(avl, box(470), box(1857), nullptr); - avl = gpr_avl_add(avl, box(933), box(1858), nullptr); - avl = gpr_avl_add(avl, box(97), box(1859), nullptr); - avl = remove_int(avl, 564); - avl = remove_int(avl, 295); - avl = gpr_avl_add(avl, box(864), box(1862), nullptr); - avl = remove_int(avl, 329); - avl = gpr_avl_add(avl, box(124), box(1864), nullptr); - avl = gpr_avl_add(avl, box(1000), box(1865), nullptr); - avl = gpr_avl_add(avl, box(228), box(1866), nullptr); - avl = gpr_avl_add(avl, box(187), box(1867), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 306); - avl = remove_int(avl, 884); - avl = gpr_avl_add(avl, box(449), box(1871), nullptr); - avl = gpr_avl_add(avl, box(353), box(1872), nullptr); - avl = gpr_avl_add(avl, box(994), box(1873), nullptr); - avl = gpr_avl_add(avl, box(596), box(1874), nullptr); - avl = gpr_avl_add(avl, box(996), box(1875), nullptr); - avl = gpr_avl_add(avl, box(101), box(1876), nullptr); - avl = gpr_avl_add(avl, box(1012), box(1877), nullptr); - avl = gpr_avl_add(avl, box(982), box(1878), nullptr); - avl = gpr_avl_add(avl, box(742), box(1879), nullptr); - avl = remove_int(avl, 92); - avl = remove_int(avl, 1022); - avl = gpr_avl_add(avl, box(941), box(1882), nullptr); - avl = remove_int(avl, 742); - avl = remove_int(avl, 919); - avl = gpr_avl_add(avl, box(588), box(1885), nullptr); - avl = remove_int(avl, 221); - avl = gpr_avl_add(avl, box(356), box(1887), nullptr); - avl = gpr_avl_add(avl, box(932), box(1888), nullptr); - avl = remove_int(avl, 837); - avl = gpr_avl_add(avl, box(394), box(1890), nullptr); - avl = gpr_avl_add(avl, box(642), box(1891), nullptr); - avl = gpr_avl_add(avl, box(52), box(1892), nullptr); - avl = gpr_avl_add(avl, box(437), box(1893), nullptr); - avl = gpr_avl_add(avl, box(948), box(1894), nullptr); - avl = gpr_avl_add(avl, box(93), box(1895), nullptr); - avl = remove_int(avl, 873); - avl = remove_int(avl, 336); - avl = remove_int(avl, 277); - avl = remove_int(avl, 932); - avl = gpr_avl_add(avl, box(80), box(1900), nullptr); - avl = gpr_avl_add(avl, box(952), box(1901), nullptr); - avl = gpr_avl_add(avl, box(510), box(1902), nullptr); - avl = remove_int(avl, 876); - avl = remove_int(avl, 612); - avl = gpr_avl_add(avl, box(923), box(1905), nullptr); - avl = gpr_avl_add(avl, box(475), box(1906), nullptr); - avl = remove_int(avl, 478); - avl = remove_int(avl, 148); - avl = gpr_avl_add(avl, box(538), box(1909), nullptr); - avl = remove_int(avl, 47); - avl = gpr_avl_add(avl, box(89), box(1911), nullptr); - avl = remove_int(avl, 723); - avl = gpr_avl_add(avl, box(687), box(1913), nullptr); - avl = gpr_avl_add(avl, box(480), box(1914), nullptr); - avl = gpr_avl_add(avl, box(149), box(1915), nullptr); - avl = remove_int(avl, 68); - avl = remove_int(avl, 862); - avl = remove_int(avl, 363); - avl = gpr_avl_add(avl, box(996), box(1919), nullptr); - avl = remove_int(avl, 380); - avl = gpr_avl_add(avl, box(957), box(1921), nullptr); - avl = remove_int(avl, 413); - avl = gpr_avl_add(avl, box(360), box(1923), nullptr); - avl = gpr_avl_add(avl, box(304), box(1924), nullptr); - avl = gpr_avl_add(avl, box(634), box(1925), nullptr); - avl = gpr_avl_add(avl, box(506), box(1926), nullptr); - avl = remove_int(avl, 248); - avl = gpr_avl_add(avl, box(124), box(1928), nullptr); - avl = gpr_avl_add(avl, box(181), box(1929), nullptr); - avl = remove_int(avl, 507); - avl = gpr_avl_add(avl, box(141), box(1931), nullptr); - avl = remove_int(avl, 409); - avl = remove_int(avl, 129); - avl = remove_int(avl, 694); - avl = remove_int(avl, 723); - avl = gpr_avl_add(avl, box(998), box(1936), nullptr); - avl = gpr_avl_add(avl, box(906), box(1937), nullptr); - avl = gpr_avl_add(avl, box(44), box(1938), nullptr); - avl = remove_int(avl, 949); - avl = remove_int(avl, 117); - avl = gpr_avl_add(avl, box(700), box(1941), nullptr); - avl = gpr_avl_add(avl, box(258), box(1942), nullptr); - avl = remove_int(avl, 828); - avl = gpr_avl_add(avl, box(860), box(1944), nullptr); - avl = gpr_avl_add(avl, box(987), box(1945), nullptr); - avl = gpr_avl_add(avl, box(316), box(1946), nullptr); - avl = gpr_avl_add(avl, box(919), box(1947), nullptr); - avl = remove_int(avl, 84); - avl = gpr_avl_add(avl, box(473), box(1949), nullptr); - avl = remove_int(avl, 127); - avl = remove_int(avl, 829); - avl = remove_int(avl, 829); - avl = gpr_avl_add(avl, box(488), box(1953), nullptr); - avl = gpr_avl_add(avl, box(954), box(1954), nullptr); - avl = remove_int(avl, 198); - avl = remove_int(avl, 972); - avl = remove_int(avl, 670); - avl = gpr_avl_add(avl, box(822), box(1958), nullptr); - avl = remove_int(avl, 589); - avl = remove_int(avl, 459); - avl = gpr_avl_add(avl, box(1003), box(1961), nullptr); - avl = gpr_avl_add(avl, box(657), box(1962), nullptr); - avl = gpr_avl_add(avl, box(477), box(1963), nullptr); - avl = gpr_avl_add(avl, box(923), box(1964), nullptr); - avl = remove_int(avl, 496); - avl = remove_int(avl, 99); - avl = gpr_avl_add(avl, box(127), box(1967), nullptr); - avl = gpr_avl_add(avl, box(1013), box(1968), nullptr); - avl = gpr_avl_add(avl, box(778), box(1969), nullptr); - avl = remove_int(avl, 5); - avl = remove_int(avl, 990); - avl = remove_int(avl, 850); - avl = remove_int(avl, 160); - avl = remove_int(avl, 86); - avl = gpr_avl_add(avl, box(283), box(1975), nullptr); - avl = remove_int(avl, 278); - avl = remove_int(avl, 297); - avl = remove_int(avl, 137); - avl = remove_int(avl, 653); - avl = gpr_avl_add(avl, box(702), box(1980), nullptr); - avl = remove_int(avl, 63); - avl = remove_int(avl, 427); - avl = remove_int(avl, 706); - avl = remove_int(avl, 806); - avl = gpr_avl_add(avl, box(335), box(1985), nullptr); - avl = gpr_avl_add(avl, box(412), box(1986), nullptr); - avl = remove_int(avl, 766); - avl = remove_int(avl, 937); - avl = remove_int(avl, 886); - avl = remove_int(avl, 652); - avl = gpr_avl_add(avl, box(545), box(1991), nullptr); - avl = gpr_avl_add(avl, box(408), box(1992), nullptr); - avl = gpr_avl_add(avl, box(841), box(1993), nullptr); - avl = remove_int(avl, 593); - avl = gpr_avl_add(avl, box(582), box(1995), nullptr); - avl = gpr_avl_add(avl, box(597), box(1996), nullptr); - avl = remove_int(avl, 49); - avl = remove_int(avl, 835); - avl = gpr_avl_add(avl, box(417), box(1999), nullptr); - avl = gpr_avl_add(avl, box(191), box(2000), nullptr); - avl = remove_int(avl, 406); - avl = gpr_avl_add(avl, box(30), box(2002), nullptr); - avl = remove_int(avl, 841); - avl = remove_int(avl, 50); - avl = gpr_avl_add(avl, box(967), box(2005), nullptr); - avl = gpr_avl_add(avl, box(849), box(2006), nullptr); - avl = remove_int(avl, 608); - avl = gpr_avl_add(avl, box(306), box(2008), nullptr); - avl = remove_int(avl, 779); - avl = gpr_avl_add(avl, box(897), box(2010), nullptr); - avl = gpr_avl_add(avl, box(147), box(2011), nullptr); - avl = remove_int(avl, 982); - avl = gpr_avl_add(avl, box(470), box(2013), nullptr); - avl = remove_int(avl, 951); - avl = gpr_avl_add(avl, box(388), box(2015), nullptr); - avl = remove_int(avl, 616); - avl = remove_int(avl, 721); - avl = remove_int(avl, 942); - avl = remove_int(avl, 589); - avl = gpr_avl_add(avl, box(218), box(2020), nullptr); - avl = remove_int(avl, 671); - avl = gpr_avl_add(avl, box(1020), box(2022), nullptr); - avl = remove_int(avl, 277); - avl = gpr_avl_add(avl, box(681), box(2024), nullptr); - avl = gpr_avl_add(avl, box(179), box(2025), nullptr); - avl = gpr_avl_add(avl, box(370), box(2026), nullptr); - avl = gpr_avl_add(avl, box(0), box(2027), nullptr); - avl = remove_int(avl, 523); - avl = gpr_avl_add(avl, box(99), box(2029), nullptr); - avl = gpr_avl_add(avl, box(334), box(2030), nullptr); - avl = gpr_avl_add(avl, box(569), box(2031), nullptr); - avl = gpr_avl_add(avl, box(257), box(2032), nullptr); - avl = remove_int(avl, 572); - avl = gpr_avl_add(avl, box(805), box(2034), nullptr); - avl = gpr_avl_add(avl, box(143), box(2035), nullptr); - avl = gpr_avl_add(avl, box(670), box(2036), nullptr); - avl = remove_int(avl, 42); - avl = gpr_avl_add(avl, box(46), box(2038), nullptr); - avl = remove_int(avl, 970); - avl = gpr_avl_add(avl, box(353), box(2040), nullptr); - avl = remove_int(avl, 258); - avl = gpr_avl_add(avl, box(451), box(2042), nullptr); - avl = gpr_avl_add(avl, box(28), box(2043), nullptr); - avl = gpr_avl_add(avl, box(729), box(2044), nullptr); - avl = gpr_avl_add(avl, box(401), box(2045), nullptr); - avl = gpr_avl_add(avl, box(614), box(2046), nullptr); - avl = remove_int(avl, 990); - avl = remove_int(avl, 212); - avl = remove_int(avl, 22); - avl = remove_int(avl, 677); - avl = gpr_avl_add(avl, box(1016), box(2051), nullptr); - avl = gpr_avl_add(avl, box(980), box(2052), nullptr); - avl = gpr_avl_add(avl, box(990), box(2053), nullptr); - avl = gpr_avl_add(avl, box(355), box(2054), nullptr); - avl = remove_int(avl, 730); - avl = remove_int(avl, 37); - avl = gpr_avl_add(avl, box(407), box(2057), nullptr); - avl = gpr_avl_add(avl, box(222), box(2058), nullptr); - avl = gpr_avl_add(avl, box(439), box(2059), nullptr); - avl = gpr_avl_add(avl, box(563), box(2060), nullptr); - avl = remove_int(avl, 992); - avl = remove_int(avl, 786); - avl = gpr_avl_add(avl, box(1), box(2063), nullptr); - avl = gpr_avl_add(avl, box(473), box(2064), nullptr); - avl = gpr_avl_add(avl, box(992), box(2065), nullptr); - avl = remove_int(avl, 190); - avl = remove_int(avl, 450); - avl = remove_int(avl, 1020); - avl = remove_int(avl, 149); - avl = gpr_avl_add(avl, box(329), box(2070), nullptr); - avl = gpr_avl_add(avl, box(35), box(2071), nullptr); - avl = remove_int(avl, 843); - avl = gpr_avl_add(avl, box(855), box(2073), nullptr); - avl = remove_int(avl, 878); - avl = gpr_avl_add(avl, box(993), box(2075), nullptr); - avl = gpr_avl_add(avl, box(87), box(2076), nullptr); - avl = gpr_avl_add(avl, box(572), box(2077), nullptr); - avl = remove_int(avl, 896); - avl = gpr_avl_add(avl, box(849), box(2079), nullptr); - avl = remove_int(avl, 597); - avl = gpr_avl_add(avl, box(472), box(2081), nullptr); - avl = remove_int(avl, 778); - avl = remove_int(avl, 934); - avl = remove_int(avl, 314); - avl = gpr_avl_add(avl, box(101), box(2085), nullptr); - avl = remove_int(avl, 938); - avl = remove_int(avl, 1010); - avl = gpr_avl_add(avl, box(579), box(2088), nullptr); - avl = remove_int(avl, 798); - avl = remove_int(avl, 88); - avl = gpr_avl_add(avl, box(851), box(2091), nullptr); - avl = remove_int(avl, 705); - avl = gpr_avl_add(avl, box(26), box(2093), nullptr); - avl = remove_int(avl, 973); - avl = gpr_avl_add(avl, box(923), box(2095), nullptr); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(310), box(2097), nullptr); - avl = gpr_avl_add(avl, box(269), box(2098), nullptr); - avl = remove_int(avl, 173); - avl = gpr_avl_add(avl, box(279), box(2100), nullptr); - avl = remove_int(avl, 203); - avl = gpr_avl_add(avl, box(411), box(2102), nullptr); - avl = remove_int(avl, 950); - avl = gpr_avl_add(avl, box(6), box(2104), nullptr); - avl = remove_int(avl, 400); - avl = remove_int(avl, 468); - avl = remove_int(avl, 271); - avl = gpr_avl_add(avl, box(627), box(2108), nullptr); - avl = remove_int(avl, 727); - avl = remove_int(avl, 148); - avl = remove_int(avl, 98); - avl = remove_int(avl, 997); - avl = remove_int(avl, 215); - avl = remove_int(avl, 628); - avl = remove_int(avl, 826); - avl = remove_int(avl, 664); - avl = gpr_avl_add(avl, box(76), box(2117), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 18); - avl = gpr_avl_add(avl, box(727), box(2120), nullptr); - avl = remove_int(avl, 295); - avl = gpr_avl_add(avl, box(645), box(2122), nullptr); - avl = remove_int(avl, 321); - avl = remove_int(avl, 863); - avl = gpr_avl_add(avl, box(824), box(2125), nullptr); - avl = gpr_avl_add(avl, box(651), box(2126), nullptr); - avl = gpr_avl_add(avl, box(804), box(2127), nullptr); - avl = remove_int(avl, 307); - avl = gpr_avl_add(avl, box(867), box(2129), nullptr); - avl = remove_int(avl, 384); - avl = gpr_avl_add(avl, box(819), box(2131), nullptr); - avl = remove_int(avl, 674); - avl = gpr_avl_add(avl, box(76), box(2133), nullptr); - avl = remove_int(avl, 898); - avl = gpr_avl_add(avl, box(45), box(2135), nullptr); - avl = gpr_avl_add(avl, box(512), box(2136), nullptr); - avl = remove_int(avl, 773); - avl = remove_int(avl, 907); - avl = remove_int(avl, 382); - avl = remove_int(avl, 95); - avl = remove_int(avl, 734); - avl = remove_int(avl, 81); - avl = gpr_avl_add(avl, box(348), box(2143), nullptr); - avl = remove_int(avl, 509); - avl = remove_int(avl, 301); - avl = gpr_avl_add(avl, box(861), box(2146), nullptr); - avl = gpr_avl_add(avl, box(918), box(2147), nullptr); - avl = remove_int(avl, 992); - avl = gpr_avl_add(avl, box(356), box(2149), nullptr); - avl = remove_int(avl, 64); - avl = remove_int(avl, 444); - avl = remove_int(avl, 741); - avl = gpr_avl_add(avl, box(710), box(2153), nullptr); - avl = gpr_avl_add(avl, box(264), box(2154), nullptr); - avl = remove_int(avl, 347); - avl = remove_int(avl, 250); - avl = gpr_avl_add(avl, box(82), box(2157), nullptr); - avl = gpr_avl_add(avl, box(571), box(2158), nullptr); - avl = remove_int(avl, 721); - avl = remove_int(avl, 622); - avl = gpr_avl_add(avl, box(950), box(2161), nullptr); - avl = gpr_avl_add(avl, box(94), box(2162), nullptr); - avl = remove_int(avl, 970); - avl = gpr_avl_add(avl, box(815), box(2164), nullptr); - avl = remove_int(avl, 930); - avl = remove_int(avl, 703); - avl = gpr_avl_add(avl, box(432), box(2167), nullptr); - avl = remove_int(avl, 544); - avl = gpr_avl_add(avl, box(21), box(2169), nullptr); - avl = gpr_avl_add(avl, box(186), box(2170), nullptr); - avl = remove_int(avl, 143); - avl = gpr_avl_add(avl, box(425), box(2172), nullptr); - avl = remove_int(avl, 769); - avl = gpr_avl_add(avl, box(656), box(2174), nullptr); - avl = remove_int(avl, 29); - avl = gpr_avl_add(avl, box(464), box(2176), nullptr); - avl = remove_int(avl, 713); - avl = gpr_avl_add(avl, box(800), box(2178), nullptr); - avl = remove_int(avl, 621); - avl = gpr_avl_add(avl, box(962), box(2180), nullptr); - avl = remove_int(avl, 448); - avl = gpr_avl_add(avl, box(878), box(2182), nullptr); - avl = remove_int(avl, 39); - avl = remove_int(avl, 999); - avl = gpr_avl_add(avl, box(182), box(2185), nullptr); - avl = gpr_avl_add(avl, box(429), box(2186), nullptr); - avl = gpr_avl_add(avl, box(598), box(2187), nullptr); - avl = remove_int(avl, 551); - avl = gpr_avl_add(avl, box(827), box(2189), nullptr); - avl = gpr_avl_add(avl, box(809), box(2190), nullptr); - avl = remove_int(avl, 438); - avl = remove_int(avl, 811); - avl = gpr_avl_add(avl, box(808), box(2193), nullptr); - avl = gpr_avl_add(avl, box(788), box(2194), nullptr); - avl = remove_int(avl, 156); - avl = gpr_avl_add(avl, box(933), box(2196), nullptr); - avl = gpr_avl_add(avl, box(344), box(2197), nullptr); - avl = remove_int(avl, 460); - avl = gpr_avl_add(avl, box(161), box(2199), nullptr); - avl = gpr_avl_add(avl, box(444), box(2200), nullptr); - avl = remove_int(avl, 597); - avl = remove_int(avl, 668); - avl = gpr_avl_add(avl, box(703), box(2203), nullptr); - avl = remove_int(avl, 515); - avl = gpr_avl_add(avl, box(380), box(2205), nullptr); - avl = gpr_avl_add(avl, box(338), box(2206), nullptr); - avl = remove_int(avl, 550); - avl = remove_int(avl, 946); - avl = remove_int(avl, 714); - avl = remove_int(avl, 739); - avl = gpr_avl_add(avl, box(413), box(2211), nullptr); - avl = remove_int(avl, 450); - avl = gpr_avl_add(avl, box(411), box(2213), nullptr); - avl = gpr_avl_add(avl, box(117), box(2214), nullptr); - avl = gpr_avl_add(avl, box(322), box(2215), nullptr); - avl = gpr_avl_add(avl, box(915), box(2216), nullptr); - avl = gpr_avl_add(avl, box(410), box(2217), nullptr); - avl = gpr_avl_add(avl, box(66), box(2218), nullptr); - avl = remove_int(avl, 756); - avl = remove_int(avl, 596); - avl = gpr_avl_add(avl, box(882), box(2221), nullptr); - avl = gpr_avl_add(avl, box(930), box(2222), nullptr); - avl = gpr_avl_add(avl, box(36), box(2223), nullptr); - avl = remove_int(avl, 742); - avl = gpr_avl_add(avl, box(539), box(2225), nullptr); - avl = gpr_avl_add(avl, box(596), box(2226), nullptr); - avl = remove_int(avl, 82); - avl = remove_int(avl, 686); - avl = remove_int(avl, 933); - avl = remove_int(avl, 42); - avl = remove_int(avl, 340); - avl = gpr_avl_add(avl, box(126), box(2232), nullptr); - avl = gpr_avl_add(avl, box(493), box(2233), nullptr); - avl = gpr_avl_add(avl, box(839), box(2234), nullptr); - avl = remove_int(avl, 774); - avl = gpr_avl_add(avl, box(337), box(2236), nullptr); - avl = remove_int(avl, 322); - avl = gpr_avl_add(avl, box(16), box(2238), nullptr); - avl = remove_int(avl, 73); - avl = remove_int(avl, 85); - avl = remove_int(avl, 191); - avl = remove_int(avl, 541); - avl = gpr_avl_add(avl, box(704), box(2243), nullptr); - avl = remove_int(avl, 767); - avl = remove_int(avl, 1006); - avl = remove_int(avl, 844); - avl = remove_int(avl, 742); - avl = gpr_avl_add(avl, box(48), box(2248), nullptr); - avl = gpr_avl_add(avl, box(138), box(2249), nullptr); - avl = gpr_avl_add(avl, box(437), box(2250), nullptr); - avl = gpr_avl_add(avl, box(275), box(2251), nullptr); - avl = remove_int(avl, 520); - avl = gpr_avl_add(avl, box(1019), box(2253), nullptr); - avl = remove_int(avl, 955); - avl = gpr_avl_add(avl, box(270), box(2255), nullptr); - avl = remove_int(avl, 680); - avl = remove_int(avl, 698); - avl = gpr_avl_add(avl, box(735), box(2258), nullptr); - avl = gpr_avl_add(avl, box(400), box(2259), nullptr); - avl = remove_int(avl, 991); - avl = gpr_avl_add(avl, box(263), box(2261), nullptr); - avl = remove_int(avl, 704); - avl = gpr_avl_add(avl, box(757), box(2263), nullptr); - avl = remove_int(avl, 194); - avl = remove_int(avl, 616); - avl = remove_int(avl, 784); - avl = gpr_avl_add(avl, box(382), box(2267), nullptr); - avl = gpr_avl_add(avl, box(464), box(2268), nullptr); - avl = gpr_avl_add(avl, box(817), box(2269), nullptr); - avl = remove_int(avl, 445); - avl = gpr_avl_add(avl, box(412), box(2271), nullptr); - avl = remove_int(avl, 525); - avl = gpr_avl_add(avl, box(299), box(2273), nullptr); - avl = gpr_avl_add(avl, box(464), box(2274), nullptr); - avl = gpr_avl_add(avl, box(715), box(2275), nullptr); - avl = remove_int(avl, 58); - avl = remove_int(avl, 218); - avl = gpr_avl_add(avl, box(961), box(2278), nullptr); - avl = gpr_avl_add(avl, box(491), box(2279), nullptr); - avl = remove_int(avl, 846); - avl = gpr_avl_add(avl, box(762), box(2281), nullptr); - avl = remove_int(avl, 974); - avl = remove_int(avl, 887); - avl = gpr_avl_add(avl, box(498), box(2284), nullptr); - avl = remove_int(avl, 810); - avl = remove_int(avl, 743); - avl = remove_int(avl, 22); - avl = remove_int(avl, 284); - avl = gpr_avl_add(avl, box(482), box(2289), nullptr); - avl = gpr_avl_add(avl, box(1021), box(2290), nullptr); - avl = remove_int(avl, 155); - avl = remove_int(avl, 128); - avl = gpr_avl_add(avl, box(819), box(2293), nullptr); - avl = gpr_avl_add(avl, box(324), box(2294), nullptr); - avl = remove_int(avl, 196); - avl = remove_int(avl, 370); - avl = remove_int(avl, 753); - avl = remove_int(avl, 56); - avl = remove_int(avl, 735); - avl = gpr_avl_add(avl, box(272), box(2300), nullptr); - avl = gpr_avl_add(avl, box(474), box(2301), nullptr); - avl = gpr_avl_add(avl, box(719), box(2302), nullptr); - avl = gpr_avl_add(avl, box(236), box(2303), nullptr); - avl = remove_int(avl, 818); - avl = gpr_avl_add(avl, box(727), box(2305), nullptr); - avl = remove_int(avl, 892); - avl = remove_int(avl, 871); - avl = remove_int(avl, 231); - avl = gpr_avl_add(avl, box(62), box(2309), nullptr); - avl = gpr_avl_add(avl, box(953), box(2310), nullptr); - avl = remove_int(avl, 701); - avl = gpr_avl_add(avl, box(193), box(2312), nullptr); - avl = remove_int(avl, 619); - avl = remove_int(avl, 22); - avl = remove_int(avl, 804); - avl = remove_int(avl, 851); - avl = gpr_avl_add(avl, box(286), box(2317), nullptr); - avl = gpr_avl_add(avl, box(751), box(2318), nullptr); - avl = remove_int(avl, 525); - avl = gpr_avl_add(avl, box(217), box(2320), nullptr); - avl = remove_int(avl, 336); - avl = gpr_avl_add(avl, box(86), box(2322), nullptr); - avl = gpr_avl_add(avl, box(81), box(2323), nullptr); - avl = gpr_avl_add(avl, box(850), box(2324), nullptr); - avl = remove_int(avl, 872); - avl = gpr_avl_add(avl, box(402), box(2326), nullptr); - avl = gpr_avl_add(avl, box(54), box(2327), nullptr); - avl = gpr_avl_add(avl, box(980), box(2328), nullptr); - avl = gpr_avl_add(avl, box(845), box(2329), nullptr); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 273); - avl = remove_int(avl, 879); - avl = gpr_avl_add(avl, box(354), box(2333), nullptr); - avl = gpr_avl_add(avl, box(58), box(2334), nullptr); - avl = gpr_avl_add(avl, box(127), box(2335), nullptr); - avl = remove_int(avl, 84); - avl = gpr_avl_add(avl, box(360), box(2337), nullptr); - avl = remove_int(avl, 648); - avl = remove_int(avl, 488); - avl = remove_int(avl, 585); - avl = remove_int(avl, 230); - avl = gpr_avl_add(avl, box(887), box(2342), nullptr); - avl = remove_int(avl, 558); - avl = remove_int(avl, 958); - avl = gpr_avl_add(avl, box(822), box(2345), nullptr); - avl = remove_int(avl, 1004); - avl = remove_int(avl, 747); - avl = gpr_avl_add(avl, box(631), box(2348), nullptr); - avl = gpr_avl_add(avl, box(442), box(2349), nullptr); - avl = remove_int(avl, 957); - avl = remove_int(avl, 964); - avl = gpr_avl_add(avl, box(10), box(2352), nullptr); - avl = remove_int(avl, 189); - avl = gpr_avl_add(avl, box(742), box(2354), nullptr); - avl = remove_int(avl, 108); - avl = gpr_avl_add(avl, box(1014), box(2356), nullptr); - avl = remove_int(avl, 266); - avl = remove_int(avl, 623); - avl = remove_int(avl, 697); - avl = gpr_avl_add(avl, box(180), box(2360), nullptr); - avl = remove_int(avl, 472); - avl = gpr_avl_add(avl, box(567), box(2362), nullptr); - avl = remove_int(avl, 1020); - avl = remove_int(avl, 273); - avl = gpr_avl_add(avl, box(864), box(2365), nullptr); - avl = gpr_avl_add(avl, box(1009), box(2366), nullptr); - avl = remove_int(avl, 224); - avl = remove_int(avl, 81); - avl = gpr_avl_add(avl, box(653), box(2369), nullptr); - avl = remove_int(avl, 67); - avl = remove_int(avl, 102); - avl = remove_int(avl, 76); - avl = remove_int(avl, 935); - avl = remove_int(avl, 169); - avl = remove_int(avl, 232); - avl = remove_int(avl, 79); - avl = gpr_avl_add(avl, box(509), box(2377), nullptr); - avl = remove_int(avl, 900); - avl = remove_int(avl, 822); - avl = remove_int(avl, 945); - avl = remove_int(avl, 356); - avl = gpr_avl_add(avl, box(443), box(2382), nullptr); - avl = gpr_avl_add(avl, box(925), box(2383), nullptr); - avl = remove_int(avl, 994); - avl = remove_int(avl, 324); - avl = gpr_avl_add(avl, box(291), box(2386), nullptr); - avl = remove_int(avl, 94); - avl = remove_int(avl, 795); - avl = remove_int(avl, 42); - avl = gpr_avl_add(avl, box(613), box(2390), nullptr); - avl = remove_int(avl, 289); - avl = gpr_avl_add(avl, box(980), box(2392), nullptr); - avl = remove_int(avl, 316); - avl = gpr_avl_add(avl, box(281), box(2394), nullptr); - avl = gpr_avl_add(avl, box(1006), box(2395), nullptr); - avl = remove_int(avl, 776); - avl = gpr_avl_add(avl, box(108), box(2397), nullptr); - avl = gpr_avl_add(avl, box(918), box(2398), nullptr); - avl = remove_int(avl, 721); - avl = remove_int(avl, 563); - avl = gpr_avl_add(avl, box(925), box(2401), nullptr); - avl = remove_int(avl, 448); - avl = remove_int(avl, 198); - avl = remove_int(avl, 1); - avl = gpr_avl_add(avl, box(160), box(2405), nullptr); - avl = remove_int(avl, 515); - avl = gpr_avl_add(avl, box(284), box(2407), nullptr); - avl = gpr_avl_add(avl, box(225), box(2408), nullptr); - avl = remove_int(avl, 304); - avl = gpr_avl_add(avl, box(714), box(2410), nullptr); - avl = gpr_avl_add(avl, box(708), box(2411), nullptr); - avl = gpr_avl_add(avl, box(624), box(2412), nullptr); - avl = remove_int(avl, 662); - avl = remove_int(avl, 825); - avl = remove_int(avl, 383); - avl = remove_int(avl, 381); - avl = gpr_avl_add(avl, box(194), box(2417), nullptr); - avl = remove_int(avl, 280); - avl = remove_int(avl, 25); - avl = remove_int(avl, 633); - avl = gpr_avl_add(avl, box(897), box(2421), nullptr); - avl = remove_int(avl, 636); - avl = remove_int(avl, 596); - avl = remove_int(avl, 757); - avl = remove_int(avl, 343); - avl = remove_int(avl, 162); - avl = remove_int(avl, 913); - avl = remove_int(avl, 843); - avl = remove_int(avl, 280); - avl = remove_int(avl, 911); - avl = gpr_avl_add(avl, box(1008), box(2431), nullptr); - avl = remove_int(avl, 948); - avl = remove_int(avl, 74); - avl = remove_int(avl, 571); - avl = gpr_avl_add(avl, box(486), box(2435), nullptr); - avl = gpr_avl_add(avl, box(285), box(2436), nullptr); - avl = remove_int(avl, 304); - avl = remove_int(avl, 516); - avl = gpr_avl_add(avl, box(758), box(2439), nullptr); - avl = gpr_avl_add(avl, box(776), box(2440), nullptr); - avl = remove_int(avl, 696); - avl = gpr_avl_add(avl, box(104), box(2442), nullptr); - avl = gpr_avl_add(avl, box(700), box(2443), nullptr); - avl = gpr_avl_add(avl, box(114), box(2444), nullptr); - avl = gpr_avl_add(avl, box(567), box(2445), nullptr); - avl = remove_int(avl, 620); - avl = gpr_avl_add(avl, box(270), box(2447), nullptr); - avl = remove_int(avl, 730); - avl = gpr_avl_add(avl, box(749), box(2449), nullptr); - avl = gpr_avl_add(avl, box(443), box(2450), nullptr); - avl = remove_int(avl, 457); - avl = gpr_avl_add(avl, box(571), box(2452), nullptr); - avl = gpr_avl_add(avl, box(626), box(2453), nullptr); - avl = remove_int(avl, 638); - avl = remove_int(avl, 313); - - gpr_avl_unref(avl, nullptr); -} - -static void test_stress(int amount_of_stress) { - int added[1024]; - int i, j; - int deletions = 0; - gpr_avl avl; - - unsigned seed = (unsigned)time(nullptr); - - gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed); - - srand((unsigned)time(nullptr)); - avl = gpr_avl_create(&int_int_vtable); - - memset(added, 0, sizeof(added)); - - for (i = 1; deletions < amount_of_stress; i++) { - int idx = rand() % (int)GPR_ARRAY_SIZE(added); - GPR_ASSERT(i); - if (rand() < RAND_MAX / 2) { - added[idx] = i; - printf("avl = gpr_avl_add(avl, box(%d), box(%d), NULL); /* d=%d */\n", - idx, i, deletions); - avl = gpr_avl_add(avl, box(idx), box(i), nullptr); - } else { - deletions += (added[idx] != 0); - added[idx] = 0; - printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions); - avl = remove_int(avl, idx); - } - for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) { - if (added[j] != 0) { - check_get(avl, j, added[j]); - } else { - check_negget(avl, j); - } - } - } - - gpr_avl_unref(avl, nullptr); -} - -int main(int argc, char* argv[]) { - grpc_test_init(argc, argv); - - test_get(); - test_ll(); - test_lr(); - test_rr(); - test_rl(); - test_unbalanced(); - test_replace(); - test_remove(); - test_badcase1(); - test_badcase2(); - test_badcase3(); - test_stress(10); - - return 0; -} diff --git a/test/core/gpr/host_port_test.cc b/test/core/gpr/host_port_test.cc index 42dd56524f..b5d88b2b01 100644 --- a/test/core/gpr/host_port_test.cc +++ b/test/core/gpr/host_port_test.cc @@ -19,8 +19,9 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> + +#include "src/core/lib/gpr/host_port.h" #include "test/core/util/test_config.h" static void join_host_port_expect(const char* host, int port, diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc index 5a8177543c..58df2f14fc 100644 --- a/test/core/gpr/mpscq_test.cc +++ b/test/core/gpr/mpscq_test.cc @@ -24,7 +24,8 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" typedef struct test_node { diff --git a/test/core/gpr/string_test.cc b/test/core/gpr/string_test.cc index 57068eb2c9..9f3b312465 100644 --- a/test/core/gpr/string_test.cc +++ b/test/core/gpr/string_test.cc @@ -26,7 +26,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> + #include "test/core/util/test_config.h" #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/gpr/tls_test.cc b/test/core/gpr/tls_test.cc index 743b10f090..1ef253ed6f 100644 --- a/test/core/gpr/tls_test.cc +++ b/test/core/gpr/tls_test.cc @@ -21,9 +21,10 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/thd.h> -#include <grpc/support/tls.h> #include <stdio.h> #include <stdlib.h> + +#include "src/core/lib/gpr/tls.h" #include "test/core/util/test_config.h" #define NUM_THREADS 100 diff --git a/test/core/gpr/useful_test.cc b/test/core/gpr/useful_test.cc index 2f86010d77..619c800c4d 100644 --- a/test/core/gpr/useful_test.cc +++ b/test/core/gpr/useful_test.cc @@ -18,7 +18,8 @@ #include <grpc/support/log.h> #include <grpc/support/port_platform.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" int main(int argc, char** argv) { diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc index 0e712dafe4..b900afaf3d 100644 --- a/test/core/gprpp/inlined_vector_test.cc +++ b/test/core/gprpp/inlined_vector_test.cc @@ -64,6 +64,44 @@ TEST(InlinedVectorTest, EmplaceBack) { EXPECT_EQ(3, *v[0]); } +TEST(InlinedVectorTest, ClearAndRepopulate) { + const int kNumElements = 10; + InlinedVector<int, 5> v; + EXPECT_EQ(0UL, v.size()); + for (int i = 0; i < kNumElements; ++i) { + v.push_back(i); + EXPECT_EQ(i + 1UL, v.size()); + } + for (int i = 0; i < kNumElements; ++i) { + EXPECT_EQ(i, v[i]); + } + v.clear(); + EXPECT_EQ(0UL, v.size()); + for (int i = 0; i < kNumElements; ++i) { + v.push_back(kNumElements + i); + EXPECT_EQ(i + 1UL, v.size()); + } + for (int i = 0; i < kNumElements; ++i) { + EXPECT_EQ(kNumElements + i, v[i]); + } +} + +TEST(InlinedVectorTest, ConstIndexOperator) { + const int kNumElements = 10; + InlinedVector<int, 5> v; + EXPECT_EQ(0UL, v.size()); + for (int i = 0; i < kNumElements; ++i) { + v.push_back(i); + EXPECT_EQ(i + 1UL, v.size()); + } + auto const_func = [kNumElements](const InlinedVector<int, 5>& v) { + for (int i = 0; i < kNumElements; ++i) { + EXPECT_EQ(i, v[i]); + } + }; + const_func(v); +} + } // namespace testing } // namespace grpc_core diff --git a/test/core/gprpp/orphanable_test.cc b/test/core/gprpp/orphanable_test.cc index ff2f6d8bc2..ad6b9ac867 100644 --- a/test/core/gprpp/orphanable_test.cc +++ b/test/core/gprpp/orphanable_test.cc @@ -58,18 +58,19 @@ TEST(MakeOrphanable, WithParameters) { EXPECT_EQ(5, foo->value()); } -class Bar : public InternallyRefCounted { +class Bar : public InternallyRefCounted<Bar> { public: Bar() : Bar(0) {} explicit Bar(int value) : value_(value) {} void Orphan() override { Unref(); } int value() const { return value_; } - void StartWork() { Ref(); } - void FinishWork() { Unref(); } + void StartWork() { self_ref_ = Ref(); } + void FinishWork() { self_ref_.reset(); } private: int value_; + RefCountedPtr<Bar> self_ref_; }; TEST(OrphanablePtr, InternallyRefCounted) { @@ -82,19 +83,24 @@ TEST(OrphanablePtr, InternallyRefCounted) { // things build properly in both debug and non-debug cases. DebugOnlyTraceFlag baz_tracer(true, "baz"); -class Baz : public InternallyRefCountedWithTracing { +class Baz : public InternallyRefCountedWithTracing<Baz> { public: Baz() : Baz(0) {} explicit Baz(int value) - : InternallyRefCountedWithTracing(&baz_tracer), value_(value) {} + : InternallyRefCountedWithTracing<Baz>(&baz_tracer), value_(value) {} void Orphan() override { Unref(); } int value() const { return value_; } - void StartWork() { Ref(DEBUG_LOCATION, "work"); } - void FinishWork() { Unref(DEBUG_LOCATION, "work"); } + void StartWork() { self_ref_ = Ref(DEBUG_LOCATION, "work"); } + void FinishWork() { + // This is a little ugly, but it makes the logged ref and unref match up. + self_ref_.release(); + Unref(DEBUG_LOCATION, "work"); + } private: int value_; + RefCountedPtr<Baz> self_ref_; }; TEST(OrphanablePtr, InternallyRefCountedWithTracing) { diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index f1f13f3183..2e398a7722 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -30,7 +30,7 @@ namespace grpc_core { namespace testing { namespace { -class Foo : public RefCounted { +class Foo : public RefCounted<Foo> { public: Foo() : value_(0) {} @@ -163,14 +163,15 @@ TEST(MakeRefCounted, Args) { TraceFlag foo_tracer(true, "foo"); -class FooWithTracing : public RefCountedWithTracing { +class FooWithTracing : public RefCountedWithTracing<FooWithTracing> { public: FooWithTracing() : RefCountedWithTracing(&foo_tracer) {} }; TEST(RefCountedPtr, RefCountedWithTracing) { RefCountedPtr<FooWithTracing> foo(New<FooWithTracing>()); - foo->Ref(DEBUG_LOCATION, "foo"); + RefCountedPtr<FooWithTracing> foo2 = foo->Ref(DEBUG_LOCATION, "foo"); + foo2.release(); foo->Unref(DEBUG_LOCATION, "foo"); } diff --git a/test/core/gprpp/ref_counted_test.cc b/test/core/gprpp/ref_counted_test.cc index b1b0fee5c0..f85a2e4675 100644 --- a/test/core/gprpp/ref_counted_test.cc +++ b/test/core/gprpp/ref_counted_test.cc @@ -27,7 +27,7 @@ namespace grpc_core { namespace testing { namespace { -class Foo : public RefCounted { +class Foo : public RefCounted<Foo> { public: Foo() {} }; @@ -39,7 +39,8 @@ TEST(RefCounted, Basic) { TEST(RefCounted, ExtraRef) { Foo* foo = New<Foo>(); - foo->Ref(); + RefCountedPtr<Foo> foop = foo->Ref(); + foop.release(); foo->Unref(); foo->Unref(); } @@ -48,17 +49,19 @@ TEST(RefCounted, ExtraRef) { // things build properly in both debug and non-debug cases. DebugOnlyTraceFlag foo_tracer(true, "foo"); -class FooWithTracing : public RefCountedWithTracing { +class FooWithTracing : public RefCountedWithTracing<FooWithTracing> { public: FooWithTracing() : RefCountedWithTracing(&foo_tracer) {} }; TEST(RefCountedWithTracing, Basic) { FooWithTracing* foo = New<FooWithTracing>(); - foo->Ref(DEBUG_LOCATION, "extra_ref"); + RefCountedPtr<FooWithTracing> foop = foo->Ref(DEBUG_LOCATION, "extra_ref"); + foop.release(); foo->Unref(DEBUG_LOCATION, "extra_ref"); // Can use the no-argument methods, too. - foo->Ref(); + foop = foo->Ref(); + foop.release(); foo->Unref(); foo->Unref(DEBUG_LOCATION, "original_ref"); } diff --git a/test/core/http/BUILD b/test/core/http/BUILD index a5ae6272db..be51ea0737 100644 --- a/test/core/http/BUILD +++ b/test/core/http/BUILD @@ -66,7 +66,12 @@ grpc_cc_test( name = "httpcli_test", srcs = ["httpcli_test.cc"], language = "C++", - data = ["test_server.py"], + data = [ + "python_wrapper.sh", + "test_server.py", + "//src/core/tsi/test_creds:server1.pem", + "//src/core/tsi/test_creds:server1.key" + ], deps = [ "//:gpr", "//:grpc", @@ -80,7 +85,13 @@ grpc_cc_test( name = "httpscli_test", srcs = ["httpscli_test.cc"], language = "C++", - data = ["test_server.py"], + data = [ + "python_wrapper.sh", + "test_server.py", + "//src/core/tsi/test_creds:ca.pem", + "//src/core/tsi/test_creds:server1.pem", + "//src/core/tsi/test_creds:server1.key" + ], deps = [ "//:gpr", "//:grpc", @@ -102,3 +113,16 @@ grpc_cc_test( "//test/core/util:grpc_test_util", ], ) + +grpc_cc_test( + name = "format_request_test", + srcs = ["format_request_test.cc"], + language = "C++", + deps = [ + "//:gpr", + "//:grpc", + "//test/core/end2end:ssl_test_data", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + ], +) diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc index 259e3aa463..3d892b939c 100644 --- a/test/core/http/httpcli_test.cc +++ b/test/core/http/httpcli_test.cc @@ -24,10 +24,11 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> #include <grpc/support/sync.h> + #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" static int g_done = 0; @@ -154,10 +155,17 @@ int main(int argc, char** argv) { int arg_shift = 0; /* figure out where we are */ char* root; - if (lslash) { - root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1))); + if (lslash != nullptr) { + /* Hack for bazel target */ + if ((unsigned)(lslash - me) >= (sizeof("http") - 1) && + strncmp(me + (lslash - me) - sizeof("http") + 1, "http", + sizeof("http") - 1) == 0) { + lslash = me + (lslash - me) - sizeof("http"); + } + root = static_cast<char*>( + gpr_malloc((size_t)(lslash - me + sizeof("/../..")))); memcpy(root, me, (size_t)(lslash - me)); - root[lslash - me] = 0; + memcpy(root + (lslash - me), "/../..", sizeof("/../..")); } else { root = gpr_strdup("."); } @@ -167,8 +175,8 @@ int main(int argc, char** argv) { args[0] = gpr_strdup(argv[1]); } else { arg_shift = 1; - gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root); - gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root); + gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root); + gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root); } /* start the server */ diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index adf69f1b16..7e99ad4249 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -21,13 +21,16 @@ #include <string.h> #include <grpc/grpc.h> +#include <grpc/grpc_security_constants.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> #include <grpc/support/sync.h> + +#include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" #include "test/core/util/test_config.h" static int g_done = 0; @@ -152,10 +155,17 @@ int main(int argc, char** argv) { int arg_shift = 0; /* figure out where we are */ char* root; - if (lslash) { - root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1))); + if (lslash != nullptr) { + /* Hack for bazel target */ + if ((unsigned)(lslash - me) >= (sizeof("http") - 1) && + strncmp(me + (lslash - me) - sizeof("http") + 1, "http", + sizeof("http") - 1) == 0) { + lslash = me + (lslash - me) - sizeof("http"); + } + root = static_cast<char*>( + gpr_malloc((size_t)(lslash - me + sizeof("/../..")))); memcpy(root, me, (size_t)(lslash - me)); - root[lslash - me] = 0; + memcpy(root + (lslash - me), "/../..", sizeof("/../..")); } else { root = gpr_strdup("."); } @@ -165,10 +175,16 @@ int main(int argc, char** argv) { args[0] = gpr_strdup(argv[1]); } else { arg_shift = 1; - gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root); - gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root); + gpr_asprintf(&args[0], "%s/test/core/http/python_wrapper.sh", root); + gpr_asprintf(&args[1], "%s/test/core/http/test_server.py", root); } + /* Set the environment variable for the SSL certificate file */ + char* pem_file; + gpr_asprintf(&pem_file, "%s/src/core/tsi/test_creds/ca.pem", root); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, pem_file); + gpr_free(pem_file); + /* start the server */ args[1 + arg_shift] = const_cast<char*>("--port"); gpr_asprintf(&args[2 + arg_shift], "%d", port); diff --git a/test/core/http/parser_test.cc b/test/core/http/parser_test.cc index 18f19856bd..fe824f57fc 100644 --- a/test/core/http/parser_test.cc +++ b/test/core/http/parser_test.cc @@ -25,7 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/http/python_wrapper.sh b/test/core/http/python_wrapper.sh new file mode 120000 index 0000000000..9ed6e3293f --- /dev/null +++ b/test/core/http/python_wrapper.sh @@ -0,0 +1 @@ +../../../tools/distrib/python_wrapper.sh
\ No newline at end of file diff --git a/test/core/iomgr/combiner_test.cc b/test/core/iomgr/combiner_test.cc index 891008c774..eb926cc620 100644 --- a/test/core/iomgr/combiner_test.cc +++ b/test/core/iomgr/combiner_test.cc @@ -22,8 +22,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static void test_no_op(void) { diff --git a/test/core/iomgr/endpoint_pair_test.cc b/test/core/iomgr/endpoint_pair_test.cc index 90dd40d9c4..4251f27c81 100644 --- a/test/core/iomgr/endpoint_pair_test.cc +++ b/test/core/iomgr/endpoint_pair_test.cc @@ -21,7 +21,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc index 8ccae52067..842be8fc92 100644 --- a/test/core/iomgr/endpoint_tests.cc +++ b/test/core/iomgr/endpoint_tests.cc @@ -25,8 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/error_test.cc b/test/core/iomgr/error_test.cc index 51f8af1957..064ce0a6b2 100644 --- a/test/core/iomgr/error_test.cc +++ b/test/core/iomgr/error_test.cc @@ -22,7 +22,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> #include <string.h> diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc index 262470300e..07a69a27c7 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.cc +++ b/test/core/iomgr/ev_epollsig_linux_test.cc @@ -30,8 +30,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc index 7d2f59bed4..114f39726d 100644 --- a/test/core/iomgr/pollset_set_test.cc +++ b/test/core/iomgr/pollset_set_test.cc @@ -27,8 +27,8 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc index e36315333c..92d2338a02 100644 --- a/test/core/iomgr/resolve_address_posix_test.cc +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -27,8 +27,8 @@ #include <grpc/support/sync.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/socket_utils_test.cc b/test/core/iomgr/socket_utils_test.cc index 49c6f799e7..67391a547d 100644 --- a/test/core/iomgr/socket_utils_test.cc +++ b/test/core/iomgr/socket_utils_test.cc @@ -30,7 +30,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/socket_mutator.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc index f4acba8302..3a79b9b430 100644 --- a/test/core/iomgr/tcp_posix_test.cc +++ b/test/core/iomgr/tcp_posix_test.cc @@ -34,8 +34,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" diff --git a/test/core/iomgr/timer_heap_test.cc b/test/core/iomgr/timer_heap_test.cc index f0ab4343cb..ed66b7df8d 100644 --- a/test/core/iomgr/timer_heap_test.cc +++ b/test/core/iomgr/timer_heap_test.cc @@ -28,8 +28,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" static gpr_atm random_deadline(void) { return rand(); } diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index 09f0283013..4c92a6b69e 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -33,9 +33,9 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/socket_factory_posix.h" diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc index c092a8f3bf..2d64520b92 100644 --- a/test/core/iomgr/wakeup_fd_cv_test.cc +++ b/test/core/iomgr/wakeup_fd_cv_test.cc @@ -25,7 +25,6 @@ #include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/ev_posix.h" diff --git a/test/core/json/json_rewrite.cc b/test/core/json/json_rewrite.cc index 6891a57f9f..0319d15024 100644 --- a/test/core/json/json_rewrite.cc +++ b/test/core/json/json_rewrite.cc @@ -20,11 +20,11 @@ #include <stdlib.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include "src/core/lib/json/json_reader.h" #include "src/core/lib/json/json_writer.h" +#include "test/core/util/cmdline.h" typedef struct json_writer_userdata { FILE* out; diff --git a/test/core/json/json_rewrite_test.cc b/test/core/json/json_rewrite_test.cc index 3104afc442..8846d4612b 100644 --- a/test/core/json/json_rewrite_test.cc +++ b/test/core/json/json_rewrite_test.cc @@ -21,9 +21,9 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "test/core/util/test_config.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/json/json_reader.h" #include "src/core/lib/json/json_writer.h" diff --git a/test/core/json/json_stream_error_test.cc b/test/core/json/json_stream_error_test.cc index b367d3fbf7..00288d6d5e 100644 --- a/test/core/json/json_stream_error_test.cc +++ b/test/core/json/json_stream_error_test.cc @@ -21,7 +21,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "test/core/util/test_config.h" #include "src/core/lib/json/json_reader.h" diff --git a/test/core/json/json_test.cc b/test/core/json/json_test.cc index 902f1cd90e..7f1dbb774a 100644 --- a/test/core/json/json_test.cc +++ b/test/core/json/json_test.cc @@ -21,8 +21,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/json/json.h" #include "test/core/util/test_config.h" diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc index ca841434aa..4f2ca9e937 100644 --- a/test/core/memory_usage/client.cc +++ b/test/core/memory_usage/client.cc @@ -24,12 +24,13 @@ #include <grpc/byte_buffer.h> #include <grpc/byte_buffer_reader.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" + +#include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" #include "test/core/util/test_config.h" diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc index fb6d290130..cc3528b060 100644 --- a/test/core/memory_usage/memory_usage_test.cc +++ b/test/core/memory_usage/memory_usage_test.cc @@ -20,11 +20,12 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" +#include "test/core/util/subprocess.h" int main(int argc, char** argv) { char* me = argv[0]; diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 60ebcece3e..a276102e83 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -30,11 +30,12 @@ #endif #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/time.h> + +#include "src/core/lib/gpr/host_port.h" #include "test/core/end2end/data/ssl_test_data.h" +#include "test/core/util/cmdline.h" #include "test/core/util/memory_counters.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -289,6 +290,7 @@ int main(int argc, char** argv) { } // no break here since we want to continue to case // FLING_SERVER_SEND_STATUS_SNAPSHOT to destroy the snapshot call + /* fallthrough */ case FLING_SERVER_SEND_STATUS_SNAPSHOT: grpc_byte_buffer_destroy(payload_buffer); grpc_byte_buffer_destroy(terminal_buffer); diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc index fb982a10fd..8fd2c75438 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.cc +++ b/test/core/network_benchmarks/low_level_ping_pong.cc @@ -35,13 +35,14 @@ #include <sys/socket.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/socket_utils_posix.h" +#include "test/core/util/cmdline.h" #include "test/core/util/histogram.h" typedef struct fd_pair { diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 7cd3ae58da..425c617fd1 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -110,6 +110,7 @@ grpc_cc_binary( deps = [ "//:gpr", "//:grpc", + "//test/core/util:grpc_test_util", ], ) @@ -121,6 +122,7 @@ grpc_cc_binary( ":oauth2_utils", "//:gpr", "//:grpc", + "//test/core/util:grpc_test_util", ], ) @@ -131,5 +133,6 @@ grpc_cc_binary( deps = [ "//:gpr", "//:grpc", + "//test/core/util:grpc_test_util", ], ) diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc index 56ae9c891c..bb8227f08f 100644 --- a/test/core/security/create_jwt.cc +++ b/test/core/security/create_jwt.cc @@ -24,9 +24,10 @@ #include <grpc/slice.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> +#include "test/core/util/cmdline.h" + void create_jwt(const char* json_key_file_path, const char* service_url, const char* scope) { grpc_auth_json_key key; diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index cb28a0487c..b0fa514400 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -23,13 +23,13 @@ #include <grpc/grpc_security.h> #include <grpc/slice.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/credentials.h" #include "test/core/security/oauth2_utils.h" +#include "test/core/util/cmdline.h" static grpc_call_credentials* create_refresh_token_creds( const char* json_refresh_token_file_path) { diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index a90f997bda..828694afd1 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -23,7 +23,6 @@ #include <grpc/grpc_security.h> #include <grpc/slice.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> @@ -31,6 +30,7 @@ #include "src/core/lib/security/credentials/composite/composite_credentials.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/slice/slice_string_helpers.h" +#include "test/core/util/cmdline.h" typedef struct { gpr_mu* mu; diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc index 38c78fed42..8e92a21e5d 100644 --- a/test/core/security/secure_endpoint_test.cc +++ b/test/core/security/secure_endpoint_test.cc @@ -24,7 +24,7 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/security/transport/secure_endpoint.h" diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc index 6eaef2bf49..e4731fb039 100644 --- a/test/core/security/security_connector_test.cc +++ b/test/core/security/security_connector_test.cc @@ -23,7 +23,6 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index 5d32ce0cdb..747508f6f6 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -23,11 +23,11 @@ #include <grpc/grpc_security.h> #include <grpc/slice.h> #include <grpc/support/alloc.h> -#include <grpc/support/cmdline.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include "src/core/lib/security/credentials/jwt/jwt_verifier.h" +#include "test/core/util/cmdline.h" typedef struct { grpc_pollset* pollset; diff --git a/test/core/slice/slice_string_helpers_test.cc b/test/core/slice/slice_string_helpers_test.cc index a443f17c69..860a1bfe03 100644 --- a/test/core/slice/slice_string_helpers_test.cc +++ b/test/core/slice/slice_string_helpers_test.cc @@ -23,11 +23,9 @@ #include <stdlib.h> #include <string.h> -#include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/core/util/test_config.h" @@ -129,11 +127,77 @@ static void test_strsplit(void) { gpr_free(parts); } +static void test_strsplit_nospace(void) { + grpc_slice_buffer* parts; + grpc_slice str; + + LOG_TEST_NAME("test_strsplit_nospace"); + + parts = + static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(grpc_slice_buffer))); + grpc_slice_buffer_init(parts); + + str = grpc_slice_from_copied_string("one ,two, three , four"); + grpc_slice_split_without_space(str, ",", parts); + GPR_ASSERT(4 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "two")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[2], "three")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[3], "four")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* separator not present in string */ + str = grpc_slice_from_copied_string("one two three four "); + grpc_slice_split_without_space(str, ",", parts); + GPR_ASSERT(1 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one two three four")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* separator at the end */ + str = grpc_slice_from_copied_string("foo,"); + grpc_slice_split_without_space(str, ",", parts); + GPR_ASSERT(2 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* separator at the beginning */ + str = grpc_slice_from_copied_string(" , foo"); + grpc_slice_split_without_space(str, ",", parts); + GPR_ASSERT(2 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "foo")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* standalone separator */ + str = grpc_slice_from_copied_string(", "); + grpc_slice_split_without_space(str, ", ", parts); + GPR_ASSERT(2 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* empty input */ + str = grpc_slice_from_copied_string(""); + grpc_slice_split_without_space(str, ",", parts); + GPR_ASSERT(1 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + grpc_slice_buffer_destroy(parts); + gpr_free(parts); +} + int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); test_dump_slice(); test_strsplit(); - grpc_shutdown(); + test_strsplit_nospace(); return 0; } diff --git a/test/core/surface/BUILD b/test/core/surface/BUILD index 6cec7feabc..d27123d1a3 100644 --- a/test/core/surface/BUILD +++ b/test/core/surface/BUILD @@ -19,18 +19,6 @@ licenses(["notice"]) # Apache v2 grpc_package(name = "test/core/surface") grpc_cc_test( - name = "alarm_test", - srcs = ["alarm_test.cc"], - language = "C++", - deps = [ - "//:gpr", - "//:grpc", - "//test/core/util:gpr_test_util", - "//test/core/util:grpc_test_util", - ], -) - -grpc_cc_test( name = "grpc_byte_buffer_reader_test", srcs = ["byte_buffer_reader_test.cc"], language = "C++", diff --git a/test/core/surface/alarm_test.cc b/test/core/surface/alarm_test.cc deleted file mode 100644 index 67fc6833a5..0000000000 --- a/test/core/surface/alarm_test.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * Copyright 2015 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/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> -#include <grpc/support/useful.h> -#include "test/core/util/test_config.h" - -#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) - -static void* create_test_tag(void) { - static intptr_t i = 0; - return (void*)(++i); -} - -/* helper for tests to shutdown correctly and tersely */ -static void shutdown_and_destroy(grpc_completion_queue* cc) { - grpc_event ev; - grpc_completion_queue_shutdown(cc); - /* By the time grpc_completion_queue_shutdown runs, the cq's internal - pending event counter might not have been updated yet by a previous - cq_end_op_for_next (which releases a completed event first and only later - updates the pending event counter), so we can't rely on a no-polling - cq_next to never return GRPC_QUEUE_TIMEOUT. Using a deadline in the future - solves the problem. See https://github.com/grpc/grpc/issues/13693. - */ - ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2), - nullptr); - GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); - grpc_completion_queue_destroy(cc); -} - -static void test_alarm(void) { - grpc_completion_queue* cc; - - LOG_TEST("test_alarm"); - cc = grpc_completion_queue_create_for_next(nullptr); - { - /* regular expiry */ - grpc_event ev; - void* tag = create_test_tag(); - grpc_alarm* alarm = grpc_alarm_create(nullptr); - grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(1), tag, - nullptr); - - ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(2), - nullptr); - GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - GPR_ASSERT(ev.tag == tag); - GPR_ASSERT(ev.success); - grpc_alarm_destroy(alarm, nullptr); - } - { - /* cancellation */ - grpc_event ev; - void* tag = create_test_tag(); - grpc_alarm* alarm = grpc_alarm_create(nullptr); - grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, - nullptr); - - grpc_alarm_cancel(alarm, nullptr); - ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1), - nullptr); - GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - GPR_ASSERT(ev.tag == tag); - GPR_ASSERT(ev.success == 0); - grpc_alarm_destroy(alarm, nullptr); - } - { - /* alarm_destroy before cq_next */ - grpc_event ev; - void* tag = create_test_tag(); - grpc_alarm* alarm = grpc_alarm_create(nullptr); - grpc_alarm_set(alarm, cc, grpc_timeout_seconds_to_deadline(2), tag, - nullptr); - - grpc_alarm_destroy(alarm, nullptr); - ev = grpc_completion_queue_next(cc, grpc_timeout_seconds_to_deadline(1), - nullptr); - GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - GPR_ASSERT(ev.tag == tag); - GPR_ASSERT(ev.success == 0); - } - { - /* alarm_destroy before set */ - grpc_alarm* alarm = grpc_alarm_create(nullptr); - grpc_alarm_destroy(alarm, nullptr); - } - - shutdown_and_destroy(cc); -} - -int main(int argc, char** argv) { - grpc_test_init(argc, argv); - grpc_init(); - test_alarm(); - grpc_shutdown(); - return 0; -} diff --git a/test/core/surface/byte_buffer_reader_test.cc b/test/core/surface/byte_buffer_reader_test.cc index 94a8615b3c..648a9d6986 100644 --- a/test/core/surface/byte_buffer_reader_test.cc +++ b/test/core/surface/byte_buffer_reader_test.cc @@ -133,7 +133,10 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */ { grpc_core::ExecCtx exec_ctx; - GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out)); + GPR_ASSERT(grpc_msg_compress( + + grpc_compression_algorithm_to_message_compression_algorithm(algorithm), + &sliceb_in, &sliceb_out)); } buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices, @@ -202,8 +205,8 @@ static void test_readall(void) { LOG_TEST("test_readall"); - memset(lotsa_as, 'a', 512); - memset(lotsa_bs, 'b', 1024); + memset(lotsa_as, 'a', 512 * sizeof(lotsa_as[0])); + memset(lotsa_bs, 'b', 1024 * sizeof(lotsa_bs[0])); /* use slices large enough to overflow inlining */ slices[0] = grpc_slice_malloc(512); memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512); @@ -237,8 +240,8 @@ static void test_byte_buffer_copy(void) { LOG_TEST("test_byte_buffer_copy"); - memset(lotsa_as, 'a', 512); - memset(lotsa_bs, 'b', 1024); + memset(lotsa_as, 'a', 512 * sizeof(lotsa_as[0])); + memset(lotsa_bs, 'b', 1024 * sizeof(lotsa_bs[0])); /* use slices large enough to overflow inlining */ slices[0] = grpc_slice_malloc(512); memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512); @@ -265,7 +268,6 @@ static void test_byte_buffer_copy(void) { int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_init(); test_read_one_slice(); test_read_one_slice_malloc(); test_read_none_compressed_slice(); @@ -275,6 +277,5 @@ int main(int argc, char** argv) { test_byte_buffer_from_reader(); test_byte_buffer_copy(); test_readall(); - grpc_shutdown(); return 0; } diff --git a/test/core/surface/channel_create_test.cc b/test/core/surface/channel_create_test.cc index 37247f89d0..56f4f602e8 100644 --- a/test/core/surface/channel_create_test.cc +++ b/test/core/surface/channel_create_test.cc @@ -29,8 +29,8 @@ void test_unknown_scheme_target(void) { grpc_channel* chan; /* avoid default prefix */ - grpc_resolver_registry_shutdown(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); chan = grpc_insecure_channel_create("blah://blah", nullptr, nullptr); GPR_ASSERT(chan != nullptr); diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index fefbb3c185..68129146cc 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -21,7 +21,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc index 4a9e818b45..d97e98b7a4 100644 --- a/test/core/surface/completion_queue_threading_test.cc +++ b/test/core/surface/completion_queue_threading_test.cc @@ -22,7 +22,8 @@ #include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index 9cdd299ae3..e48fd7fcf2 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -19,11 +19,11 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index 7fd36a241a..14267c1214 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -46,36 +46,29 @@ #include <grpc/status.h> #include <grpc/support/alloc.h> #include <grpc/support/atm.h> -#include <grpc/support/avl.h> -#include <grpc/support/cmdline.h> #include <grpc/support/cpu.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/port_platform.h> #include <grpc/support/string_util.h> -#include <grpc/support/subprocess.h> #include <grpc/support/sync.h> #include <grpc/support/sync_custom.h> #include <grpc/support/sync_generic.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/tls.h> -#include <grpc/support/useful.h> #include <grpc/support/workaround_list.h> #include <stdio.h> int main(int argc, char **argv) { + printf("%lx", (unsigned long) grpc_compression_algorithm_is_message); + printf("%lx", (unsigned long) grpc_compression_algorithm_is_stream); printf("%lx", (unsigned long) grpc_compression_algorithm_parse); printf("%lx", (unsigned long) grpc_compression_algorithm_name); - printf("%lx", (unsigned long) grpc_stream_compression_algorithm_name); printf("%lx", (unsigned long) grpc_compression_algorithm_for_level); - printf("%lx", (unsigned long) grpc_stream_compression_algorithm_for_level); printf("%lx", (unsigned long) grpc_compression_options_init); printf("%lx", (unsigned long) grpc_compression_options_enable_algorithm); printf("%lx", (unsigned long) grpc_compression_options_disable_algorithm); printf("%lx", (unsigned long) grpc_compression_options_is_algorithm_enabled); - printf("%lx", (unsigned long) grpc_compression_options_is_stream_compression_algorithm_enabled); printf("%lx", (unsigned long) grpc_metadata_array_init); printf("%lx", (unsigned long) grpc_metadata_array_destroy); printf("%lx", (unsigned long) grpc_call_details_init); @@ -95,10 +88,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) grpc_completion_queue_destroy); printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_init); printf("%lx", (unsigned long) grpc_completion_queue_thread_local_cache_flush); - printf("%lx", (unsigned long) grpc_alarm_create); - printf("%lx", (unsigned long) grpc_alarm_set); - printf("%lx", (unsigned long) grpc_alarm_cancel); - printf("%lx", (unsigned long) grpc_alarm_destroy); printf("%lx", (unsigned long) grpc_channel_check_connectivity_state); printf("%lx", (unsigned long) grpc_channel_num_external_connectivity_watchers); printf("%lx", (unsigned long) grpc_channel_watch_connectivity_state); @@ -245,27 +234,8 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) gpr_free_aligned); printf("%lx", (unsigned long) gpr_set_allocation_functions); printf("%lx", (unsigned long) gpr_get_allocation_functions); - printf("%lx", (unsigned long) gpr_avl_create); - printf("%lx", (unsigned long) gpr_avl_ref); - printf("%lx", (unsigned long) gpr_avl_unref); - printf("%lx", (unsigned long) gpr_avl_add); - printf("%lx", (unsigned long) gpr_avl_remove); - printf("%lx", (unsigned long) gpr_avl_get); - printf("%lx", (unsigned long) gpr_avl_maybe_get); - printf("%lx", (unsigned long) gpr_avl_is_empty); - printf("%lx", (unsigned long) gpr_cmdline_create); - printf("%lx", (unsigned long) gpr_cmdline_add_int); - printf("%lx", (unsigned long) gpr_cmdline_add_flag); - printf("%lx", (unsigned long) gpr_cmdline_add_string); - printf("%lx", (unsigned long) gpr_cmdline_on_extra_arg); - printf("%lx", (unsigned long) gpr_cmdline_set_survive_failure); - printf("%lx", (unsigned long) gpr_cmdline_parse); - printf("%lx", (unsigned long) gpr_cmdline_destroy); - printf("%lx", (unsigned long) gpr_cmdline_usage_string); printf("%lx", (unsigned long) gpr_cpu_num_cores); printf("%lx", (unsigned long) gpr_cpu_current_cpu); - printf("%lx", (unsigned long) gpr_join_host_port); - printf("%lx", (unsigned long) gpr_split_host_port); printf("%lx", (unsigned long) gpr_log_severity_string); printf("%lx", (unsigned long) gpr_log); printf("%lx", (unsigned long) gpr_log_message); @@ -274,11 +244,6 @@ int main(int argc, char **argv) { printf("%lx", (unsigned long) gpr_set_log_function); printf("%lx", (unsigned long) gpr_strdup); printf("%lx", (unsigned long) gpr_asprintf); - printf("%lx", (unsigned long) gpr_subprocess_binary_extension); - printf("%lx", (unsigned long) gpr_subprocess_create); - printf("%lx", (unsigned long) gpr_subprocess_destroy); - printf("%lx", (unsigned long) gpr_subprocess_join); - printf("%lx", (unsigned long) gpr_subprocess_interrupt); printf("%lx", (unsigned long) gpr_mu_init); printf("%lx", (unsigned long) gpr_mu_destroy); printf("%lx", (unsigned long) gpr_mu_lock); diff --git a/test/core/surface/secure_channel_create_test.cc b/test/core/surface/secure_channel_create_test.cc index fa22cd6873..c10d6796a7 100644 --- a/test/core/surface/secure_channel_create_test.cc +++ b/test/core/surface/secure_channel_create_test.cc @@ -28,8 +28,8 @@ #include "test/core/util/test_config.h" void test_unknown_scheme_target(void) { - grpc_resolver_registry_shutdown(); - grpc_resolver_registry_init(); + grpc_core::ResolverRegistry::Builder::ShutdownRegistry(); + grpc_core::ResolverRegistry::Builder::InitRegistry(); grpc_channel_credentials* creds = grpc_fake_transport_security_credentials_create(); grpc_channel* chan = diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index ac49bd9823..1ac0a5ee13 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -19,11 +19,11 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/thd.h> #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index 96eaa6a7a9..f0412d01d9 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -19,9 +19,10 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/time.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/tsi/fake_transport_security.h" diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index 969b8cb11b..3b08efb563 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -19,9 +19,10 @@ #include <grpc/grpc.h> #include <grpc/grpc_security.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/port.h" diff --git a/test/core/transport/bdp_estimator_test.cc b/test/core/transport/bdp_estimator_test.cc index 3afcad7f17..c7e6b2bd84 100644 --- a/test/core/transport/bdp_estimator_test.cc +++ b/test/core/transport/bdp_estimator_test.cc @@ -22,10 +22,12 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> + #include <gtest/gtest.h> #include <limits.h> + #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/timer_manager.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/byte_stream_test.cc b/test/core/transport/byte_stream_test.cc index 2aab6e9262..6947d50976 100644 --- a/test/core/transport/byte_stream_test.cc +++ b/test/core/transport/byte_stream_test.cc @@ -21,8 +21,8 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc index d7d6ee7508..7fb395d4b6 100644 --- a/test/core/transport/chttp2/settings_timeout_test.cc +++ b/test/core/transport/chttp2/settings_timeout_test.cc @@ -169,7 +169,7 @@ class Client { grpc_closure* closure() { return &closure_; } - bool done() const { return done_; } + bool done() const { return gpr_atm_acq_load(&done_atm_) != 0; } // Caller does NOT take ownership of the error. grpc_error* error() const { return error_; } @@ -179,11 +179,11 @@ class Client { gpr_log(GPR_INFO, "OnEventDone(): %s", grpc_error_string(error)); EventState* state = (EventState*)arg; state->error_ = GRPC_ERROR_REF(error); - state->done_ = true; + gpr_atm_rel_store(&state->done_atm_, 1); } grpc_closure closure_; - bool done_ = false; + gpr_atm done_atm_ = 0; grpc_error* error_ = GRPC_ERROR_NONE; }; diff --git a/test/core/transport/pid_controller_test.cc b/test/core/transport/pid_controller_test.cc index 1a499c2fb7..8d2cec4042 100644 --- a/test/core/transport/pid_controller_test.cc +++ b/test/core/transport/pid_controller_test.cc @@ -24,7 +24,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> + #include <gtest/gtest.h> #include "src/core/lib/gpr/string.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc index e94be138dd..26e0785488 100644 --- a/test/core/transport/timeout_encoding_test.cc +++ b/test/core/transport/timeout_encoding_test.cc @@ -24,9 +24,10 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> + #include "src/core/lib/gpr/murmur_hash.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/core/util/test_config.h" #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc index 8939c0434b..bf54383c54 100644 --- a/test/core/tsi/ssl_transport_security_test.cc +++ b/test/core/tsi/ssl_transport_security_test.cc @@ -667,9 +667,15 @@ int main(int argc, char** argv) { ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain(); ssl_tsi_test_do_handshake_with_bad_server_cert(); ssl_tsi_test_do_handshake_with_bad_client_cert(); - ssl_tsi_test_do_handshake_alpn_client_no_server(); + // TODO: BoringSSL and OpenSSL have different behaviors on handling mismatched + // ALPN. Re-enable this test if we can detect in the runtime which SSL library + // is used. + // ssl_tsi_test_do_handshake_alpn_client_no_server(); ssl_tsi_test_do_handshake_alpn_server_no_client(); - ssl_tsi_test_do_handshake_alpn_client_server_mismatch(); + // TODO: BoringSSL and OpenSSL have different behaviors on handling mismatched + // ALPN. Re-enable this test if we can detect in the runtime which SSL library + // is used. + // ssl_tsi_test_do_handshake_alpn_client_server_mismatch(); ssl_tsi_test_do_handshake_alpn_client_server_ok(); ssl_tsi_test_do_round_trip_for_all_configs(); ssl_tsi_test_do_round_trip_odd_buffer_size(); diff --git a/test/core/tsi/transport_security_test.cc b/test/core/tsi/transport_security_test.cc index 42e17df25d..5c92912f6f 100644 --- a/test/core/tsi/transport_security_test.cc +++ b/test/core/tsi/transport_security_test.cc @@ -23,11 +23,11 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> #include <openssl/crypto.h> #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "src/core/tsi/fake_transport_security.h" #include "src/core/tsi/ssl_transport_security.h" #include "test/core/util/test_config.h" diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 2237cfc173..886cfddf86 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -51,6 +51,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_test_util_base", srcs = [ + "cmdline.cc", "grpc_profiler.cc", "histogram.cc", "mock_endpoint.cc", @@ -61,11 +62,14 @@ grpc_cc_library( "port_server_client.cc", "reconnect_server.cc", "slice_splitter.cc", + "subprocess_posix.cc", + "subprocess_windows.cc", "test_tcp_server.cc", "tracer_util.cc", "trickle_endpoint.cc", ], hdrs = [ + "cmdline.h", "grpc_profiler.h", "histogram.h", "mock_endpoint.h", @@ -74,6 +78,7 @@ grpc_cc_library( "port.h", "port_server_client.h", "reconnect_server.h", + "subprocess.h", "slice_splitter.h", "test_tcp_server.h", "tracer_util.h", @@ -109,6 +114,16 @@ grpc_cc_library( ], ) +grpc_cc_test( + name = "cmdline_test", + srcs = ["cmdline_test.cc"], + language = "C++", + deps = [ + ":grpc_test_util", + "//:gpr", + ], +) + grpc_cc_library( name = "fuzzer_corpus_test", testonly = 1, diff --git a/test/core/util/cmdline.cc b/test/core/util/cmdline.cc new file mode 100644 index 0000000000..20bce273cd --- /dev/null +++ b/test/core/util/cmdline.cc @@ -0,0 +1,330 @@ +/* + * + * Copyright 2015 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 "test/core/util/cmdline.h" + +#include <limits.h> +#include <stdio.h> +#include <string.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> +#include "src/core/lib/gpr/string.h" + +typedef enum { ARGTYPE_INT, ARGTYPE_BOOL, ARGTYPE_STRING } argtype; + +typedef struct arg { + const char* name; + const char* help; + argtype type; + void* value; + struct arg* next; +} arg; + +struct gpr_cmdline { + const char* description; + arg* args; + const char* argv0; + + const char* extra_arg_name; + const char* extra_arg_help; + void (*extra_arg)(void* user_data, const char* arg); + void* extra_arg_user_data; + + int (*state)(gpr_cmdline* cl, char* arg); + arg* cur_arg; + + int survive_failure; +}; + +static int normal_state(gpr_cmdline* cl, char* arg); + +gpr_cmdline* gpr_cmdline_create(const char* description) { + gpr_cmdline* cl = (gpr_cmdline*)gpr_zalloc(sizeof(gpr_cmdline)); + + cl->description = description; + cl->state = normal_state; + + return cl; +} + +void gpr_cmdline_set_survive_failure(gpr_cmdline* cl) { + cl->survive_failure = 1; +} + +void gpr_cmdline_destroy(gpr_cmdline* cl) { + while (cl->args) { + arg* a = cl->args; + cl->args = a->next; + gpr_free(a); + } + gpr_free(cl); +} + +static void add_arg(gpr_cmdline* cl, const char* name, const char* help, + argtype type, void* value) { + arg* a; + + for (a = cl->args; a; a = a->next) { + GPR_ASSERT(0 != strcmp(a->name, name)); + } + + a = (arg*)gpr_zalloc(sizeof(arg)); + a->name = name; + a->help = help; + a->type = type; + a->value = value; + a->next = cl->args; + cl->args = a; +} + +void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, + int* value) { + add_arg(cl, name, help, ARGTYPE_INT, value); +} + +void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, + int* value) { + add_arg(cl, name, help, ARGTYPE_BOOL, value); +} + +void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, + const char** value) { + add_arg(cl, name, help, ARGTYPE_STRING, value); +} + +void gpr_cmdline_on_extra_arg( + gpr_cmdline* cl, const char* name, const char* help, + void (*on_extra_arg)(void* user_data, const char* arg), void* user_data) { + GPR_ASSERT(!cl->extra_arg); + GPR_ASSERT(on_extra_arg); + + cl->extra_arg = on_extra_arg; + cl->extra_arg_user_data = user_data; + cl->extra_arg_name = name; + cl->extra_arg_help = help; +} + +/* 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(gpr_strvec* s, arg* a) { + char* tmp; + + if (!a) return; + add_args_to_usage(s, a->next); + + switch (a->type) { + case ARGTYPE_BOOL: + gpr_asprintf(&tmp, " [--%s|--no-%s]", a->name, a->name); + gpr_strvec_add(s, tmp); + break; + case ARGTYPE_STRING: + gpr_asprintf(&tmp, " [--%s=string]", a->name); + gpr_strvec_add(s, tmp); + break; + case ARGTYPE_INT: + gpr_asprintf(&tmp, " [--%s=int]", a->name); + gpr_strvec_add(s, tmp); + break; + } +} + +char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) { + /* TODO(ctiller): make this prettier */ + gpr_strvec s; + char* tmp; + const char* name = strrchr(argv0, '/'); + + if (name) { + name++; + } else { + name = argv0; + } + + gpr_strvec_init(&s); + + gpr_asprintf(&tmp, "Usage: %s", name); + gpr_strvec_add(&s, tmp); + add_args_to_usage(&s, cl->args); + if (cl->extra_arg) { + gpr_asprintf(&tmp, " [%s...]", cl->extra_arg_name); + gpr_strvec_add(&s, tmp); + } + gpr_strvec_add(&s, gpr_strdup("\n")); + + tmp = gpr_strvec_flatten(&s, nullptr); + gpr_strvec_destroy(&s); + return tmp; +} + +static int print_usage_and_die(gpr_cmdline* cl) { + char* usage = gpr_cmdline_usage_string(cl, cl->argv0); + fprintf(stderr, "%s", usage); + gpr_free(usage); + if (!cl->survive_failure) { + exit(1); + } + return 0; +} + +static int extra_state(gpr_cmdline* cl, char* str) { + if (!cl->extra_arg) { + return print_usage_and_die(cl); + } + cl->extra_arg(cl->extra_arg_user_data, str); + return 1; +} + +static arg* find_arg(gpr_cmdline* cl, char* name) { + arg* a; + + for (a = cl->args; a; a = a->next) { + if (0 == strcmp(a->name, name)) { + break; + } + } + + if (!a) { + fprintf(stderr, "Unknown argument: %s\n", name); + return nullptr; + } + + return a; +} + +static int value_state(gpr_cmdline* cl, char* str) { + long intval; + char* end; + + GPR_ASSERT(cl->cur_arg); + + switch (cl->cur_arg->type) { + case ARGTYPE_INT: + intval = strtol(str, &end, 0); + if (*end || intval < INT_MIN || intval > INT_MAX) { + fprintf(stderr, "expected integer, got '%s' for %s\n", str, + cl->cur_arg->name); + return print_usage_and_die(cl); + } + *(int*)cl->cur_arg->value = (int)intval; + break; + case ARGTYPE_BOOL: + if (0 == strcmp(str, "1") || 0 == strcmp(str, "true")) { + *(int*)cl->cur_arg->value = 1; + } else if (0 == strcmp(str, "0") || 0 == strcmp(str, "false")) { + *(int*)cl->cur_arg->value = 0; + } else { + fprintf(stderr, "expected boolean, got '%s' for %s\n", str, + cl->cur_arg->name); + return print_usage_and_die(cl); + } + break; + case ARGTYPE_STRING: + *(char**)cl->cur_arg->value = str; + break; + } + + cl->state = normal_state; + return 1; +} + +static int normal_state(gpr_cmdline* cl, char* str) { + char* eq = nullptr; + char* tmp = nullptr; + char* arg_name = nullptr; + int r = 1; + + if (0 == strcmp(str, "-help") || 0 == strcmp(str, "--help") || + 0 == strcmp(str, "-h")) { + return print_usage_and_die(cl); + } + + cl->cur_arg = nullptr; + + if (str[0] == '-') { + if (str[1] == '-') { + if (str[2] == 0) { + /* handle '--' to move to just extra args */ + cl->state = extra_state; + return 1; + } + str += 2; + } else { + str += 1; + } + /* first byte of str is now past the leading '-' or '--' */ + if (str[0] == 'n' && str[1] == 'o' && str[2] == '-') { + /* str is of the form '--no-foo' - it's a flag disable */ + str += 3; + cl->cur_arg = find_arg(cl, str); + if (cl->cur_arg == nullptr) { + return print_usage_and_die(cl); + } + if (cl->cur_arg->type != ARGTYPE_BOOL) { + fprintf(stderr, "%s is not a flag argument\n", str); + return print_usage_and_die(cl); + } + *(int*)cl->cur_arg->value = 0; + return 1; /* early out */ + } + eq = strchr(str, '='); + if (eq != nullptr) { + /* copy the string into a temp buffer and extract the name */ + tmp = arg_name = (char*)gpr_malloc((size_t)(eq - str + 1)); + memcpy(arg_name, str, (size_t)(eq - str)); + arg_name[eq - str] = 0; + } else { + arg_name = str; + } + cl->cur_arg = find_arg(cl, arg_name); + if (cl->cur_arg == nullptr) { + return print_usage_and_die(cl); + } + if (eq != nullptr) { + /* str was of the type --foo=value, parse the value */ + r = value_state(cl, eq + 1); + } else if (cl->cur_arg->type != ARGTYPE_BOOL) { + /* flag types don't have a '--foo value' variant, other types do */ + cl->state = value_state; + } else { + /* flag parameter: just set the value */ + *(int*)cl->cur_arg->value = 1; + } + } else { + r = extra_state(cl, str); + } + + gpr_free(tmp); + return r; +} + +int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv) { + int i; + + GPR_ASSERT(argc >= 1); + cl->argv0 = argv[0]; + + for (i = 1; i < argc; i++) { + if (!cl->state(cl, argv[i])) { + return 0; + } + } + return 1; +} diff --git a/test/core/util/cmdline.h b/test/core/util/cmdline.h new file mode 100644 index 0000000000..3ae35d6e6a --- /dev/null +++ b/test/core/util/cmdline.h @@ -0,0 +1,80 @@ +/* + * + * Copyright 2015 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_CMDLINE_H +#define GRPC_TEST_CORE_UTIL_CMDLINE_H + +#include <grpc/support/port_platform.h> + +/** Simple command line parser. + + Supports flags that can be specified as -foo, --foo, --no-foo, -no-foo, etc + And integers, strings that can be specified as -foo=4, -foo blah, etc + + No support for short command line options (but we may get that in the + future.) + + Usage (for a program with a single flag argument 'foo'): + + int main(int argc, char **argv) { + gpr_cmdline *cl; + int verbose = 0; + + cl = gpr_cmdline_create("My cool tool"); + gpr_cmdline_add_int(cl, "verbose", "Produce verbose output?", &verbose); + gpr_cmdline_parse(cl, argc, argv); + gpr_cmdline_destroy(cl); + + if (verbose) { + gpr_log(GPR_INFO, "Goodbye cruel world!"); + } + + return 0; + } */ + +typedef struct gpr_cmdline gpr_cmdline; + +/** Construct a command line parser: takes a short description of the tool + doing the parsing */ +gpr_cmdline* gpr_cmdline_create(const char* description); +/** Add an integer parameter, with a name (used on the command line) and some + helpful text (used in the command usage) */ +void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, const char* help, + int* value); +/** The same, for a boolean flag */ +void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, const char* help, + int* value); +/** And for a string */ +void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, const char* help, + const char** value); +/** Set a callback for non-named arguments */ +void gpr_cmdline_on_extra_arg( + gpr_cmdline* cl, const char* name, const char* help, + void (*on_extra_arg)(void* user_data, const char* arg), void* user_data); +/** Enable surviving failure: default behavior is to exit the process */ +void gpr_cmdline_set_survive_failure(gpr_cmdline* cl); +/** Parse the command line; returns 1 on success, on failure either dies + (by default) or returns 0 if gpr_cmdline_set_survive_failure() has been + called */ +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 */ +char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0); + +#endif /* GRPC_TEST_CORE_UTIL_CMDLINE_H */ diff --git a/test/core/gpr/cmdline_test.cc b/test/core/util/cmdline_test.cc index 172efda8a0..9f5ad88d57 100644 --- a/test/core/gpr/cmdline_test.cc +++ b/test/core/util/cmdline_test.cc @@ -16,13 +16,13 @@ * */ -#include <grpc/support/cmdline.h> - #include <string.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" +#include "test/core/util/cmdline.h" #include "test/core/util/test_config.h" #define LOG_TEST() gpr_log(GPR_INFO, "test at %s:%d", __FILE__, __LINE__) diff --git a/test/core/util/fuzzer_one_entry_runner.sh b/test/core/util/fuzzer_one_entry_runner.sh index 2634a1b3a9..7c471afcc2 100755 --- a/test/core/util/fuzzer_one_entry_runner.sh +++ b/test/core/util/fuzzer_one_entry_runner.sh @@ -15,4 +15,4 @@ # 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. -$1 $2 +"$1" "$2" diff --git a/test/core/util/histogram.cc b/test/core/util/histogram.cc index 2f916f831d..b2518279ac 100644 --- a/test/core/util/histogram.cc +++ b/test/core/util/histogram.cc @@ -16,6 +16,8 @@ * */ +#include "test/core/util/histogram.h" + #include <math.h> #include <stddef.h> #include <string.h> @@ -23,9 +25,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/port_platform.h> -#include <grpc/support/useful.h> -#include "test/core/util/histogram.h" +#include "src/core/lib/gpr/useful.h" /* Histograms are stored with exponentially increasing bucket sizes. The first bucket is [0, m) where m = 1 + resolution diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc index 5f127cb960..0da0765979 100644 --- a/test/core/util/passthru_endpoint.cc +++ b/test/core/util/passthru_endpoint.cc @@ -48,8 +48,6 @@ struct passthru_endpoint { gpr_mu mu; int halves; grpc_passthru_endpoint_stats* stats; - grpc_passthru_endpoint_stats - dummy_stats; // used if constructor stats == nullptr bool shutdown; half client; half server; @@ -137,6 +135,7 @@ static void me_destroy(grpc_endpoint* ep) { if (0 == --p->halves) { gpr_mu_unlock(&p->mu); gpr_mu_destroy(&p->mu); + grpc_passthru_endpoint_stats_destroy(p->stats); grpc_slice_buffer_destroy_internal(&p->client.read_buffer); grpc_slice_buffer_destroy_internal(&p->server.read_buffer); grpc_resource_user_unref(p->client.resource_user); @@ -194,11 +193,30 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client, passthru_endpoint* m = (passthru_endpoint*)gpr_malloc(sizeof(*m)); m->halves = 2; m->shutdown = 0; - m->stats = stats == nullptr ? &m->dummy_stats : stats; - memset(m->stats, 0, sizeof(*m->stats)); + if (stats == nullptr) { + m->stats = grpc_passthru_endpoint_stats_create(); + } else { + gpr_ref(&stats->refs); + m->stats = stats; + } half_init(&m->client, m, resource_quota, "client"); half_init(&m->server, m, resource_quota, "server"); gpr_mu_init(&m->mu); *client = &m->client.base; *server = &m->server.base; } + +grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create() { + grpc_passthru_endpoint_stats* stats = + (grpc_passthru_endpoint_stats*)gpr_malloc( + sizeof(grpc_passthru_endpoint_stats)); + memset(stats, 0, sizeof(*stats)); + gpr_ref_init(&stats->refs, 1); + return stats; +} + +void grpc_passthru_endpoint_stats_destroy(grpc_passthru_endpoint_stats* stats) { + if (gpr_unref(&stats->refs)) { + gpr_free(stats); + } +} diff --git a/test/core/util/passthru_endpoint.h b/test/core/util/passthru_endpoint.h index bddd8ea6a2..a46c775505 100644 --- a/test/core/util/passthru_endpoint.h +++ b/test/core/util/passthru_endpoint.h @@ -23,7 +23,11 @@ #include "src/core/lib/iomgr/endpoint.h" +/* The struct is refcounted, always use grpc_passthru_endpoint_stats_create and + * grpc_passthru_endpoint_stats_destroy, rather then embedding it in your + * objects by value. */ typedef struct { + gpr_refcount refs; gpr_atm num_writes; } grpc_passthru_endpoint_stats; @@ -32,4 +36,8 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client, grpc_resource_quota* resource_quota, grpc_passthru_endpoint_stats* stats); +grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create(); + +void grpc_passthru_endpoint_stats_destroy(grpc_passthru_endpoint_stats* stats); + #endif diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index bcafc4e898..b5a7749385 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -20,11 +20,12 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> #include <string.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/core/util/run_with_poller.sh b/test/core/util/run_with_poller.sh index 05791457a2..382a63e8ae 100755 --- a/test/core/util/run_with_poller.sh +++ b/test/core/util/run_with_poller.sh @@ -16,4 +16,4 @@ set -ex export GRPC_POLL_STRATEGY=$1 shift -$@ +"$@" diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc index 7225b6dc03..c92fc0affe 100644 --- a/test/core/util/slice_splitter.cc +++ b/test/core/util/slice_splitter.cc @@ -21,7 +21,8 @@ #include <string.h> #include <grpc/support/alloc.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode) { switch (mode) { diff --git a/test/core/util/subprocess.h b/test/core/util/subprocess.h new file mode 100644 index 0000000000..c7fe9af435 --- /dev/null +++ b/test/core/util/subprocess.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2015 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_SUBPROCESS_H +#define GRPC_TEST_CORE_UTIL_SUBPROCESS_H + +#include <grpc/support/port_platform.h> + +typedef struct gpr_subprocess gpr_subprocess; + +/** .exe on windows, empty on unices */ +const char* gpr_subprocess_binary_extension(); + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv); +/** if subprocess has not been joined, kill it */ +void gpr_subprocess_destroy(gpr_subprocess* p); +/** returns exit status; can be called at most once */ +int gpr_subprocess_join(gpr_subprocess* p); +void gpr_subprocess_interrupt(gpr_subprocess* p); + +#endif /* GRPC_TEST_CORE_UTIL_SUBPROCESS_H */ diff --git a/test/core/util/subprocess_posix.cc b/test/core/util/subprocess_posix.cc new file mode 100644 index 0000000000..0f6c99731f --- /dev/null +++ b/test/core/util/subprocess_posix.cc @@ -0,0 +1,99 @@ +/* + * + * Copyright 2015 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> + +#ifdef GPR_POSIX_SUBPROCESS + +#include <assert.h> +#include <errno.h> +#include <signal.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> + +#include "test/core/util/subprocess.h" + +struct gpr_subprocess { + int pid; + bool joined; +}; + +const char* gpr_subprocess_binary_extension() { return ""; } + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { + gpr_subprocess* r; + int pid; + char** exec_args; + + pid = fork(); + if (pid == -1) { + return nullptr; + } else if (pid == 0) { + exec_args = (char**)gpr_malloc(((size_t)argc + 1) * sizeof(char*)); + memcpy(exec_args, argv, (size_t)argc * sizeof(char*)); + exec_args[argc] = nullptr; + execv(exec_args[0], exec_args); + /* if we reach here, an error has occurred */ + gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno)); + _exit(1); + return nullptr; + } else { + r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess)); + r->pid = pid; + return r; + } +} + +void gpr_subprocess_destroy(gpr_subprocess* p) { + if (!p->joined) { + kill(p->pid, SIGKILL); + gpr_subprocess_join(p); + } + gpr_free(p); +} + +int gpr_subprocess_join(gpr_subprocess* p) { + int status; +retry: + if (waitpid(p->pid, &status, 0) == -1) { + if (errno == EINTR) { + goto retry; + } + gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid, + strerror(errno)); + return -1; + } + p->joined = true; + return status; +} + +void gpr_subprocess_interrupt(gpr_subprocess* p) { + if (!p->joined) { + kill(p->pid, SIGINT); + } +} + +#endif /* GPR_POSIX_SUBPROCESS */ diff --git a/test/core/util/subprocess_windows.cc b/test/core/util/subprocess_windows.cc new file mode 100644 index 0000000000..d3295244ea --- /dev/null +++ b/test/core/util/subprocess_windows.cc @@ -0,0 +1,126 @@ +/* + * + * Copyright 2016 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> + +#ifdef GPR_WINDOWS_SUBPROCESS + +#include <string.h> +#include <tchar.h> +#include <windows.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/string_windows.h" +#include "test/core/util/subprocess.h" + +struct gpr_subprocess { + PROCESS_INFORMATION pi; + int joined; + int interrupted; +}; + +const char* gpr_subprocess_binary_extension() { return ".exe"; } + +gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) { + gpr_subprocess* r; + + STARTUPINFO si; + PROCESS_INFORMATION pi; + + char* args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL); + TCHAR* args_tchar; + + args_tchar = gpr_char_to_tchar(args); + gpr_free(args); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + memset(&pi, 0, sizeof(pi)); + + if (!CreateProcess(NULL, args_tchar, NULL, NULL, FALSE, + CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { + gpr_free(args_tchar); + return NULL; + } + gpr_free(args_tchar); + + r = (gpr_subprocess*)gpr_malloc(sizeof(gpr_subprocess)); + memset(r, 0, sizeof(*r)); + r->pi = pi; + return r; +} + +void gpr_subprocess_destroy(gpr_subprocess* p) { + if (p) { + if (!p->joined) { + gpr_subprocess_interrupt(p); + gpr_subprocess_join(p); + } + if (p->pi.hProcess) { + CloseHandle(p->pi.hProcess); + } + if (p->pi.hThread) { + CloseHandle(p->pi.hThread); + } + gpr_free(p); + } +} + +int gpr_subprocess_join(gpr_subprocess* p) { + DWORD dwExitCode; + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + if (dwExitCode == STILL_ACTIVE) { + if (WaitForSingleObject(p->pi.hProcess, INFINITE) == WAIT_OBJECT_0) { + p->joined = 1; + goto getExitCode; + } + return -1; // failed to join + } else { + goto getExitCode; + } + } else { + return -1; // failed to get exit code + } + +getExitCode: + if (p->interrupted) { + return 0; + } + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + return (int)dwExitCode; + } else { + return -1; // failed to get exit code + } +} + +void gpr_subprocess_interrupt(gpr_subprocess* p) { + DWORD dwExitCode; + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + if (dwExitCode == STILL_ACTIVE) { + gpr_log(GPR_INFO, "sending ctrl-break"); + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, p->pi.dwProcessId); + p->joined = 1; + p->interrupted = 1; + } + } + return; +} + +#endif /* GPR_WINDOWS_SUBPROCESS */ diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 6b410440c2..e381be6842 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -29,6 +29,7 @@ #include "src/core/lib/gpr/env.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" int64_t g_fixture_slowdown_factor = 1; int64_t g_poller_slowdown_factor = 1; @@ -196,7 +197,6 @@ static void install_crash_handler() { #elif GPR_POSIX_CRASH_HANDLER #include <errno.h> #include <execinfo.h> -#include <grpc/support/useful.h> #include <stdio.h> #include <string.h> diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 5f6af4e707..b1b5297f29 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -22,11 +22,12 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/sync.h> #include <grpc/support/time.h> #include <string.h> + +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc index f95ed62463..54e1cf19c9 100644 --- a/test/core/util/trickle_endpoint.cc +++ b/test/core/util/trickle_endpoint.cc @@ -26,7 +26,8 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include <grpc/support/useful.h> + +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/slice/slice_internal.h" #define WRITE_BUFFER_SIZE (2 * 1024 * 1024) diff --git a/test/cpp/client/client_channel_stress_test.cc b/test/cpp/client/client_channel_stress_test.cc index 80d1583333..bb8553f56a 100644 --- a/test/cpp/client/client_channel_stress_test.cc +++ b/test/cpp/client/client_channel_stress_test.cc @@ -36,6 +36,7 @@ #include <grpc/support/time.h> #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "test/core/util/port.h" @@ -230,8 +231,7 @@ class ClientChannelStressTest { } grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response(response_generator_, - &fake_result); + response_generator_->SetResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -253,9 +253,10 @@ class ClientChannelStressTest { void CreateStub() { ChannelArguments args; - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); std::ostringstream uri; uri << "fake:///servername_not_used"; channel_ = @@ -298,7 +299,6 @@ class ClientChannelStressTest { for (size_t i = 0; i < backends_.size(); ++i) { backend_servers_[i].Shutdown(); } - grpc_fake_resolver_response_generator_unref(response_generator_); } std::atomic_bool shutdown_{false}; @@ -310,7 +310,8 @@ class ClientChannelStressTest { std::vector<std::unique_ptr<BalancerServiceImpl>> balancers_; std::vector<ServerThread<BackendServiceImpl>> backend_servers_; std::vector<ServerThread<BalancerServiceImpl>> balancer_servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator_; std::vector<std::thread> client_threads_; }; diff --git a/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj b/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..1d332ba7ce --- /dev/null +++ b/test/cpp/cocoapods/GRPCCppTests.xcodeproj/project.pbxproj @@ -0,0 +1,533 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 2D3F2189E2CDF493639A17C5 /* libPods-test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B1FD20127AB0F23D6AB570 /* libPods-test.a */; }; + 5E63948A1FDB64B50051E9AA /* server_context_test_spouse_test.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */; }; + 5EFA5F731FEDB36700EBF4B7 /* generic.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5EFA5F721FEDB36700EBF4B7 /* generic.mm */; }; + D0F8FABF3ECF587C207C12F3 /* libPods-generic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-generic.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E63947F1FDB5EA10051E9AA /* test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = test.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E6394831FDB5EA10051E9AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = server_context_test_spouse_test.mm; sourceTree = "<group>"; }; + 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = generic.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 5EFA5F721FEDB36700EBF4B7 /* generic.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = generic.mm; sourceTree = "<group>"; }; + 5EFA5F741FEDB36700EBF4B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.release.xcconfig"; path = "Pods/Target Support Files/Pods-test/Pods-test.release.xcconfig"; sourceTree = "<group>"; }; + 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-test.debug.xcconfig"; path = "Pods/Target Support Files/Pods-test/Pods-test.debug.xcconfig"; sourceTree = "<group>"; }; + 99B1FD20127AB0F23D6AB570 /* libPods-test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-test.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-generic.release.xcconfig"; path = "Pods/Target Support Files/Pods-generic/Pods-generic.release.xcconfig"; sourceTree = "<group>"; }; + D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-generic.debug.xcconfig"; path = "Pods/Target Support Files/Pods-generic/Pods-generic.debug.xcconfig"; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 5E63947C1FDB5EA10051E9AA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2D3F2189E2CDF493639A17C5 /* libPods-test.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EFA5F6D1FEDB36700EBF4B7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D0F8FABF3ECF587C207C12F3 /* libPods-generic.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4439BD4D56FD5738BF780F8E /* Pods */ = { + isa = PBXGroup; + children = ( + 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */, + 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */, + D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */, + B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */, + ); + name = Pods; + sourceTree = "<group>"; + }; + 5E63944B1FDB5D9B0051E9AA = { + isa = PBXGroup; + children = ( + 5E63947F1FDB5EA10051E9AA /* test.xctest */, + 5E6394801FDB5EA10051E9AA /* test */, + 4439BD4D56FD5738BF780F8E /* Pods */, + 5EFA5F711FEDB36700EBF4B7 /* generic */, + C2E6603B58413BD724AFB400 /* Frameworks */, + 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */, + ); + sourceTree = "<group>"; + }; + 5E6394801FDB5EA10051E9AA /* test */ = { + isa = PBXGroup; + children = ( + 5E6394891FDB64B50051E9AA /* server_context_test_spouse_test.mm */, + 5E6394831FDB5EA10051E9AA /* Info.plist */, + ); + path = test; + sourceTree = "<group>"; + }; + 5EFA5F711FEDB36700EBF4B7 /* generic */ = { + isa = PBXGroup; + children = ( + 5EFA5F721FEDB36700EBF4B7 /* generic.mm */, + 5EFA5F741FEDB36700EBF4B7 /* Info.plist */, + ); + path = generic; + sourceTree = "<group>"; + }; + C2E6603B58413BD724AFB400 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 99B1FD20127AB0F23D6AB570 /* libPods-test.a */, + 3D0872BAEE90C8A149743DB7 /* libPods-generic.a */, + ); + name = Frameworks; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 5E63947E1FDB5EA10051E9AA /* test */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5E6394841FDB5EA10051E9AA /* Build configuration list for PBXNativeTarget "test" */; + buildPhases = ( + 6D8317CF72F9E252442662F8 /* [CP] Check Pods Manifest.lock */, + 5E63947B1FDB5EA10051E9AA /* Sources */, + 5E63947C1FDB5EA10051E9AA /* Frameworks */, + 5E63947D1FDB5EA10051E9AA /* Resources */, + B972D278DA2A2BF12386177C /* [CP] Embed Pods Frameworks */, + 3C2FE7A8DBA8BBCB2923B173 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = test; + productName = test; + productReference = 5E63947F1FDB5EA10051E9AA /* test.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 5EFA5F6F1FEDB36700EBF4B7 /* generic */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5EFA5F751FEDB36700EBF4B7 /* Build configuration list for PBXNativeTarget "generic" */; + buildPhases = ( + 4844599DC62113265AB660B3 /* [CP] Check Pods Manifest.lock */, + 5EFA5F6C1FEDB36700EBF4B7 /* Sources */, + 5EFA5F6D1FEDB36700EBF4B7 /* Frameworks */, + 5EFA5F6E1FEDB36700EBF4B7 /* Resources */, + 11E4716E0919C734CC6AA8C2 /* [CP] Embed Pods Frameworks */, + 9E149E84C3AA06289FE1F244 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = generic; + productName = generic; + productReference = 5EFA5F701FEDB36700EBF4B7 /* generic.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 5E63944C1FDB5D9B0051E9AA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0910; + ORGANIZATIONNAME = gRPC; + TargetAttributes = { + 5E63947E1FDB5EA10051E9AA = { + CreatedOnToolsVersion = 9.1; + ProvisioningStyle = Automatic; + }; + 5EFA5F6F1FEDB36700EBF4B7 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 5E63944F1FDB5D9B0051E9AA /* Build configuration list for PBXProject "GRPCCppTests" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 5E63944B1FDB5D9B0051E9AA; + productRefGroup = 5E63944B1FDB5D9B0051E9AA; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 5E63947E1FDB5EA10051E9AA /* test */, + 5EFA5F6F1FEDB36700EBF4B7 /* generic */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 5E63947D1FDB5EA10051E9AA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EFA5F6E1FEDB36700EBF4B7 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 11E4716E0919C734CC6AA8C2 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-generic/Pods-generic-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 3C2FE7A8DBA8BBCB2923B173 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-test/Pods-test-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 4844599DC62113265AB660B3 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-generic-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 6D8317CF72F9E252442662F8 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-test-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 9E149E84C3AA06289FE1F244 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-generic/Pods-generic-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + B972D278DA2A2BF12386177C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-test/Pods-test-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 5E63947B1FDB5EA10051E9AA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E63948A1FDB64B50051E9AA /* server_context_test_spouse_test.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5EFA5F6C1FEDB36700EBF4B7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5EFA5F731FEDB36700EBF4B7 /* generic.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 5E6394731FDB5D9B0051E9AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ../../../include; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = ../../..; + }; + name = Debug; + }; + 5E6394741FDB5D9B0051E9AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ../../../include; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = ../../..; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 5E6394851FDB5EA10051E9AA /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 91EDF22ADDE71926C7BC1AF1 /* Pods-test.debug.xcconfig */; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = EQHXZ8M8AV; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/Headers/Public\"", + "\"${PODS_ROOT}/Headers/Public/BoringSSL\"", + "\"${PODS_ROOT}/Headers/Public/gRPC-C++\"", + "\"${PODS_ROOT}/Headers/Public/gRPC-Core\"", + "\"${PODS_ROOT}/Headers/Public/nanopb\"", + ); + INFOPLIST_FILE = test/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.test; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5E6394861FDB5EA10051E9AA /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8682448F311EDE94C14D551D /* Pods-test.release.xcconfig */; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = EQHXZ8M8AV; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/Headers/Public\"", + "\"${PODS_ROOT}/Headers/Public/BoringSSL\"", + "\"${PODS_ROOT}/Headers/Public/gRPC-C++\"", + "\"${PODS_ROOT}/Headers/Public/gRPC-Core\"", + "\"${PODS_ROOT}/Headers/Public/nanopb\"", + ); + INFOPLIST_FILE = test/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.test; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 5EFA5F761FEDB36700EBF4B7 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D9B4F77163CB9089C4436BF4 /* Pods-generic.debug.xcconfig */; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = EQHXZ8M8AV; + INFOPLIST_FILE = generic/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.generic; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5EFA5F771FEDB36700EBF4B7 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B357AF2DC912B224C026D114 /* Pods-generic.release.xcconfig */; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = EQHXZ8M8AV; + INFOPLIST_FILE = generic/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = io.grpc.generic; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 5E63944F1FDB5D9B0051E9AA /* Build configuration list for PBXProject "GRPCCppTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E6394731FDB5D9B0051E9AA /* Debug */, + 5E6394741FDB5D9B0051E9AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5E6394841FDB5EA10051E9AA /* Build configuration list for PBXNativeTarget "test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E6394851FDB5EA10051E9AA /* Debug */, + 5E6394861FDB5EA10051E9AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5EFA5F751FEDB36700EBF4B7 /* Build configuration list for PBXNativeTarget "generic" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5EFA5F761FEDB36700EBF4B7 /* Debug */, + 5EFA5F771FEDB36700EBF4B7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 5E63944C1FDB5D9B0051E9AA /* Project object */; +} diff --git a/test/cpp/cocoapods/Podfile b/test/cpp/cocoapods/Podfile new file mode 100644 index 0000000000..8d8cdaaadd --- /dev/null +++ b/test/cpp/cocoapods/Podfile @@ -0,0 +1,71 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' + +install! 'cocoapods', :deterministic_uuids => false + +# Location of gRPC's repo root relative to this file. +GRPC_LOCAL_SRC = '../../..' + +%w( + test + generic +).each do |target_name| + target target_name do + pod 'gRPC-Core', :path => GRPC_LOCAL_SRC + pod 'gRPC-Core/Tests', :path => GRPC_LOCAL_SRC + pod 'gRPC-C++', :path => GRPC_LOCAL_SRC + pod 'BoringSSL', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true + end +end + +# gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's +# pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded +# and before they are installed in the user project. +# +# This podspec searches for the gRPC core library headers under "$(PODS_ROOT)/gRPC-Core", where +# Cocoapods normally places the downloaded sources. When doing local development of the libraries, +# though, Cocoapods just takes the sources from whatever directory was specified using `:path`, and +# doesn't copy them under $(PODS_ROOT). When using static libraries, one can sometimes rely on the +# symbolic links to the pods headers that Cocoapods creates under "$(PODS_ROOT)/Headers". But those +# aren't created when using dynamic frameworks. So our solution is to modify the podspec on the fly +# to point at the local directory where the sources are. +# +# TODO(jcanizales): Send a PR to Cocoapods to get rid of this need. +pre_install do |installer| + # This is the gRPC-Core podspec object, as initialized by its podspec file. + grpc_core_spec = installer.pod_targets.find{|t| t.name == 'gRPC-Core'}.root_spec + + # Copied from gRPC-Core.podspec, except for the adjusted src_root: + src_root = "$(PODS_ROOT)/../#{GRPC_LOCAL_SRC}" + grpc_core_spec.pod_target_xcconfig = { + 'GRPC_SRC_ROOT' => src_root, + 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', + 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', + # If we don't set these two settings, `include/grpc/support/time.h` and + # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the + # build. + 'USE_HEADERMAP' => 'NO', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + } +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'YES' + end + + # CocoaPods creates duplicated library targets of gRPC-Core when the test targets include + # non-default subspecs of gRPC-Core. All of these library targets start with prefix 'gRPC-Core' + # and require the same error suppresion. + if target.name.start_with?('gRPC-Core') + target.build_configurations.each do |config| + # TODO(zyc): Remove this setting after the issue is resolved + # GPR_UNREACHABLE_CODE causes "Control may reach end of non-void + # function" warning + config.build_settings['GCC_WARN_ABOUT_RETURN_TYPE'] = 'NO' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) COCOAPODS=1 GRPC_CRONET_WITH_PACKET_COALESCING=1' + end + end + end +end diff --git a/test/cpp/cocoapods/generic/Info.plist b/test/cpp/cocoapods/generic/Info.plist new file mode 100644 index 0000000000..6c40a6cd0c --- /dev/null +++ b/test/cpp/cocoapods/generic/Info.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> +</dict> +</plist> diff --git a/test/cpp/cocoapods/generic/generic.mm b/test/cpp/cocoapods/generic/generic.mm new file mode 100644 index 0000000000..30b43ec375 --- /dev/null +++ b/test/cpp/cocoapods/generic/generic.mm @@ -0,0 +1,244 @@ +/* + * + * Copyright 2017 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. + * + */ + +#import <XCTest/XCTest.h> + +#include <sstream> + +#include <grpc++/channel.h> +#include <grpc++/client_context.h> +#include <grpc++/create_channel.h> +#include <grpc++/generic/async_generic_service.h> +#include <grpc++/generic/generic_stub.h> +#include <grpc++/server.h> +#include <grpc++/server_builder.h> +#include <grpc++/server_context.h> +#include <grpc++/support/slice.h> +#include <grpc/grpc.h> +#include <grpc/support/thd.h> +#include <grpc/support/time.h> + +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" + +using std::chrono::system_clock; +using namespace grpc; + +void* tag(int i) { return (void*)(intptr_t)i; } + +static grpc_slice merge_slices(grpc_slice* slices, size_t nslices) { + size_t i; + size_t len = 0; + uint8_t* cursor; + grpc_slice out; + + for (i = 0; i < nslices; i++) { + len += GRPC_SLICE_LENGTH(slices[i]); + } + + out = grpc_slice_malloc(len); + cursor = GRPC_SLICE_START_PTR(out); + + for (i = 0; i < nslices; i++) { + memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]), + GRPC_SLICE_LENGTH(slices[i])); + cursor += GRPC_SLICE_LENGTH(slices[i]); + } + + return out; +} + +int byte_buffer_eq_string(ByteBuffer* bb, const char* str) { + int res; + + std::vector<Slice> slices; + bb->Dump(&slices); + grpc_slice* c_slices = new grpc_slice[slices.size()]; + for (int i = 0; i < slices.size(); i++) { + c_slices[i] = slices[i].c_slice(); + } + grpc_slice a = merge_slices(c_slices, slices.size()); + grpc_slice b = grpc_slice_from_copied_string(str); + res = + (GRPC_SLICE_LENGTH(a) == GRPC_SLICE_LENGTH(b)) && + (0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b), + GRPC_SLICE_LENGTH(a))); + grpc_slice_unref(a); + grpc_slice_unref(b); + for (int i = 0; i < slices.size(); i++) { + grpc_slice_unref(c_slices[i]); + } + delete [] c_slices; + + return res; +} + +@interface GenericTest : XCTestCase + +@end + +@implementation GenericTest { + grpc::string server_host_; + CompletionQueue cli_cq_; + std::unique_ptr<ServerCompletionQueue> srv_cq_; + std::unique_ptr<GenericStub> generic_stub_; + std::unique_ptr<Server> server_; + AsyncGenericService generic_service_; + std::ostringstream server_address_; +} + +- (void)verify_ok:(grpc::CompletionQueue*)cq + i:(int)i + expect_ok:(bool)expect_ok { + bool ok; + void* got_tag; + XCTAssertTrue(cq->Next(&got_tag, &ok)); + XCTAssertEqual(expect_ok, ok); + XCTAssertEqual(tag(i), got_tag); +} + +- (void)server_ok:(int)i { [self verify_ok:srv_cq_.get() i:i expect_ok:true]; } +- (void)client_ok:(int)i { [self verify_ok:&cli_cq_ i:i expect_ok:true]; } +- (void)server_fail:(int)i { [self verify_ok:srv_cq_.get() i:i expect_ok:false]; } +- (void)client_fail:(int)i { [self verify_ok:&cli_cq_ i:i expect_ok:false]; } + +- (void)setUp { + [super setUp]; + + server_host_ = "localhost"; + int port = grpc_pick_unused_port_or_die(); + server_address_ << server_host_ << ":" << port; + // Setup server + ServerBuilder builder; + builder.AddListeningPort(server_address_.str(), + InsecureServerCredentials()); + builder.RegisterAsyncGenericService(&generic_service_); + // Include a second call to RegisterAsyncGenericService to make sure that + // we get an error in the log, since it is not allowed to have 2 async + // generic services + builder.RegisterAsyncGenericService(&generic_service_); + srv_cq_ = builder.AddCompletionQueue(); + server_ = builder.BuildAndStart(); +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + server_->Shutdown(); + void* ignored_tag; + bool ignored_ok; + cli_cq_.Shutdown(); + srv_cq_->Shutdown(); + while (cli_cq_.Next(&ignored_tag, &ignored_ok)); + while (srv_cq_->Next(&ignored_tag, &ignored_ok)); + [super tearDown]; +} + +- (void)ResetStub { + std::shared_ptr<Channel> channel = + CreateChannel(server_address_.str(), InsecureChannelCredentials()); + generic_stub_.reset(new GenericStub(channel)); +} + +- (void)SendRpc:(int)num_rpcs { + [self SendRpc:num_rpcs check_deadline:false deadline:gpr_inf_future(GPR_CLOCK_MONOTONIC)]; + } + +- (void)SendRpc:(int)num_rpcs + check_deadline:(bool)check_deadline + deadline:(gpr_timespec)deadline { + const grpc::string kMethodName("/grpc.cpp.test.util.EchoTestService/Echo"); + for (int i = 0; i < num_rpcs; i++) { + Status recv_status; + + ClientContext cli_ctx; + GenericServerContext srv_ctx; + GenericServerAsyncReaderWriter stream(&srv_ctx); + + // The string needs to be long enough to test heap-based slice. + /*send_request.set_message("Hello world. Hello world. Hello world.");*/ + + if (check_deadline) { + cli_ctx.set_deadline(deadline); + } + + std::unique_ptr<GenericClientAsyncReaderWriter> call = + generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1)); + [self client_ok:1]; + Slice send_slice = Slice("hello world", 11); + std::unique_ptr<ByteBuffer> send_buffer = + std::unique_ptr<ByteBuffer>(new ByteBuffer(&send_slice, 1)); + call->Write(*send_buffer, tag(2)); + // Send ByteBuffer can be destroyed after calling Write. + send_buffer.reset(); + [self client_ok:2]; + call->WritesDone(tag(3)); + [self client_ok:3]; + + generic_service_.RequestCall(&srv_ctx, &stream, srv_cq_.get(), + srv_cq_.get(), tag(4)); + + [self verify_ok:srv_cq_.get() i:4 expect_ok:true]; + XCTAssertEqual(server_host_, srv_ctx.host().substr(0, server_host_.length())); + XCTAssertEqual(kMethodName, srv_ctx.method()); + + if (check_deadline) { + XCTAssertTrue(gpr_time_similar(deadline, srv_ctx.raw_deadline(), + gpr_time_from_millis(1000, GPR_TIMESPAN))); + } + + ByteBuffer recv_buffer; + stream.Read(&recv_buffer, tag(5)); + [self server_ok:5]; + XCTAssertTrue(byte_buffer_eq_string(&recv_buffer, "hello world")); + + send_buffer = std::unique_ptr<ByteBuffer>(new ByteBuffer(recv_buffer)); + stream.Write(*send_buffer, tag(6)); + send_buffer.reset(); + [self server_ok:6]; + + stream.Finish(Status::OK, tag(7)); + [self server_ok:7]; + + recv_buffer.Clear(); + call->Read(&recv_buffer, tag(8)); + [self client_ok:8]; + XCTAssertTrue(byte_buffer_eq_string(&recv_buffer, "hello world")); + + call->Finish(&recv_status, tag(9)); + [self client_ok:9]; + + XCTAssertTrue(recv_status.ok()); + } +} + +- (void)testSimpleRpc { + [self ResetStub]; + [self SendRpc:1]; +} + +- (void)testSequentialRpcs { + [self ResetStub]; + [self SendRpc:10]; +} + ++ (void)setUp { + grpc_test_init(0, NULL); +} + +@end + diff --git a/test/cpp/cocoapods/test/Info.plist b/test/cpp/cocoapods/test/Info.plist new file mode 100644 index 0000000000..6c40a6cd0c --- /dev/null +++ b/test/cpp/cocoapods/test/Info.plist @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> +</dict> +</plist> diff --git a/test/cpp/cocoapods/test/server_context_test_spouse_test.mm b/test/cpp/cocoapods/test/server_context_test_spouse_test.mm new file mode 100644 index 0000000000..fd6878efbf --- /dev/null +++ b/test/cpp/cocoapods/test/server_context_test_spouse_test.mm @@ -0,0 +1,100 @@ +/* + * + * Copyright 2016 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. + * + */ + +// Hack TEST macro of gTest and make they conform XCTest style. We only +// need test name (b), not test case name (a). +#define TEST(a,b) - (void)test ## b +#define ASSERT_TRUE XCTAssert +#define ASSERT_EQ XCTAssertEqual + +#import <XCTest/XCTest.h> + +#include <grpc++/test/server_context_test_spouse.h> + +#include <cstring> +#include <vector> + +#include <grpc++/impl/grpc_library.h> + +static grpc::internal::GrpcLibraryInitializer g_initializer; + +const char key1[] = "metadata-key1"; +const char key2[] = "metadata-key2"; +const char val1[] = "metadata-val1"; +const char val2[] = "metadata-val2"; + +bool ClientMetadataContains(const grpc::ServerContext& context, + const grpc::string_ref& key, + const grpc::string_ref& value) { + const auto& client_metadata = context.client_metadata(); + for (auto iter = client_metadata.begin(); iter != client_metadata.end(); + ++iter) { + if (iter->first == key && iter->second == value) { + return true; + } + } + return false; +} + +@interface ServerContextTestSpouseTest : XCTestCase + +@end + +@implementation ServerContextTestSpouseTest + +TEST(ServerContextTestSpouseTest, ClientMetadata) { + grpc::ServerContext context; + grpc::testing::ServerContextTestSpouse spouse(&context); + + spouse.AddClientMetadata(key1, val1); + ASSERT_TRUE(ClientMetadataContains(context, key1, val1)); + + spouse.AddClientMetadata(key2, val2); + ASSERT_TRUE(ClientMetadataContains(context, key1, val1)); + ASSERT_TRUE(ClientMetadataContains(context, key2, val2)); +} + +TEST(ServerContextTestSpouseTest, InitialMetadata) { + grpc::ServerContext context; + grpc::testing::ServerContextTestSpouse spouse(&context); + std::multimap<grpc::string, grpc::string> metadata; + + context.AddInitialMetadata(key1, val1); + metadata.insert(std::pair<grpc::string, grpc::string>(key1, val1)); + ASSERT_EQ(metadata, spouse.GetInitialMetadata()); + + context.AddInitialMetadata(key2, val2); + metadata.insert(std::pair<grpc::string, grpc::string>(key2, val2)); + ASSERT_EQ(metadata, spouse.GetInitialMetadata()); +} + +TEST(ServerContextTestSpouseTest, TrailingMetadata) { + grpc::ServerContext context; + grpc::testing::ServerContextTestSpouse spouse(&context); + std::multimap<grpc::string, grpc::string> metadata; + + context.AddTrailingMetadata(key1, val1); + metadata.insert(std::pair<grpc::string, grpc::string>(key1, val1)); + ASSERT_EQ(metadata, spouse.GetTrailingMetadata()); + + context.AddTrailingMetadata(key2, val2); + metadata.insert(std::pair<grpc::string, grpc::string>(key2, val2)); + ASSERT_EQ(metadata, spouse.GetTrailingMetadata()); +} + +@end diff --git a/test/cpp/common/BUILD b/test/cpp/common/BUILD index e2b6365b13..2cf3ad669f 100644 --- a/test/cpp/common/BUILD +++ b/test/cpp/common/BUILD @@ -19,8 +19,8 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") grpc_package(name = "test/cpp/common") grpc_cc_test( - name = "alarm_cpp_test", - srcs = ["alarm_cpp_test.cc"], + name = "alarm_test", + srcs = ["alarm_test.cc"], deps = [ "//:grpc++_unsecure", "//test/core/util:gpr_test_util", diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_test.cc index 7adc3102f4..2a933a84c4 100644 --- a/test/cpp/common/alarm_cpp_test.cc +++ b/test/cpp/common/alarm_test.cc @@ -182,6 +182,29 @@ TEST(AlarmTest, Cancellation) { EXPECT_EQ(junk, output_tag); } +TEST(AlarmTest, SetDestruction) { + CompletionQueue cq; + void* junk = reinterpret_cast<void*>(1618033); + { + Alarm alarm; + alarm.Set(&cq, grpc_timeout_seconds_to_deadline(2), junk); + } + + void* output_tag; + bool ok; + const CompletionQueue::NextStatus status = cq.AsyncNext( + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1)); + + EXPECT_EQ(status, CompletionQueue::GOT_EVENT); + EXPECT_FALSE(ok); + EXPECT_EQ(junk, output_tag); +} + +TEST(AlarmTest, UnsetDestruction) { + CompletionQueue cq; + Alarm alarm; +} + } // namespace } // namespace grpc diff --git a/test/cpp/common/channel_arguments_test.cc b/test/cpp/common/channel_arguments_test.cc index f330c01281..29e225d924 100644 --- a/test/cpp/common/channel_arguments_test.cc +++ b/test/cpp/common/channel_arguments_test.cc @@ -20,9 +20,9 @@ #include <grpc++/grpc++.h> #include <grpc/grpc.h> -#include <grpc/support/useful.h> #include <gtest/gtest.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/socket_mutator.h" diff --git a/test/cpp/end2end/BUILD b/test/cpp/end2end/BUILD index 8894c68b95..27e8da1ff1 100644 --- a/test/cpp/end2end/BUILD +++ b/test/cpp/end2end/BUILD @@ -120,6 +120,24 @@ grpc_cc_library( ) grpc_cc_test( + name = "server_early_return_test", + srcs = ["server_early_return_test.cc"], + external_deps = [ + "gtest", + ], + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/proto/grpc/testing:echo_messages_proto", + "//src/proto/grpc/testing:echo_proto", + "//test/core/util:gpr_test_util", + "//test/core/util:grpc_test_util", + "//test/cpp/util:test_util", + ], +) + +grpc_cc_test( name = "end2end_test", deps = [ ":end2end_test_lib", diff --git a/test/cpp/end2end/OWNERS b/test/cpp/end2end/OWNERS new file mode 100644 index 0000000000..d87b3286a5 --- /dev/null +++ b/test/cpp/end2end/OWNERS @@ -0,0 +1,5 @@ +set noparent +@vjpai +@yang-g +@y-zeng + diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 44cd81a6a4..482f0cb24f 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -32,9 +32,9 @@ #include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/time.h> -#include <grpc/support/tls.h> #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/tls.h" #include "src/core/lib/iomgr/port.h" #include "src/proto/grpc/health/v1/health.grpc.pb.h" #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 328ad86061..386d18e95d 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -39,6 +39,8 @@ #include "src/core/ext/filters/client_channel/subchannel_index.h" #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/util/port.h" @@ -118,11 +120,11 @@ class ClientLbEnd2endTest : public ::testing::Test { } void SetUp() override { - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); } void TearDown() override { - grpc_fake_resolver_response_generator_unref(response_generator_); for (size_t i = 0; i < servers_.size(); ++i) { servers_[i]->Shutdown(); } @@ -152,13 +154,30 @@ class ClientLbEnd2endTest : public ::testing::Test { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } - const grpc_arg fake_addresses = - grpc_lb_addresses_create_channel_arg(addresses); - grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); - grpc_fake_resolver_response_generator_set_response(response_generator_, - fake_result); - grpc_channel_args_destroy(fake_result); + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetResponse(&fake_result); + grpc_lb_addresses_destroy(addresses); + } + + void SetNextResolutionUponError(const std::vector<int>& ports) { + grpc_core::ExecCtx exec_ctx; + grpc_lb_addresses* addresses = + grpc_lb_addresses_create(ports.size(), nullptr); + for (size_t i = 0; i < ports.size(); ++i) { + char* lb_uri_str; + gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", ports[i]); + grpc_uri* lb_uri = grpc_uri_parse(lb_uri_str, true); + GPR_ASSERT(lb_uri != nullptr); + grpc_lb_addresses_set_address_from_uri(addresses, i, lb_uri, + false /* is balancer */, + "" /* balancer name */, nullptr); + grpc_uri_destroy(lb_uri); + gpr_free(lb_uri_str); + } + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetReresolutionResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -168,39 +187,51 @@ class ClientLbEnd2endTest : public ::testing::Test { return ports; } - void ResetStub(const std::vector<int>& ports, - const grpc::string& lb_policy_name, - ChannelArguments args = ChannelArguments()) { + std::unique_ptr<grpc::testing::EchoTestService::Stub> BuildStub( + const std::shared_ptr<Channel>& channel) { + return grpc::testing::EchoTestService::NewStub(channel); + } + + std::shared_ptr<Channel> BuildChannel( + const grpc::string& lb_policy_name, + ChannelArguments args = ChannelArguments()) { if (lb_policy_name.size() > 0) { args.SetLoadBalancingPolicyName(lb_policy_name); } // else, default to pick first args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); - channel_ = - CreateCustomChannel("fake:///", InsecureChannelCredentials(), args); - stub_ = grpc::testing::EchoTestService::NewStub(channel_); + response_generator_.get()); + return CreateCustomChannel("fake:///", InsecureChannelCredentials(), args); } - bool SendRpc(EchoResponse* response = nullptr) { + bool SendRpc( + const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, + EchoResponse* response = nullptr, int timeout_ms = 1000) { const bool local_response = (response == nullptr); if (local_response) response = new EchoResponse; EchoRequest request; request.set_message(kRequestMessage_); ClientContext context; - Status status = stub_->Echo(&context, request, response); + context.set_deadline(grpc_timeout_milliseconds_to_deadline(timeout_ms)); + Status status = stub->Echo(&context, request, response); if (local_response) delete response; return status.ok(); } - void CheckRpcSendOk() { + void CheckRpcSendOk( + const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, + const grpc_core::DebugLocation& location) { EchoResponse response; - const bool success = SendRpc(&response); - EXPECT_TRUE(success); - EXPECT_EQ(response.message(), kRequestMessage_); + const bool success = SendRpc(stub, &response); + if (!success) abort(); + ASSERT_TRUE(success) << "From " << location.file() << ":" + << location.line(); + ASSERT_EQ(response.message(), kRequestMessage_) + << "From " << location.file() << ":" << location.line(); } - void CheckRpcSendFailure() { - const bool success = SendRpc(); + void CheckRpcSendFailure( + const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub) { + const bool success = SendRpc(stub); EXPECT_FALSE(success); } @@ -239,7 +270,7 @@ class ClientLbEnd2endTest : public ::testing::Test { } void Shutdown(bool join = true) { - server_->Shutdown(); + server_->Shutdown(grpc_timeout_milliseconds_to_deadline(0)); if (join) thread_->join(); } }; @@ -248,9 +279,11 @@ class ClientLbEnd2endTest : public ::testing::Test { for (const auto& server : servers_) server->service_.ResetCounters(); } - void WaitForServer(size_t server_idx) { + void WaitForServer( + const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub, + size_t server_idx, const grpc_core::DebugLocation& location) { do { - CheckRpcSendOk(); + CheckRpcSendOk(stub, location); } while (servers_[server_idx]->service_.request_count() == 0); ResetCounters(); } @@ -281,10 +314,10 @@ class ClientLbEnd2endTest : public ::testing::Test { } const grpc::string server_host_; - std::shared_ptr<Channel> channel_; std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; std::vector<std::unique_ptr<ServerData>> servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator_; const grpc::string kRequestMessage_; }; @@ -292,14 +325,15 @@ TEST_F(ClientLbEnd2endTest, PickFirst) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), ""); // test that pick first is the default. + auto channel = BuildChannel(""); // test that pick first is the default. + auto stub = BuildStub(channel); std::vector<int> ports; for (size_t i = 0; i < servers_.size(); ++i) { ports.emplace_back(servers_[i]->port_); } SetNextResolution(ports); for (size_t i = 0; i < servers_.size(); ++i) { - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); } // All requests should have gone to a single server. bool found = false; @@ -313,7 +347,7 @@ TEST_F(ClientLbEnd2endTest, PickFirst) { } EXPECT_TRUE(found); // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) { @@ -322,15 +356,16 @@ TEST_F(ClientLbEnd2endTest, PickFirstBackOffInitialReconnect) { args.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, kInitialBackOffMs); const std::vector<int> ports = {grpc_pick_unused_port_or_die()}; const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - ResetStub(ports, "pick_first", args); + auto channel = BuildChannel("pick_first", args); + auto stub = BuildStub(channel); SetNextResolution(ports); // The channel won't become connected (there's no server). - ASSERT_FALSE(channel_->WaitForConnected( + ASSERT_FALSE(channel->WaitForConnected( grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2))); // Bring up a server on the chosen port. StartServers(1, ports); // Now it will. - ASSERT_TRUE(channel_->WaitForConnected( + ASSERT_TRUE(channel->WaitForConnected( grpc_timeout_milliseconds_to_deadline(kInitialBackOffMs * 2))); const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC); const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0)); @@ -350,14 +385,15 @@ TEST_F(ClientLbEnd2endTest, PickFirstBackOffMinReconnect) { constexpr int kMinReconnectBackOffMs = 1000; args.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, kMinReconnectBackOffMs); const std::vector<int> ports = {grpc_pick_unused_port_or_die()}; - ResetStub(ports, "pick_first", args); + auto channel = BuildChannel("pick_first", args); + auto stub = BuildStub(channel); SetNextResolution(ports); // Make connection delay a 10% longer than it's willing to in order to make // sure we are hitting the codepath that waits for the min reconnect backoff. gpr_atm_rel_store(&g_connection_delay_ms, kMinReconnectBackOffMs * 1.10); grpc_tcp_client_connect_impl = tcp_client_connect_with_delay; const gpr_timespec t0 = gpr_now(GPR_CLOCK_MONOTONIC); - channel_->WaitForConnected( + channel->WaitForConnected( grpc_timeout_milliseconds_to_deadline(kMinReconnectBackOffMs * 2)); const gpr_timespec t1 = gpr_now(GPR_CLOCK_MONOTONIC); const grpc_millis waited_ms = gpr_time_to_millis(gpr_time_sub(t1, t0)); @@ -372,14 +408,16 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "pick_first"); + auto channel = BuildChannel("pick_first"); + auto stub = BuildStub(channel); + std::vector<int> ports; // Perform one RPC against the first server. ports.emplace_back(servers_[0]->port_); SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [0] *******"); - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 1); // An empty update will result in the channel going into TRANSIENT_FAILURE. @@ -388,7 +426,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { gpr_log(GPR_INFO, "****** SET none *******"); grpc_connectivity_state channel_state; do { - channel_state = channel_->GetState(true /* try to connect */); + channel_state = channel->GetState(true /* try to connect */); } while (channel_state == GRPC_CHANNEL_READY); GPR_ASSERT(channel_state != GRPC_CHANNEL_READY); servers_[0]->service_.ResetCounters(); @@ -398,7 +436,7 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { ports.emplace_back(servers_[1]->port_); SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [1] *******"); - WaitForServer(1); + WaitForServer(stub, 1, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 0); // And again for servers_[2] @@ -406,26 +444,28 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdates) { ports.emplace_back(servers_[2]->port_); SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [2] *******"); - WaitForServer(2); + WaitForServer(stub, 2, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 0); EXPECT_EQ(servers_[1]->service_.request_count(), 0); // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "pick_first"); + auto channel = BuildChannel("pick_first"); + auto stub = BuildStub(channel); + std::vector<int> ports; // Perform one RPC against the first server. ports.emplace_back(servers_[0]->port_); SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET [0] *******"); - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(servers_[0]->service_.request_count(), 1); servers_[0]->service_.ResetCounters(); @@ -435,20 +475,21 @@ TEST_F(ClientLbEnd2endTest, PickFirstUpdateSuperset) { ports.emplace_back(servers_[0]->port_); SetNextResolution(ports); gpr_log(GPR_INFO, "****** SET superset *******"); - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); // We stick to the previously connected server. - WaitForServer(0); + WaitForServer(stub, 0, DEBUG_LOCATION); EXPECT_EQ(0, servers_[1]->service_.request_count()); // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "pick_first"); + auto channel = BuildChannel("pick_first"); + auto stub = BuildStub(channel); std::vector<int> ports; for (size_t i = 0; i < servers_.size(); ++i) { ports.emplace_back(servers_[i]->port_); @@ -460,18 +501,19 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) { std::shuffle(ports.begin(), ports.end(), std::mt19937(std::random_device()())); SetNextResolution(ports); - if (i % 10 == 0) CheckRpcSendOk(); + if (i % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION); } } // Check LB policy name for the channel. - EXPECT_EQ("pick_first", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("pick_first", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, RoundRobin) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "round_robin"); + auto channel = BuildChannel("round_robin"); + auto stub = BuildStub(channel); std::vector<int> ports; for (const auto& server : servers_) { ports.emplace_back(server->port_); @@ -479,15 +521,15 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) { SetNextResolution(ports); // Wait until all backends are ready. do { - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); } while (!SeenAllServers()); ResetCounters(); // "Sync" to the end of the list. Next sequence of picks will start at the // first server (index 0). - WaitForServer(servers_.size() - 1); + WaitForServer(stub, servers_.size() - 1, DEBUG_LOCATION); std::vector<int> connection_order; for (size_t i = 0; i < servers_.size(); ++i) { - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); UpdateConnectionOrder(servers_, &connection_order); } // Backends should be iterated over in the order in which the addresses were @@ -495,22 +537,23 @@ TEST_F(ClientLbEnd2endTest, RoundRobin) { const auto expected = std::vector<int>{0, 1, 2}; EXPECT_EQ(expected, connection_order); // Check LB policy name for the channel. - EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "round_robin"); + auto channel = BuildChannel("round_robin"); + auto stub = BuildStub(channel); std::vector<int> ports; // Start with a single server. ports.emplace_back(servers_[0]->port_); SetNextResolution(ports); - WaitForServer(0); + WaitForServer(stub, 0, DEBUG_LOCATION); // Send RPCs. They should all go servers_[0] - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(); + for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(10, servers_[0]->service_.request_count()); EXPECT_EQ(0, servers_[1]->service_.request_count()); EXPECT_EQ(0, servers_[2]->service_.request_count()); @@ -524,9 +567,9 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { // Wait until update has been processed, as signaled by the second backend // receiving a request. EXPECT_EQ(0, servers_[1]->service_.request_count()); - WaitForServer(1); + WaitForServer(stub, 1, DEBUG_LOCATION); - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(); + for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(0, servers_[0]->service_.request_count()); EXPECT_EQ(10, servers_[1]->service_.request_count()); EXPECT_EQ(0, servers_[2]->service_.request_count()); @@ -536,9 +579,9 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { ports.clear(); ports.emplace_back(servers_[2]->port_); SetNextResolution(ports); - WaitForServer(2); + WaitForServer(stub, 2, DEBUG_LOCATION); - for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(); + for (size_t i = 0; i < 10; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(0, servers_[0]->service_.request_count()); EXPECT_EQ(0, servers_[1]->service_.request_count()); EXPECT_EQ(10, servers_[2]->service_.request_count()); @@ -550,12 +593,12 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { ports.emplace_back(servers_[1]->port_); ports.emplace_back(servers_[2]->port_); SetNextResolution(ports); - WaitForServer(0); - WaitForServer(1); - WaitForServer(2); + WaitForServer(stub, 0, DEBUG_LOCATION); + WaitForServer(stub, 1, DEBUG_LOCATION); + WaitForServer(stub, 2, DEBUG_LOCATION); // Send three RPCs, one per server. - for (size_t i = 0; i < 3; ++i) CheckRpcSendOk(); + for (size_t i = 0; i < 3; ++i) CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(1, servers_[0]->service_.request_count()); EXPECT_EQ(1, servers_[1]->service_.request_count()); EXPECT_EQ(1, servers_[2]->service_.request_count()); @@ -565,7 +608,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { SetNextResolution(ports); grpc_connectivity_state channel_state; do { - channel_state = channel_->GetState(true /* try to connect */); + channel_state = channel->GetState(true /* try to connect */); } while (channel_state == GRPC_CHANNEL_READY); GPR_ASSERT(channel_state != GRPC_CHANNEL_READY); servers_[0]->service_.ResetCounters(); @@ -574,26 +617,27 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdates) { ports.clear(); ports.emplace_back(servers_[1]->port_); SetNextResolution(ports); - WaitForServer(1); - channel_state = channel_->GetState(false /* try to connect */); + WaitForServer(stub, 1, DEBUG_LOCATION); + channel_state = channel->GetState(false /* try to connect */); GPR_ASSERT(channel_state == GRPC_CHANNEL_READY); // Check LB policy name for the channel. - EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, RoundRobinUpdateInError) { const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "round_robin"); + auto channel = BuildChannel("round_robin"); + auto stub = BuildStub(channel); std::vector<int> ports; // Start with a single server. ports.emplace_back(servers_[0]->port_); SetNextResolution(ports); - WaitForServer(0); + WaitForServer(stub, 0, DEBUG_LOCATION); // Send RPCs. They should all go to servers_[0] - for (size_t i = 0; i < 10; ++i) SendRpc(); + for (size_t i = 0; i < 10; ++i) SendRpc(stub); EXPECT_EQ(10, servers_[0]->service_.request_count()); EXPECT_EQ(0, servers_[1]->service_.request_count()); EXPECT_EQ(0, servers_[2]->service_.request_count()); @@ -604,11 +648,11 @@ TEST_F(ClientLbEnd2endTest, RoundRobinUpdateInError) { ports.emplace_back(servers_[1]->port_); ports.emplace_back(servers_[2]->port_); SetNextResolution(ports); - WaitForServer(0); - WaitForServer(2); + WaitForServer(stub, 0, DEBUG_LOCATION); + WaitForServer(stub, 2, DEBUG_LOCATION); // Send three RPCs, one per server. - for (size_t i = 0; i < kNumServers; ++i) SendRpc(); + for (size_t i = 0; i < kNumServers; ++i) SendRpc(stub); // The server in shutdown shouldn't receive any. EXPECT_EQ(0, servers_[1]->service_.request_count()); } @@ -617,7 +661,8 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) { // Start servers and send one RPC per server. const int kNumServers = 3; StartServers(kNumServers); - ResetStub(GetServersPorts(), "round_robin"); + auto channel = BuildChannel("round_robin"); + auto stub = BuildStub(channel); std::vector<int> ports; for (size_t i = 0; i < servers_.size(); ++i) { ports.emplace_back(servers_[i]->port_); @@ -626,10 +671,10 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) { std::shuffle(ports.begin(), ports.end(), std::mt19937(std::random_device()())); SetNextResolution(ports); - if (i % 10 == 0) CheckRpcSendOk(); + if (i % 10 == 0) CheckRpcSendOk(stub, DEBUG_LOCATION); } // Check LB policy name for the channel. - EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName()); + EXPECT_EQ("round_robin", channel->GetLoadBalancingPolicyName()); } TEST_F(ClientLbEnd2endTest, RoundRobinConcurrentUpdates) { @@ -640,16 +685,21 @@ TEST_F(ClientLbEnd2endTest, RoundRobinConcurrentUpdates) { TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) { // Start servers and send one RPC per server. const int kNumServers = 3; - std::vector<int> ports; + std::vector<int> first_ports; + std::vector<int> second_ports; for (int i = 0; i < kNumServers; ++i) { - ports.push_back(grpc_pick_unused_port_or_die()); + first_ports.push_back(grpc_pick_unused_port_or_die()); } - StartServers(kNumServers, ports); - ResetStub(GetServersPorts(), "round_robin"); - SetNextResolution(ports); + for (int i = 0; i < kNumServers; ++i) { + second_ports.push_back(grpc_pick_unused_port_or_die()); + } + StartServers(kNumServers, first_ports); + auto channel = BuildChannel("round_robin"); + auto stub = BuildStub(channel); + SetNextResolution(first_ports); // Send a number of RPCs, which succeed. for (size_t i = 0; i < 100; ++i) { - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); } // Kill all servers gpr_log(GPR_INFO, "****** ABOUT TO KILL SERVERS *******"); @@ -659,18 +709,25 @@ TEST_F(ClientLbEnd2endTest, RoundRobinReresolve) { gpr_log(GPR_INFO, "****** SERVERS KILLED *******"); gpr_log(GPR_INFO, "****** SENDING DOOMED REQUESTS *******"); // Client requests should fail. Send enough to tickle all subchannels. - for (size_t i = 0; i < servers_.size(); ++i) CheckRpcSendFailure(); + for (size_t i = 0; i < servers_.size(); ++i) CheckRpcSendFailure(stub); gpr_log(GPR_INFO, "****** DOOMED REQUESTS SENT *******"); - // Bring servers back up on the same port (we aren't recreating the channel). + // Bring servers back up on a different set of ports. We need to do this to be + // sure that the eventual success is *not* due to subchannel reconnection + // attempts and that an actual re-resolution has happened as a result of the + // RR policy going into transient failure when all its subchannels become + // unavailable (in transient failure as well). gpr_log(GPR_INFO, "****** RESTARTING SERVERS *******"); - StartServers(kNumServers, ports); + StartServers(kNumServers, second_ports); + // Don't notify of the update. Wait for the LB policy's re-resolution to + // "pull" the new ports. + SetNextResolutionUponError(second_ports); gpr_log(GPR_INFO, "****** SERVERS RESTARTED *******"); gpr_log(GPR_INFO, "****** SENDING REQUEST TO SUCCEED *******"); // Client request should eventually (but still fairly soon) succeed. const gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); while (gpr_time_cmp(deadline, now) > 0) { - if (SendRpc()) break; + if (SendRpc(stub)) break; now = gpr_now(GPR_CLOCK_MONOTONIC); } GPR_ASSERT(gpr_time_cmp(deadline, now) > 0); @@ -680,11 +737,13 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { const int kNumServers = 3; StartServers(kNumServers); const auto ports = GetServersPorts(); - ResetStub(ports, "round_robin"); + auto channel = BuildChannel("round_robin"); + auto stub = BuildStub(channel); SetNextResolution(ports); - for (size_t i = 0; i < kNumServers; ++i) WaitForServer(i); + for (size_t i = 0; i < kNumServers; ++i) + WaitForServer(stub, i, DEBUG_LOCATION); for (size_t i = 0; i < servers_.size(); ++i) { - CheckRpcSendOk(); + CheckRpcSendOk(stub, DEBUG_LOCATION); EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i; } // One request should have gone to each server. @@ -696,10 +755,14 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { servers_[0]->Shutdown(true); // Client request still succeed. May need retrying if RR had returned a pick // before noticing the change in the server's connectivity. - while (!SendRpc()) + while (!SendRpc(stub)) { ; // Retry until success. + } + gpr_log(GPR_INFO, "------------------------------------------------------"); // Send a bunch of RPCs that should succeed. - for (int i = 0; i < 10 * kNumServers; ++i) CheckRpcSendOk(); + for (int i = 0; i < 10 * kNumServers; ++i) { + CheckRpcSendOk(stub, DEBUG_LOCATION); + } const auto post_death = servers_[0]->service_.request_count(); // No requests have gone to the deceased server. EXPECT_EQ(pre_death, post_death); @@ -709,7 +772,7 @@ TEST_F(ClientLbEnd2endTest, RoundRobinSingleReconnect) { // the server managed to start before the RR policy retried the subchannel) or // after the subchannel retry delay otherwise (RR's subchannel retried before // the server was fully back up). - WaitForServer(0); + WaitForServer(stub, 0, DEBUG_LOCATION); } } // namespace diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index e25de810f1..967db4c57c 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -706,7 +706,6 @@ TEST_P(End2endTest, ReconnectChannel) { if (GetParam().inproc) { return; } - gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "200"); int poller_slowdown_factor = 1; // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" @@ -1087,31 +1086,6 @@ TEST_P(End2endTest, RpcMaxMessageSize) { EXPECT_FALSE(s.ok()); } -// Client sends 20 requests and the server returns CANCELLED status after -// reading 10 requests. -TEST_P(End2endTest, RequestStreamServerEarlyCancelTest) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - - context.AddMetadata(kServerCancelAfterReads, "10"); - auto stream = stub_->RequestStream(&context, &response); - request.set_message("hello"); - int send_messages = 20; - while (send_messages > 10) { - EXPECT_TRUE(stream->Write(request)); - send_messages--; - } - while (send_messages > 0) { - stream->Write(request); - send_messages--; - } - stream->WritesDone(); - Status s = stream->Finish(); - EXPECT_EQ(s.error_code(), StatusCode::CANCELLED); -} - void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream, gpr_event* ev) { EchoResponse resp; @@ -1359,8 +1333,11 @@ TEST_P(ProxyEnd2endTest, EchoDeadline) { EXPECT_TRUE(s.ok()); gpr_timespec sent_deadline; Timepoint2Timespec(deadline, &sent_deadline); - // Allow 1 second error. - EXPECT_LE(response.param().request_deadline() - sent_deadline.tv_sec, 1); + // We want to allow some reasonable error given: + // - request_deadline() only has 1sec resolution so the best we can do is +-1 + // - if sent_deadline.tv_nsec is very close to the next second's boundary we + // can end up being off by 2 in one direction. + EXPECT_LE(response.param().request_deadline() - sent_deadline.tv_sec, 2); EXPECT_GE(response.param().request_deadline() - sent_deadline.tv_sec, -1); } @@ -1853,6 +1830,7 @@ INSTANTIATE_TEST_CASE_P(ResourceQuotaEnd2end, ResourceQuotaEnd2endTest, } // namespace grpc int main(int argc, char** argv) { + gpr_setenv("GRPC_CLIENT_CHANNEL_BACKUP_POLL_INTERVAL_MS", "200"); grpc_test_init(argc, argv); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc index c4430379db..53e86addef 100644 --- a/test/cpp/end2end/filter_end2end_test.cc +++ b/test/cpp/end2end/filter_end2end_test.cc @@ -175,7 +175,8 @@ class FilterEnd2endTest : public ::testing::Test { // The string needs to be long enough to test heap-based slice. send_request.set_message("Hello world. Hello world. Hello world."); std::unique_ptr<GenericClientAsyncReaderWriter> call = - generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1)); + generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); + call->StartCall(tag(1)); client_ok(1); std::unique_ptr<ByteBuffer> send_buffer = SerializeToByteBuffer(&send_request); @@ -268,7 +269,8 @@ TEST_F(FilterEnd2endTest, SimpleBidiStreaming) { cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); send_request.set_message("Hello"); std::unique_ptr<GenericClientAsyncReaderWriter> cli_stream = - generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1)); + generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); + cli_stream->StartCall(tag(1)); client_ok(1); generic_service_.RequestCall(&srv_ctx, &srv_stream, srv_cq_.get(), diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 40949e8f3a..dac5faed8f 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -125,7 +125,8 @@ class GenericEnd2endTest : public ::testing::Test { } std::unique_ptr<GenericClientAsyncReaderWriter> call = - generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1)); + generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); + call->StartCall(tag(1)); client_ok(1); std::unique_ptr<ByteBuffer> send_buffer = SerializeToByteBuffer(&send_request); @@ -271,7 +272,8 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) { cli_ctx.set_compression_algorithm(GRPC_COMPRESS_GZIP); send_request.set_message("Hello"); std::unique_ptr<GenericClientAsyncReaderWriter> cli_stream = - generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1)); + generic_stub_->PrepareCall(&cli_ctx, kMethodName, &cli_cq_); + cli_stream->StartCall(tag(1)); client_ok(1); generic_service_.RequestCall(&srv_ctx, &srv_stream, srv_cq_.get(), diff --git a/test/cpp/end2end/grpclb_end2end_test.cc b/test/cpp/end2end/grpclb_end2end_test.cc index 815dfd0c4f..89c9c2bf76 100644 --- a/test/cpp/end2end/grpclb_end2end_test.cc +++ b/test/cpp/end2end/grpclb_end2end_test.cc @@ -35,6 +35,7 @@ #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "test/core/util/port.h" @@ -220,30 +221,31 @@ class BalancerServiceImpl : public BalancerService { if (client_load_reporting_interval_seconds_ > 0) { request.Clear(); - stream->Read(&request); - gpr_log(GPR_INFO, "LB[%p]: recv client load report msg: '%s'", this, - request.DebugString().c_str()); - GPR_ASSERT(request.has_client_stats()); - // We need to acquire the lock here in order to prevent the notify_one - // below from firing before its corresponding wait is executed. - std::lock_guard<std::mutex> lock(mu_); - client_stats_.num_calls_started += - request.client_stats().num_calls_started(); - client_stats_.num_calls_finished += - request.client_stats().num_calls_finished(); - client_stats_.num_calls_finished_with_client_failed_to_send += - request.client_stats() - .num_calls_finished_with_client_failed_to_send(); - client_stats_.num_calls_finished_known_received += - request.client_stats().num_calls_finished_known_received(); - for (const auto& drop_token_count : - request.client_stats().calls_finished_with_drop()) { - client_stats_ - .drop_token_counts[drop_token_count.load_balance_token()] += - drop_token_count.num_calls(); + if (stream->Read(&request)) { + gpr_log(GPR_INFO, "LB[%p]: recv client load report msg: '%s'", this, + request.DebugString().c_str()); + GPR_ASSERT(request.has_client_stats()); + // We need to acquire the lock here in order to prevent the notify_one + // below from firing before its corresponding wait is executed. + std::lock_guard<std::mutex> lock(mu_); + client_stats_.num_calls_started += + request.client_stats().num_calls_started(); + client_stats_.num_calls_finished += + request.client_stats().num_calls_finished(); + client_stats_.num_calls_finished_with_client_failed_to_send += + request.client_stats() + .num_calls_finished_with_client_failed_to_send(); + client_stats_.num_calls_finished_known_received += + request.client_stats().num_calls_finished_known_received(); + for (const auto& drop_token_count : + request.client_stats().calls_finished_with_drop()) { + client_stats_ + .drop_token_counts[drop_token_count.load_balance_token()] += + drop_token_count.num_calls(); + } + load_report_ready_ = true; + load_report_cond_.notify_one(); } - load_report_ready_ = true; - load_report_cond_.notify_one(); } done: gpr_log(GPR_INFO, "LB[%p]: done", this); @@ -338,7 +340,8 @@ class GrpclbEnd2endTest : public ::testing::Test { } void SetUp() override { - response_generator_ = grpc_fake_resolver_response_generator_create(); + response_generator_ = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); // Start the backends. for (size_t i = 0; i < num_backends_; ++i) { backends_.emplace_back(new BackendServiceImpl()); @@ -362,7 +365,6 @@ class GrpclbEnd2endTest : public ::testing::Test { for (size_t i = 0; i < balancers_.size(); ++i) { if (balancers_[i]->Shutdown()) balancer_servers_[i].Shutdown(); } - grpc_fake_resolver_response_generator_unref(response_generator_); } void SetNextResolutionAllBalancers() { @@ -377,7 +379,7 @@ class GrpclbEnd2endTest : public ::testing::Test { ChannelArguments args; args.SetGrpclbFallbackTimeout(fallback_timeout); args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, - response_generator_); + response_generator_.get()); std::ostringstream uri; uri << "fake:///servername_not_used"; channel_ = @@ -453,8 +455,8 @@ class GrpclbEnd2endTest : public ::testing::Test { grpc::string balancer_name; }; - void SetNextResolution(const std::vector<AddressData>& address_data) { - grpc_core::ExecCtx exec_ctx; + grpc_lb_addresses* CreateLbAddressesFromAddressDataList( + const std::vector<AddressData>& address_data) { grpc_lb_addresses* addresses = grpc_lb_addresses_create(address_data.size(), nullptr); for (size_t i = 0; i < address_data.size(); ++i) { @@ -468,10 +470,27 @@ class GrpclbEnd2endTest : public ::testing::Test { grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } + return addresses; + } + + void SetNextResolution(const std::vector<AddressData>& address_data) { + grpc_core::ExecCtx exec_ctx; + grpc_lb_addresses* addresses = + CreateLbAddressesFromAddressDataList(address_data); + grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); + grpc_channel_args fake_result = {1, &fake_addresses}; + response_generator_->SetResponse(&fake_result); + grpc_lb_addresses_destroy(addresses); + } + + void SetNextReresolutionResponse( + const std::vector<AddressData>& address_data) { + grpc_core::ExecCtx exec_ctx; + grpc_lb_addresses* addresses = + CreateLbAddressesFromAddressDataList(address_data); grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args fake_result = {1, &fake_addresses}; - grpc_fake_resolver_response_generator_set_response(response_generator_, - &fake_result); + response_generator_->SetReresolutionResponse(&fake_result); grpc_lb_addresses_destroy(addresses); } @@ -573,7 +592,8 @@ class GrpclbEnd2endTest : public ::testing::Test { std::vector<std::unique_ptr<BalancerServiceImpl>> balancers_; std::vector<ServerThread<BackendService>> backend_servers_; std::vector<ServerThread<BalancerService>> balancer_servers_; - grpc_fake_resolver_response_generator* response_generator_; + grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> + response_generator_; const grpc::string kRequestMessage_ = "Live long and prosper."; }; diff --git a/test/cpp/end2end/server_early_return_test.cc b/test/cpp/end2end/server_early_return_test.cc new file mode 100644 index 0000000000..6fd26fcdb6 --- /dev/null +++ b/test/cpp/end2end/server_early_return_test.cc @@ -0,0 +1,233 @@ +/* + * + * Copyright 2018 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++/channel.h> +#include <grpc++/client_context.h> +#include <grpc++/create_channel.h> +#include <grpc++/security/credentials.h> +#include <grpc++/security/server_credentials.h> +#include <grpc++/server.h> +#include <grpc++/server_builder.h> +#include <grpc++/server_context.h> +#include <grpc/grpc.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/thd.h> +#include <grpc/support/time.h> + +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/port.h" +#include "test/core/util/test_config.h" +#include "test/cpp/util/string_ref_helper.h" + +#include <gtest/gtest.h> + +namespace grpc { +namespace testing { +namespace { + +const char kServerReturnStatusCode[] = "server_return_status_code"; +const char kServerDelayBeforeReturnUs[] = "server_delay_before_return_us"; +const char kServerReturnAfterNReads[] = "server_return_after_n_reads"; + +class TestServiceImpl : public ::grpc::testing::EchoTestService::Service { + public: + // Unused methods are not implemented. + + Status RequestStream(ServerContext* context, + ServerReader<EchoRequest>* reader, + EchoResponse* response) override { + int server_return_status_code = + GetIntValueFromMetadata(context, kServerReturnStatusCode, 0); + int server_delay_before_return_us = + GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0); + int server_return_after_n_reads = + GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0); + + EchoRequest request; + while (server_return_after_n_reads--) { + EXPECT_TRUE(reader->Read(&request)); + } + + response->set_message("response msg"); + + gpr_sleep_until(gpr_time_add( + gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN))); + + return Status(static_cast<StatusCode>(server_return_status_code), ""); + } + + Status BidiStream( + ServerContext* context, + ServerReaderWriter<EchoResponse, EchoRequest>* stream) override { + int server_return_status_code = + GetIntValueFromMetadata(context, kServerReturnStatusCode, 0); + int server_delay_before_return_us = + GetIntValueFromMetadata(context, kServerDelayBeforeReturnUs, 0); + int server_return_after_n_reads = + GetIntValueFromMetadata(context, kServerReturnAfterNReads, 0); + + EchoRequest request; + EchoResponse response; + while (server_return_after_n_reads--) { + EXPECT_TRUE(stream->Read(&request)); + response.set_message(request.message()); + EXPECT_TRUE(stream->Write(response)); + } + + gpr_sleep_until(gpr_time_add( + gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_micros(server_delay_before_return_us, GPR_TIMESPAN))); + + return Status(static_cast<StatusCode>(server_return_status_code), ""); + } + + int GetIntValueFromMetadata(ServerContext* context, const char* key, + int default_value) { + auto metadata = context->client_metadata(); + if (metadata.find(key) != metadata.end()) { + std::istringstream iss(ToString(metadata.find(key)->second)); + iss >> default_value; + } + return default_value; + } +}; + +class ServerEarlyReturnTest : public ::testing::Test { + protected: + ServerEarlyReturnTest() : picked_port_(0) {} + + void SetUp() override { + int port = grpc_pick_unused_port_or_die(); + picked_port_ = port; + server_address_ << "127.0.0.1:" << port; + ServerBuilder builder; + builder.AddListeningPort(server_address_.str(), + InsecureServerCredentials()); + builder.RegisterService(&service_); + server_ = builder.BuildAndStart(); + + channel_ = + CreateChannel(server_address_.str(), InsecureChannelCredentials()); + stub_ = grpc::testing::EchoTestService::NewStub(channel_); + } + + void TearDown() override { + server_->Shutdown(); + if (picked_port_ > 0) { + grpc_recycle_unused_port(picked_port_); + } + } + + // Client sends 20 requests and the server returns after reading 10 requests. + // If return_cancel is true, server returns CANCELLED status. Otherwise it + // returns OK. + void DoBidiStream(bool return_cancelled) { + EchoRequest request; + EchoResponse response; + ClientContext context; + + context.AddMetadata(kServerReturnAfterNReads, "10"); + if (return_cancelled) { + // "1" means CANCELLED + context.AddMetadata(kServerReturnStatusCode, "1"); + } + context.AddMetadata(kServerDelayBeforeReturnUs, "10000"); + + auto stream = stub_->BidiStream(&context); + + for (int i = 0; i < 20; i++) { + request.set_message(grpc::string("hello") + grpc::to_string(i)); + bool write_ok = stream->Write(request); + bool read_ok = stream->Read(&response); + if (i < 10) { + EXPECT_TRUE(write_ok); + EXPECT_TRUE(read_ok); + EXPECT_EQ(response.message(), request.message()); + } else { + EXPECT_FALSE(read_ok); + } + } + + stream->WritesDone(); + EXPECT_FALSE(stream->Read(&response)); + + Status s = stream->Finish(); + if (return_cancelled) { + EXPECT_EQ(s.error_code(), StatusCode::CANCELLED); + } else { + EXPECT_TRUE(s.ok()); + } + } + + void DoRequestStream(bool return_cancelled) { + EchoRequest request; + EchoResponse response; + ClientContext context; + + context.AddMetadata(kServerReturnAfterNReads, "10"); + if (return_cancelled) { + // "1" means CANCELLED + context.AddMetadata(kServerReturnStatusCode, "1"); + } + context.AddMetadata(kServerDelayBeforeReturnUs, "10000"); + + auto stream = stub_->RequestStream(&context, &response); + for (int i = 0; i < 20; i++) { + request.set_message(grpc::string("hello") + grpc::to_string(i)); + bool written = stream->Write(request); + if (i < 10) { + EXPECT_TRUE(written); + } + } + stream->WritesDone(); + Status s = stream->Finish(); + if (return_cancelled) { + EXPECT_EQ(s.error_code(), StatusCode::CANCELLED); + } else { + EXPECT_TRUE(s.ok()); + } + } + + std::shared_ptr<Channel> channel_; + std::unique_ptr<grpc::testing::EchoTestService::Stub> stub_; + std::unique_ptr<Server> server_; + std::ostringstream server_address_; + TestServiceImpl service_; + int picked_port_; +}; + +TEST_F(ServerEarlyReturnTest, BidiStreamEarlyOk) { DoBidiStream(false); } + +TEST_F(ServerEarlyReturnTest, BidiStreamEarlyCancel) { DoBidiStream(true); } + +TEST_F(ServerEarlyReturnTest, RequestStreamEarlyOK) { DoRequestStream(false); } +TEST_F(ServerEarlyReturnTest, RequestStreamEarlyCancel) { + DoRequestStream(true); +} + +} // namespace +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc_test_init(argc, argv); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc index e4f7c08f25..875a27b5f5 100644 --- a/test/cpp/end2end/test_service_impl.cc +++ b/test/cpp/end2end/test_service_impl.cc @@ -181,13 +181,6 @@ Status TestServiceImpl::RequestStream(ServerContext* context, int server_try_cancel = GetIntValueFromMetadata( kServerTryCancelRequest, context->client_metadata(), DO_NOT_CANCEL); - // If 'cancel_after_reads' is set in the metadata AND non-zero, the server - // will cancel the RPC (by just returning Status::CANCELLED - doesn't call - // ServerContext::TryCancel()) after reading the number of records specified - // by the 'cancel_after_reads' value set in the metadata. - int cancel_after_reads = GetIntValueFromMetadata( - kServerCancelAfterReads, context->client_metadata(), 0); - EchoRequest request; response->set_message(""); @@ -204,12 +197,6 @@ Status TestServiceImpl::RequestStream(ServerContext* context, int num_msgs_read = 0; while (reader->Read(&request)) { - if (cancel_after_reads == 1) { - gpr_log(GPR_INFO, "return cancel status"); - return Status::CANCELLED; - } else if (cancel_after_reads > 0) { - cancel_after_reads--; - } response->mutable_message()->append(request.message()); } gpr_log(GPR_INFO, "Read: %d messages", num_msgs_read); diff --git a/test/cpp/end2end/test_service_impl.h b/test/cpp/end2end/test_service_impl.h index e485769bb2..070f357139 100644 --- a/test/cpp/end2end/test_service_impl.h +++ b/test/cpp/end2end/test_service_impl.h @@ -31,7 +31,6 @@ namespace testing { const int kServerDefaultResponseStreamsToSend = 3; const char* const kServerResponseStreamsToSend = "server_responses_to_send"; -const char* const kServerCancelAfterReads = "cancel_after_reads"; const char* const kServerTryCancelRequest = "server_try_cancel"; const char* const kDebugInfoTrailerKey = "debug-info-bin"; const char* const kServerFinishAfterNReads = "server_finish_after_n_reads"; diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index d241594af1..06ab8c3ff8 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -27,7 +27,6 @@ #include <grpc/grpc.h> #include <grpc/impl/codegen/byte_buffer_reader.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/sync.h> @@ -41,8 +40,10 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/tmpfile.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "src/core/lib/surface/channel.h" @@ -558,8 +559,8 @@ static void setup_client(const server_fixture* lb_server, const char* backends_name = lb_server->servers_hostport; gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME); - grpc_fake_resolver_response_generator* response_generator = - grpc_fake_resolver_response_generator_create(); + auto response_generator = + grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, nullptr); char* lb_uri_str; @@ -578,25 +579,22 @@ static void setup_client(const server_fixture* lb_server, grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); grpc_lb_addresses_destroy(addresses); - const grpc_arg new_args[] = { + grpc_arg new_args[] = { grpc_fake_transport_expected_targets_arg(expected_target_names), - grpc_fake_resolver_response_generator_arg(response_generator)}; + grpc_core::FakeResolverResponseGenerator::MakeChannelArg( + response_generator.get())}; - grpc_channel_args* args = grpc_channel_args_copy_and_add( - nullptr, new_args, GPR_ARRAY_SIZE(new_args)); - gpr_free(expected_target_names); + grpc_channel_args args = {GPR_ARRAY_SIZE(new_args), new_args}; cf->cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel_credentials* fake_creds = grpc_fake_transport_security_credentials_create(); cf->client = - grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr); - grpc_fake_resolver_response_generator_set_response(response_generator, - fake_result); + grpc_secure_channel_create(fake_creds, cf->server_uri, &args, nullptr); + response_generator->SetResponse(fake_result); grpc_channel_args_destroy(fake_result); grpc_channel_credentials_unref(fake_creds); - grpc_channel_args_destroy(args); - grpc_fake_resolver_response_generator_unref(response_generator); + gpr_free(expected_target_names); } static void teardown_client(client_fixture* cf) { diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 8958b9884d..4da9639d25 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -25,7 +25,6 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "test/cpp/interop/client_helper.h" diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc index 7a9e3ced6a..411812d583 100644 --- a/test/cpp/interop/http2_client.cc +++ b/test/cpp/interop/http2_client.cc @@ -23,7 +23,6 @@ #include <grpc++/client_context.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> #include "src/core/lib/transport/byte_stream.h" #include "src/proto/grpc/testing/messages.pb.h" @@ -31,6 +30,7 @@ #include "test/cpp/interop/http2_client.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gpr/useful.h" #include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index d2192f5e70..3051afa86b 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -28,7 +28,6 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/transport/byte_stream.h" #include "src/proto/grpc/testing/empty.pb.h" diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 7cfdb2f9e9..f78a1f1d8a 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -29,7 +29,6 @@ #include <grpc/grpc.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include <grpc/support/useful.h> #include "src/core/lib/gpr/string.h" #include "src/core/lib/transport/byte_stream.h" diff --git a/test/cpp/interop/interop_test.cc b/test/cpp/interop/interop_test.cc index 563b7abb5e..ae155b65f9 100644 --- a/test/cpp/interop/interop_test.cc +++ b/test/cpp/interop/interop_test.cc @@ -31,12 +31,12 @@ #include <gflags/gflags.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include "test/core/util/port.h" #include "test/cpp/util/test_config.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/socket_utils_posix.h" diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index d6d7d41e5e..294f1feb80 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -79,9 +79,11 @@ static void write_csv(std::ostream* out, A0&& a0, Arg&&... arg) { class TrickledCHTTP2 : public EndpointPairFixture { public: TrickledCHTTP2(Service* service, bool streaming, size_t req_size, - size_t resp_size, size_t kilobits_per_second) - : EndpointPairFixture(service, MakeEndpoints(kilobits_per_second), - FixtureConfiguration()) { + size_t resp_size, size_t kilobits_per_second, + grpc_passthru_endpoint_stats* stats) + : EndpointPairFixture(service, MakeEndpoints(kilobits_per_second, stats), + FixtureConfiguration()), + stats_(stats) { if (FLAGS_log) { std::ostringstream fn; fn << "trickle." << (streaming ? "streaming" : "unary") << "." << req_size @@ -101,9 +103,15 @@ class TrickledCHTTP2 : public EndpointPairFixture { } } + virtual ~TrickledCHTTP2() { + if (stats_ != nullptr) { + grpc_passthru_endpoint_stats_destroy(stats_); + } + } + void AddToLabel(std::ostream& out, benchmark::State& state) { out << " writes/iter:" - << ((double)stats_.num_writes / (double)state.iterations()) + << ((double)stats_->num_writes / (double)state.iterations()) << " cli_transport_stalls/iter:" << ((double) client_stats_.streams_stalled_due_to_transport_flow_control / @@ -193,7 +201,7 @@ class TrickledCHTTP2 : public EndpointPairFixture { } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; struct Stats { int streams_stalled_due_to_stream_flow_control = 0; int streams_stalled_due_to_transport_flow_control = 0; @@ -203,10 +211,11 @@ class TrickledCHTTP2 : public EndpointPairFixture { std::unique_ptr<std::ofstream> log_; gpr_timespec start_ = gpr_now(GPR_CLOCK_MONOTONIC); - grpc_endpoint_pair MakeEndpoints(size_t kilobits) { + static grpc_endpoint_pair MakeEndpoints(size_t kilobits, + grpc_passthru_endpoint_stats* stats) { grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, Library::get().rq(), - &stats_); + stats); double bytes_per_second = 125.0 * kilobits; p.client = grpc_trickle_endpoint_create(p.client, bytes_per_second); p.server = grpc_trickle_endpoint_create(p.server, bytes_per_second); @@ -251,7 +260,8 @@ static void BM_PumpStreamServerToClient_Trickle(benchmark::State& state) { EchoTestService::AsyncService service; std::unique_ptr<TrickledCHTTP2> fixture(new TrickledCHTTP2( &service, true, state.range(0) /* req_size */, - state.range(0) /* resp_size */, state.range(1) /* bw in kbit/s */)); + state.range(0) /* resp_size */, state.range(1) /* bw in kbit/s */, + grpc_passthru_endpoint_stats_create())); { EchoResponse send_response; EchoResponse recv_response; @@ -344,7 +354,8 @@ static void BM_PumpUnbalancedUnary_Trickle(benchmark::State& state) { EchoTestService::AsyncService service; std::unique_ptr<TrickledCHTTP2> fixture(new TrickledCHTTP2( &service, false, state.range(0) /* req_size */, - state.range(1) /* resp_size */, state.range(2) /* bw in kbit/s */)); + state.range(1) /* resp_size */, state.range(2) /* bw in kbit/s */, + grpc_passthru_endpoint_stats_create())); EchoRequest send_request; EchoResponse send_response; EchoResponse recv_response; diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index d9d5164cce..f49f6671ae 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -21,8 +21,8 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> -#include <grpc/support/useful.h> +#include "src/core/lib/gpr/useful.h" #include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/port.h" diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index d1ede755a5..fdc04e51c6 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -61,6 +61,15 @@ class FixtureConfiguration { class BaseFixture : public TrackCounters {}; +// Special tag to be used in Server shutdown. This tag is *NEVER* returned when +// Cq->Next() API is called (This is because FinalizeResult() function in this +// class always returns 'false'). This is intentional and makes writing shutdown +// code easier. +class ShutdownTag : public internal::CompletionQueueTag { + public: + bool FinalizeResult(void** tag, bool* status) { return false; } +}; + class FullstackFixture : public BaseFixture { public: FullstackFixture(Service* service, const FixtureConfiguration& config, @@ -84,7 +93,11 @@ class FullstackFixture : public BaseFixture { } virtual ~FullstackFixture() { - server_->Shutdown(gpr_inf_past(GPR_CLOCK_MONOTONIC)); + // Dummy shutdown tag (this tag is swallowed by cq->Next() and is not + // returned to the user) see ShutdownTag definition for more details + ShutdownTag shutdown_tag; + grpc_server_shutdown_and_notify(server_->c_server(), cq_->cq(), + &shutdown_tag); cq_->Shutdown(); void* tag; bool ok; @@ -208,7 +221,11 @@ class EndpointPairFixture : public BaseFixture { } virtual ~EndpointPairFixture() { - server_->Shutdown(gpr_inf_past(GPR_CLOCK_MONOTONIC)); + // Dummy shutdown tag (this tag is swallowed by cq->Next() and is not + // returned to the user) see ShutdownTag definition for more details + ShutdownTag shutdown_tag; + grpc_server_shutdown_and_notify(server_->c_server(), cq_->cq(), + &shutdown_tag); cq_->Shutdown(); void* tag; bool ok; @@ -245,31 +262,53 @@ class SockPair : public EndpointPairFixture { fixture_configuration) {} }; -class InProcessCHTTP2 : public EndpointPairFixture { +/* Use InProcessCHTTP2 instead. This class (with stats as an explicit parameter) + is here only to be able to initialize both the base class and stats_ with the + same stats instance without accessing the stats_ fields before the object is + properly initialized. */ +class InProcessCHTTP2WithExplicitStats : public EndpointPairFixture { public: - InProcessCHTTP2(Service* service, - const FixtureConfiguration& fixture_configuration = - FixtureConfiguration()) - : EndpointPairFixture(service, MakeEndpoints(), fixture_configuration) {} + InProcessCHTTP2WithExplicitStats( + Service* service, grpc_passthru_endpoint_stats* stats, + const FixtureConfiguration& fixture_configuration) + : EndpointPairFixture(service, MakeEndpoints(stats), + fixture_configuration), + stats_(stats) {} + + virtual ~InProcessCHTTP2WithExplicitStats() { + if (stats_ != nullptr) { + grpc_passthru_endpoint_stats_destroy(stats_); + } + } void AddToLabel(std::ostream& out, benchmark::State& state) { EndpointPairFixture::AddToLabel(out, state); out << " writes/iter:" - << static_cast<double>(gpr_atm_no_barrier_load(&stats_.num_writes)) / + << static_cast<double>(gpr_atm_no_barrier_load(&stats_->num_writes)) / static_cast<double>(state.iterations()); } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; - grpc_endpoint_pair MakeEndpoints() { + static grpc_endpoint_pair MakeEndpoints(grpc_passthru_endpoint_stats* stats) { grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, Library::get().rq(), - &stats_); + stats); return p; } }; +class InProcessCHTTP2 : public InProcessCHTTP2WithExplicitStats { + public: + InProcessCHTTP2(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) + : InProcessCHTTP2WithExplicitStats(service, + grpc_passthru_endpoint_stats_create(), + fixture_configuration) {} +}; + //////////////////////////////////////////////////////////////////////////////// // Minimal stack fixtures diff --git a/test/cpp/naming/create_private_dns_zone.sh b/test/cpp/naming/create_private_dns_zone.sh index 55a4cfe36e..5c9364ca1a 100755 --- a/test/cpp/naming/create_private_dns_zone.sh +++ b/test/cpp/naming/create_private_dns_zone.sh @@ -17,7 +17,7 @@ set -ex -cd $(dirname $0)/../../.. +cd "$(dirname "$0")/../../.." gcloud alpha dns managed-zones create \ resolver-tests-version-4-grpctestingexp-zone-id \ diff --git a/test/cpp/naming/private_dns_zone_init.sh b/test/cpp/naming/private_dns_zone_init.sh index 8fa5a8a475..fba8a005cc 100755 --- a/test/cpp/naming/private_dns_zone_init.sh +++ b/test/cpp/naming/private_dns_zone_init.sh @@ -17,7 +17,7 @@ set -ex -cd $(dirname $0)/../../.. +cd "$(dirname "$0")/../../.." gcloud dns record-sets transaction start -z=resolver-tests-version-4-grpctestingexp-zone-id diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 8b5523f01a..f4be064305 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -18,7 +18,6 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/sync.h> @@ -38,7 +37,9 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" @@ -61,11 +62,9 @@ using namespace gflags; DEFINE_string(target_name, "", "Target name to resolve."); DEFINE_string(expected_addrs, "", - "Comma-separated list of expected " - "'<ip0:port0>,<is_balancer0>;<ip1:port1>,<is_balancer1>;...' " - "addresses of " - "backend and/or balancers. 'is_balancer' should be bool, i.e. " - "true or false."); + "List of expected backend or balancer addresses in the form " + "'<ip0:port0>,<is_balancer0>;<ip1:port1>,<is_balancer1>;...'. " + "'is_balancer' should be bool, i.e. true or false."); DEFINE_string(expected_chosen_service_config, "", "Expected service config json string that gets chosen (no " "whitespace). Empty for none."); @@ -102,12 +101,10 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { // get the next <ip>,<port> (v4 or v6) size_t next_comma = expected_addrs.find(","); if (next_comma == std::string::npos) { - gpr_log( - GPR_ERROR, - "Missing ','. Expected_addrs arg should be a semi-colon-separated " - "list of " - "<ip-port>,<bool> pairs. Left-to-be-parsed arg is |%s|", - expected_addrs.c_str()); + gpr_log(GPR_ERROR, + "Missing ','. Expected_addrs arg should be a semicolon-separated " + "list of <ip-port>,<bool> pairs. Left-to-be-parsed arg is |%s|", + expected_addrs.c_str()); abort(); } std::string next_addr = expected_addrs.substr(0, next_comma); @@ -125,7 +122,7 @@ vector<GrpcLBAddress> ParseExpectedAddrs(std::string expected_addrs) { } if (out.size() == 0) { gpr_log(GPR_ERROR, - "expected_addrs arg should be a comma-separated list of " + "expected_addrs arg should be a semicolon-separated list of " "<ip-port>,<bool> pairs"); abort(); } @@ -287,17 +284,16 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { FLAGS_local_dns_server_address.c_str(), FLAGS_target_name.c_str())); // create resolver and resolve - grpc_resolver* resolver = - grpc_resolver_create(whole_uri, nullptr, args.pollset_set, args.lock); + grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = + grpc_core::ResolverRegistry::CreateResolver(whole_uri, nullptr, + args.pollset_set, args.lock); gpr_free(whole_uri); grpc_closure on_resolver_result_changed; GRPC_CLOSURE_INIT(&on_resolver_result_changed, CheckResolverResultLocked, (void*)&args, grpc_combiner_scheduler(args.lock)); - grpc_resolver_next_locked(resolver, &args.channel_args, - &on_resolver_result_changed); + resolver->NextLocked(&args.channel_args, &on_resolver_result_changed); grpc_core::ExecCtx::Get()->Flush(); PollPollsetUntilRequestDone(&args); - GRPC_RESOLVER_UNREF(resolver, nullptr); ArgsFinish(&args); } diff --git a/test/cpp/naming/resolver_component_tests_runner.sh b/test/cpp/naming/resolver_component_tests_runner.sh index 11a45d72ce..618a173dc0 100755 --- a/test/cpp/naming/resolver_component_tests_runner.sh +++ b/test/cpp/naming/resolver_component_tests_runner.sh @@ -18,10 +18,10 @@ set -ex # all command args required in this set order -FLAGS_test_bin_path=`echo "$1" | grep '\--test_bin_path=' | cut -d "=" -f 2` -FLAGS_dns_server_bin_path=`echo "$2" | grep '\--dns_server_bin_path=' | cut -d "=" -f 2` -FLAGS_records_config_path=`echo "$3" | grep '\--records_config_path=' | cut -d "=" -f 2` -FLAGS_test_dns_server_port=`echo "$4" | grep '\--test_dns_server_port=' | cut -d "=" -f 2` +FLAGS_test_bin_path=$(echo "$1" | grep '\--test_bin_path=' | cut -d "=" -f 2) +FLAGS_dns_server_bin_path=$(echo "$2" | grep '\--dns_server_bin_path=' | cut -d "=" -f 2) +FLAGS_records_config_path=$(echo "$3" | grep '\--records_config_path=' | cut -d "=" -f 2) +FLAGS_test_dns_server_port=$(echo "$4" | grep '\--test_dns_server_port=' | cut -d "=" -f 2) for cmd_arg in "$FLAGS_test_bin_path" "$FLAGS_dns_server_bin_path" "$FLAGS_records_config_path" "$FLAGS_test_dns_server_port"; do if [[ "$cmd_arg" == "" ]]; then @@ -34,7 +34,7 @@ if [[ "$GRPC_DNS_RESOLVER" != "" && "$GRPC_DNS_RESOLVER" != ares ]]; then fi export GRPC_DNS_RESOLVER=ares -"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_test_dns_server_port" 2>&1 > /dev/null & +"$FLAGS_dns_server_bin_path" --records_config_path="$FLAGS_records_config_path" --port="$FLAGS_test_dns_server_port" > /dev/null 2>&1 & DNS_SERVER_PID=$! echo "Local DNS server started. PID: $DNS_SERVER_PID" @@ -53,15 +53,15 @@ done if [[ $RETRY == 1 ]]; then echo "FAILED TO START LOCAL DNS SERVER" - kill -SIGTERM $DNS_SERVER_PID + kill -SIGTERM "$DNS_SERVER_PID" wait exit 1 fi function terminate_all { echo "Received signal. Terminating $! and $DNS_SERVER_PID" - kill -SIGTERM $! || true - kill -SIGTERM $DNS_SERVER_PID || true + kill -SIGTERM "$!" || true + kill -SIGTERM "$DNS_SERVER_PID" || true wait exit 1 } @@ -77,105 +77,105 @@ $FLAGS_test_bin_path \ --expected_addrs='1.2.3.4:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='srv-ipv4-multi-target.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.5:1234,True;1.2.3.6:1234,True;1.2.3.7:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='srv-ipv6-single-target.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='[2607:f8b0:400a:801::1001]:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='srv-ipv6-multi-target.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1003]:1234,True;[2607:f8b0:400a:801::1004]:1234,True' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='srv-ipv4-simple-service-config.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:1234,True' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='ipv4-no-srv-simple-service-config.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"NoSrvSimpleService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='ipv4-no-config-for-cpp.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='ipv4-cpp-config-has-zero-percentage.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='ipv4-second-language-is-cpp.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"CppService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='ipv4-config-with-percentages.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"AlwaysPickedService","waitForReady":true}]}]}' \ --expected_lb_policy='round_robin' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='srv-ipv4-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:1234,True;1.2.3.4:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='srv-ipv6-target-has-backend-and-balancer.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='[2607:f8b0:400a:801::1002]:1234,True;[2607:f8b0:400a:801::1002]:443,False' \ --expected_chosen_service_config='' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 $FLAGS_test_bin_path \ --target_name='ipv4-config-causing-fallback-to-tcp.resolver-tests-version-4.grpctestingexp.' \ --expected_addrs='1.2.3.4:443,False' \ --expected_chosen_service_config='{"loadBalancingPolicy":"round_robin","methodConfig":[{"name":[{"method":"Foo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwo","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooThree","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFour","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooFive","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSix","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooSeven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEight","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooNine","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTen","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooEleven","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]},{"name":[{"method":"FooTwelve","service":"SimpleService","waitForReady":true}]}]}' \ --expected_lb_policy='' \ - --local_dns_server_address=127.0.0.1:$FLAGS_test_dns_server_port & -wait $! || EXIT_CODE=1 + --local_dns_server_address="127.0.0.1:$FLAGS_test_dns_server_port" & +wait "$!" || EXIT_CODE=1 -kill -SIGTERM $DNS_SERVER_PID || true +kill -SIGTERM "$DNS_SERVER_PID" || true wait exit $EXIT_CODE diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc index 65f11243fe..306c322780 100644 --- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc +++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc @@ -44,7 +44,8 @@ DEFINE_bool( DEFINE_string(test_bin_name, "", "Name, without the preceding path, of the test binary"); -DEFINE_string(grpc_test_directory_relative_to_test_srcdir, "/__main__", +DEFINE_string(grpc_test_directory_relative_to_test_srcdir, + "/com_github_grpc_grpc", "This flag only applies if runner_under_bazel is true. This " "flag is ignored if runner_under_bazel is false. " "Directory of the <repo-root>/test directory relative to bazel's " diff --git a/test/cpp/naming/resolver_gce_integration_tests_runner.sh b/test/cpp/naming/resolver_gce_integration_tests_runner.sh index 091f9efbbd..2f673a59fd 100755 --- a/test/cpp/naming/resolver_gce_integration_tests_runner.sh +++ b/test/cpp/naming/resolver_gce_integration_tests_runner.sh @@ -24,7 +24,7 @@ elif [[ "$GRPC_DNS_RESOLVER" != ares ]]; then exit 1 fi -cd $(dirname $0)/../../.. +cd "$(dirname "$0")/../../.." if [[ "$CONFIG" == "" ]]; then export CONFIG=opt diff --git a/test/cpp/performance/BUILD b/test/cpp/performance/BUILD new file mode 100644 index 0000000000..4fe95d5905 --- /dev/null +++ b/test/cpp/performance/BUILD @@ -0,0 +1,34 @@ +# Copyright 2017 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. + +licenses(["notice"]) # Apache v2 + +load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") + +grpc_package(name = "test/cpp/performance") + +grpc_cc_test( + name = "writes_per_rpc_test", + srcs = ["writes_per_rpc_test.cc"], + external_deps = [ + "gtest", + ], + deps = [ + "//:gpr", + "//:grpc", + "//:grpc++", + "//src/proto/grpc/testing:echo_proto", + "//test/core/util:grpc_test_util_base", + ], +) diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 0b9dc83f2b..b7d951a86e 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -142,18 +142,24 @@ class EndpointPairFixture { class InProcessCHTTP2 : public EndpointPairFixture { public: - InProcessCHTTP2(Service* service) - : EndpointPairFixture(service, MakeEndpoints()) {} + InProcessCHTTP2(Service* service, grpc_passthru_endpoint_stats* stats) + : EndpointPairFixture(service, MakeEndpoints(stats)), stats_(stats) {} - int writes_performed() const { return stats_.num_writes; } + virtual ~InProcessCHTTP2() { + if (stats_ != nullptr) { + grpc_passthru_endpoint_stats_destroy(stats_); + } + } + + int writes_performed() const { return stats_->num_writes; } private: - grpc_passthru_endpoint_stats stats_; + grpc_passthru_endpoint_stats* stats_; - grpc_endpoint_pair MakeEndpoints() { + static grpc_endpoint_pair MakeEndpoints(grpc_passthru_endpoint_stats* stats) { grpc_endpoint_pair p; grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq(), - &stats_); + stats); return p; } }; @@ -162,7 +168,8 @@ static double UnaryPingPong(int request_size, int response_size) { const int kIterations = 10000; EchoTestService::AsyncService service; - std::unique_ptr<InProcessCHTTP2> fixture(new InProcessCHTTP2(&service)); + std::unique_ptr<InProcessCHTTP2> fixture( + new InProcessCHTTP2(&service, grpc_passthru_endpoint_stats_create())); EchoRequest send_request; EchoResponse send_response; EchoResponse recv_response; diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 7cf9d3ea7e..e3fba36a7a 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -82,6 +82,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { prepare_req_(prepare_req) {} ~ClientRpcContextUnaryImpl() override {} void Start(CompletionQueue* cq, const ClientConfig& config) override { + GPR_ASSERT(!config.use_coalesce_api()); // not supported. StartInternal(cq); } bool RunNextState(bool ok, HistogramEntry* entry) override { @@ -349,10 +350,11 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { next_state_(State::INVALID), callback_(on_done), next_issue_(next_issue), - prepare_req_(prepare_req) {} + prepare_req_(prepare_req), + coalesce_(false) {} ~ClientRpcContextStreamingPingPongImpl() override {} void Start(CompletionQueue* cq, const ClientConfig& config) override { - StartInternal(cq, config.messages_per_stream()); + StartInternal(cq, config.messages_per_stream(), config.use_coalesce_api()); } bool RunNextState(bool ok, HistogramEntry* entry) override { while (true) { @@ -375,7 +377,12 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { } start_ = UsageTimer::Now(); next_state_ = State::WRITE_DONE; - stream_->Write(req_, ClientRpcContext::tag(this)); + if (coalesce_ && messages_issued_ == messages_per_stream_ - 1) { + stream_->WriteLast(req_, WriteOptions(), + ClientRpcContext::tag(this)); + } else { + stream_->Write(req_, ClientRpcContext::tag(this)); + } return true; case State::WRITE_DONE: if (!ok) { @@ -391,6 +398,11 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { if ((messages_per_stream_ != 0) && (++messages_issued_ >= messages_per_stream_)) { next_state_ = State::WRITES_DONE_DONE; + if (coalesce_) { + // WritesDone should have been called on the last Write. + // loop around to call Finish. + break; + } stream_->WritesDone(ClientRpcContext::tag(this)); return true; } @@ -413,7 +425,7 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { void StartNewClone(CompletionQueue* cq) override { auto* clone = new ClientRpcContextStreamingPingPongImpl( stub_, req_, next_issue_, prepare_req_, callback_); - clone->StartInternal(cq, messages_per_stream_); + clone->StartInternal(cq, messages_per_stream_, coalesce_); } void TryCancel() override { context_.TryCancel(); } @@ -449,14 +461,27 @@ class ClientRpcContextStreamingPingPongImpl : public ClientRpcContext { // Allow a limit on number of messages in a stream int messages_per_stream_; int messages_issued_; + // Whether to use coalescing API. + bool coalesce_; - void StartInternal(CompletionQueue* cq, int messages_per_stream) { + void StartInternal(CompletionQueue* cq, int messages_per_stream, + bool coalesce) { cq_ = cq; messages_per_stream_ = messages_per_stream; messages_issued_ = 0; + coalesce_ = coalesce; + if (coalesce_) { + GPR_ASSERT(messages_per_stream_ != 0); + context_.set_initial_metadata_corked(true); + } stream_ = prepare_req_(stub_, &context_, cq); next_state_ = State::STREAM_IDLE; stream_->StartCall(ClientRpcContext::tag(this)); + if (coalesce_) { + // When the intial metadata is corked, the tag will not come back and we + // need to manually drive the state machine. + RunNextState(true, nullptr); + } } }; @@ -512,6 +537,7 @@ class ClientRpcContextStreamingFromClientImpl : public ClientRpcContext { prepare_req_(prepare_req) {} ~ClientRpcContextStreamingFromClientImpl() override {} void Start(CompletionQueue* cq, const ClientConfig& config) override { + GPR_ASSERT(!config.use_coalesce_api()); // not supported yet. StartInternal(cq); } bool RunNextState(bool ok, HistogramEntry* entry) override { @@ -641,6 +667,7 @@ class ClientRpcContextStreamingFromServerImpl : public ClientRpcContext { prepare_req_(prepare_req) {} ~ClientRpcContextStreamingFromServerImpl() override {} void Start(CompletionQueue* cq, const ClientConfig& config) override { + GPR_ASSERT(!config.use_coalesce_api()); // not supported StartInternal(cq); } bool RunNextState(bool ok, HistogramEntry* entry) override { @@ -753,6 +780,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { prepare_req_(prepare_req) {} ~ClientRpcContextGenericStreamingImpl() override {} void Start(CompletionQueue* cq, const ClientConfig& config) override { + GPR_ASSERT(!config.use_coalesce_api()); // not supported yet. StartInternal(cq, config.messages_per_stream()); } bool RunNextState(bool ok, HistogramEntry* entry) override { diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 82a3f0042d..8c1d9417fa 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -30,10 +30,10 @@ #include <grpc++/server_builder.h> #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/time.h> +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/client.h" @@ -402,6 +402,7 @@ class SynchronousStreamingBothWaysClient final }; std::unique_ptr<Client> CreateSynchronousClient(const ClientConfig& config) { + GPR_ASSERT(!config.use_coalesce_api()); // not supported yet. switch (config.rpc_type()) { case UNARY: return std::unique_ptr<Client>(new SynchronousUnaryClient(config)); diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 2f765a6d1e..4e0d266d77 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -27,13 +27,12 @@ #include <grpc++/client_context.h> #include <grpc++/create_channel.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include "src/core/lib/gpr/env.h" +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/profiling/timers.h" -#include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" #include "test/cpp/qps/client.h" diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 4c9ab0ea43..215a7bfbc9 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -32,9 +32,9 @@ #include <grpc/grpc.h> #include <grpc/support/alloc.h> #include <grpc/support/cpu.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/services.pb.h" #include "test/core/util/grpc_profiler.h" #include "test/core/util/histogram.h" diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 72ae772147..b88b88445c 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -32,9 +32,9 @@ #include <grpc++/support/config.h> #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> #include <grpc/support/log.h> +#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/surface/completion_queue.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/core/util/test_config.h" diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index ea89a30e2e..19cbb53445 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -24,8 +24,8 @@ #include <grpc++/server_context.h> #include <grpc/grpc.h> #include <grpc/support/alloc.h> -#include <grpc/support/host_port.h> +#include "src/core/lib/gpr/host_port.h" #include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/server.h" #include "test/cpp/qps/usage_timer.h" diff --git a/test/cpp/util/BUILD b/test/cpp/util/BUILD index 19e15b1adf..d092ba348e 100644 --- a/test/cpp/util/BUILD +++ b/test/cpp/util/BUILD @@ -74,6 +74,7 @@ grpc_cc_library( deps = [ "//:grpc++", "//test/core/end2end:ssl_test_data", + "//test/core/util:grpc_test_util", ], external_deps = [ "protobuf", @@ -86,6 +87,7 @@ grpc_cc_library( hdrs = GRPCXX_TESTUTIL_HDRS, deps = [ "//:grpc++_unsecure", + "//test/core/util:grpc_test_util", ], external_deps = [ "protobuf", @@ -140,6 +142,10 @@ grpc_cc_test( srcs = [ "grpc_tool_test.cc", ], + data = [ + "//src/proto/grpc/testing:echo.proto", + "//src/proto/grpc/testing:echo_messages.proto" + ], deps = [ ":grpc_cli_libs", ":test_util", diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 4f1a20c727..3b0bb9eeba 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -60,7 +60,8 @@ CliCall::CliCall(std::shared_ptr<grpc::Channel> channel, ctx_.AddMetadata(iter->first, iter->second); } } - call_ = stub_->Call(&ctx_, method, &cq_, tag(1)); + call_ = stub_->PrepareCall(&ctx_, method, &cq_); + call_->StartCall(tag(1)); void* got_tag; bool ok; cq_.Next(&got_tag, &ok); diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc index 0b599f4eeb..135cfdc1f3 100644 --- a/test/cpp/util/grpc_tool_test.cc +++ b/test/cpp/util/grpc_tool_test.cc @@ -31,6 +31,7 @@ #include <grpc/grpc.h> #include <gtest/gtest.h> +#include "src/core/lib/gpr/env.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.pb.h" #include "test/core/util/port.h" @@ -87,6 +88,7 @@ DECLARE_bool(l); DECLARE_bool(batch); DECLARE_string(metadata); DECLARE_string(protofiles); +DECLARE_string(proto_path); namespace { @@ -707,6 +709,10 @@ TEST_F(GrpcToolTest, CallCommandWithBadMetadata) { const char* argv[] = {"grpc_cli", "call", "localhost:10000", "Echo", "message: 'Hello'"}; FLAGS_protofiles = "src/proto/grpc/testing/echo.proto"; + char* test_srcdir = gpr_getenv("TEST_SRCDIR"); + if (test_srcdir != nullptr) { + FLAGS_proto_path = test_srcdir + std::string("/com_github_grpc_grpc"); + } { std::stringstream output_stream; diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc index 0f77934672..42b1f4e75c 100644 --- a/test/cpp/util/proto_reflection_descriptor_database.cc +++ b/test/cpp/util/proto_reflection_descriptor_database.cc @@ -43,6 +43,11 @@ ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() { stream_->WritesDone(); Status status = stream_->Finish(); if (!status.ok()) { + if (status.error_code() == StatusCode::UNIMPLEMENTED) { + gpr_log(GPR_INFO, + "Reflection request not implemented; " + "is the ServerReflection service enabled?"); + } gpr_log(GPR_INFO, "ServerReflectionInfo rpc failed. Error code: %d, details: %s", (int)status.error_code(), status.error_message().c_str()); @@ -64,7 +69,9 @@ bool ProtoReflectionDescriptorDatabase::FindFileByName( request.set_file_by_filename(filename); ServerReflectionResponse response; - DoOneRequest(request, response); + if (!DoOneRequest(request, response)) { + return false; + } if (response.message_response_case() == ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { @@ -109,7 +116,9 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingSymbol( request.set_file_containing_symbol(symbol_name); ServerReflectionResponse response; - DoOneRequest(request, response); + if (!DoOneRequest(request, response)) { + return false; + } if (response.message_response_case() == ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { @@ -163,7 +172,9 @@ bool ProtoReflectionDescriptorDatabase::FindFileContainingExtension( field_number); ServerReflectionResponse response; - DoOneRequest(request, response); + if (!DoOneRequest(request, response)) { + return false; + } if (response.message_response_case() == ServerReflectionResponse::MessageResponseCase::kFileDescriptorResponse) { @@ -213,7 +224,9 @@ bool ProtoReflectionDescriptorDatabase::FindAllExtensionNumbers( request.set_all_extension_numbers_of_type(extendee_type); ServerReflectionResponse response; - DoOneRequest(request, response); + if (!DoOneRequest(request, response)) { + return false; + } if (response.message_response_case() == ServerReflectionResponse::MessageResponseCase:: @@ -245,7 +258,9 @@ bool ProtoReflectionDescriptorDatabase::GetServices( request.set_list_services(""); ServerReflectionResponse response; - DoOneRequest(request, response); + if (!DoOneRequest(request, response)) { + return false; + } if (response.message_response_case() == ServerReflectionResponse::MessageResponseCase::kListServicesResponse) { diff --git a/test/cpp/util/subprocess.cc b/test/cpp/util/subprocess.cc index a54d0c087a..ddaad89805 100644 --- a/test/cpp/util/subprocess.cc +++ b/test/cpp/util/subprocess.cc @@ -20,7 +20,7 @@ #include <vector> -#include <grpc/support/subprocess.h> +#include "test/core/util/subprocess.h" namespace grpc { diff --git a/test/distrib/cpp/run_distrib_test_cmake.bat b/test/distrib/cpp/run_distrib_test_cmake.bat index f920768ae3..8eb3b201b1 100644 --- a/test/distrib/cpp/run_distrib_test_cmake.bat +++ b/test/distrib/cpp/run_distrib_test_cmake.bat @@ -54,7 +54,7 @@ cd ../../../.. cd cmake mkdir build cd build -cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%/include -DZLIB_LIBRARY=%INSTALL_DIR%/lib/zlibstatic.lib -DZLIB_INCLUDE_DIR=%INSTALL_DIR%/include -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ../.. || goto :error +cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DZLIB_ROOT=%INSTALL_DIR% -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ../.. || goto :error cmake --build . --config Release --target install || goto :error cd ../.. @@ -64,7 +64,7 @@ mkdir cmake cd cmake mkdir build cd build -cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DOPENSSL_INCLUDE_DIR=%OPENSSL_DIR%/include ../.. || goto :error +cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DZLIB_ROOT=%INSTALL_DIR% ../.. || goto :error cmake --build . --config Release || goto :error cd ../../../../.. diff --git a/test/distrib/cpp/run_distrib_test_cmake.sh b/test/distrib/cpp/run_distrib_test_cmake.sh index a9c081c2f5..6ec3cab602 100755 --- a/test/distrib/cpp/run_distrib_test_cmake.sh +++ b/test/distrib/cpp/run_distrib_test_cmake.sh @@ -15,7 +15,7 @@ set -ex -cd $(dirname $0)/../../.. +cd "$(dirname "$0")/../../.." echo "deb http://ftp.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list apt-get update diff --git a/test/distrib/cpp/run_distrib_test_routeguide.sh b/test/distrib/cpp/run_distrib_test_routeguide.sh index b043075d93..dc69ab8377 100755 --- a/test/distrib/cpp/run_distrib_test_routeguide.sh +++ b/test/distrib/cpp/run_distrib_test_routeguide.sh @@ -16,7 +16,7 @@ set -ex # change to grpc repo root -cd $(dirname $0)/../../.. +cd "$(dirname "$0")/../../.." cd third_party/protobuf && ./autogen.sh && \ ./configure && make -j4 && make check && make install && ldconfig diff --git a/test/distrib/csharp/run_distrib_test.sh b/test/distrib/csharp/run_distrib_test.sh index 99cdb5e022..eee24d0e57 100755 --- a/test/distrib/csharp/run_distrib_test.sh +++ b/test/distrib/csharp/run_distrib_test.sh @@ -15,7 +15,7 @@ set -ex -cd $(dirname $0) +cd "$(dirname "$0")" unzip -o "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets_windows_dotnetcli.zip" -d TestNugetFeed diff --git a/test/distrib/csharp/run_distrib_test_dotnetcli.sh b/test/distrib/csharp/run_distrib_test_dotnetcli.sh index 53117d4828..9e31945dfb 100755 --- a/test/distrib/csharp/run_distrib_test_dotnetcli.sh +++ b/test/distrib/csharp/run_distrib_test_dotnetcli.sh @@ -15,7 +15,7 @@ set -ex -cd $(dirname $0) +cd "$(dirname "$0")" unzip -o "$EXTERNAL_GIT_ROOT/input_artifacts/csharp_nugets_windows_dotnetcli.zip" -d TestNugetFeed diff --git a/test/distrib/csharp/update_version.sh b/test/distrib/csharp/update_version.sh index 2e9050cb98..734ec21ba2 100755 --- a/test/distrib/csharp/update_version.sh +++ b/test/distrib/csharp/update_version.sh @@ -15,12 +15,14 @@ set -e -cd $(dirname $0) +cd "$(dirname "$0")" CSHARP_VERSION="$1" if [ "$CSHARP_VERSION" == "auto" ] then # autodetect C# version from the name of Grpc.Core.0.0.0-x.nupkg file + # TODO: find a better shellcheck-compliant way to write the following line + # shellcheck disable=SC2010 CSHARP_VERSION=$(ls TestNugetFeed | grep -m 1 '^Grpc\.Core\.[0-9].*\.nupkg$' | sed s/^Grpc\.Core\.// | sed s/\.nupkg$// | sed s/\.symbols$//) echo "Autodetected nuget ${CSHARP_VERSION}" fi diff --git a/test/distrib/php/run_distrib_test.sh b/test/distrib/php/run_distrib_test.sh index 70ebaf88b9..f781815840 100755 --- a/test/distrib/php/run_distrib_test.sh +++ b/test/distrib/php/run_distrib_test.sh @@ -15,9 +15,9 @@ set -ex -cd $(dirname $0) +cd "$(dirname "$0")" -cp -r $EXTERNAL_GIT_ROOT/input_artifacts/grpc-*.tgz . +cp -r "$EXTERNAL_GIT_ROOT"/input_artifacts/grpc-*.tgz . find . -regextype sed -regex ".*/grpc-[0-9].*.tgz" | cut -b3- | \ xargs pecl install diff --git a/test/distrib/python/run_distrib_test.sh b/test/distrib/python/run_distrib_test.sh index 02654be467..a855ae3b61 100755 --- a/test/distrib/python/run_distrib_test.sh +++ b/test/distrib/python/run_distrib_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2015 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,23 +15,25 @@ set -ex -cd $(dirname $0) +cd "$(dirname "$0")" + +shopt -s nullglob # Pick up the source dist archive whatever its version is -SDIST_ARCHIVES=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-*.tar.gz -BDIST_ARCHIVES=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio-*.whl -TOOLS_SDIST_ARCHIVES=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio_tools-*.tar.gz -TOOLS_BDIST_ARCHIVES=$EXTERNAL_GIT_ROOT/input_artifacts/grpcio_tools-*.whl +SDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-*.tar.gz) +BDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio-*.whl) +TOOLS_SDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_tools-*.tar.gz) +TOOLS_BDIST_ARCHIVES=("$EXTERNAL_GIT_ROOT"/input_artifacts/grpcio_tools-*.whl) function make_virtualenv() { - virtualenv $1 - $1/bin/python -m pip install --upgrade six pip - $1/bin/python -m pip install cython + virtualenv "$1" + "$1/bin/python" -m pip install --upgrade six pip + "$1/bin/python" -m pip install cython } function at_least_one_installs() { for file in "$@"; do - if python -m pip install $file; then + if python -m pip install "$file"; then return 0 fi done @@ -45,11 +47,11 @@ make_virtualenv sdist_test # Install our distributions in order of dependencies # -(source bdist_test/bin/activate && at_least_one_installs ${BDIST_ARCHIVES}) -(source bdist_test/bin/activate && at_least_one_installs ${TOOLS_BDIST_ARCHIVES}) +(source bdist_test/bin/activate && at_least_one_installs "${BDIST_ARCHIVES[@]}") +(source bdist_test/bin/activate && at_least_one_installs "${TOOLS_BDIST_ARCHIVES[@]}") -(source sdist_test/bin/activate && at_least_one_installs ${SDIST_ARCHIVES}) -(source sdist_test/bin/activate && at_least_one_installs ${TOOLS_SDIST_ARCHIVES}) +(source sdist_test/bin/activate && at_least_one_installs "${SDIST_ARCHIVES[@]}") +(source sdist_test/bin/activate && at_least_one_installs "${TOOLS_SDIST_ARCHIVES[@]}") # # Test our distributions diff --git a/test/distrib/ruby/run_distrib_test.sh b/test/distrib/ruby/run_distrib_test.sh index d74f4cd76d..99fb873589 100755 --- a/test/distrib/ruby/run_distrib_test.sh +++ b/test/distrib/ruby/run_distrib_test.sh @@ -15,20 +15,22 @@ set -ex -cd $(dirname $0) +cd "$(dirname "$0")" ARCH=$1 PLATFORM=$2 # Create an indexed local gem source with gRPC gems to test GEM_SOURCE=../../../gem_source -mkdir -p ${GEM_SOURCE}/gems -cp $EXTERNAL_GIT_ROOT/input_artifacts/grpc-*$ARCH-$PLATFORM.gem ${GEM_SOURCE}/gems -if [[ "$(ls ${GEM_SOURCE}/gems | grep grpc | wc -l)" != 1 ]]; then +mkdir -p "${GEM_SOURCE}/gems" +cp "$EXTERNAL_GIT_ROOT"/input_artifacts/grpc-*"$ARCH-$PLATFORM".gem "${GEM_SOURCE}/gems" +# TODO: rewrite the following line to be shellcheck-compliant +# shellcheck disable=SC2010 +if [[ "$(ls "${GEM_SOURCE}/gems" | grep -c grpc)" != 1 ]]; then echo "Sanity check failed. Copied over more than one grpc gem into the gem source directory." exit 1 fi; gem install builder -gem generate_index --directory ${GEM_SOURCE} +gem generate_index --directory "${GEM_SOURCE}" bundle install |