aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-03-08 12:52:39 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-03-08 12:52:39 -0800
commite83edbfc2fde65b0814e8c0249f25105fd44d69b (patch)
tree500b193fed466a972c91aaad52094ab2203d44d6 /test
parent1ffda9f292fc3a104c8597c16bcdffa9083f8b95 (diff)
parent808d19e83438b27a768d68517662d0e11fb7484c (diff)
Merge github.com:grpc/grpc into bm_channel
Diffstat (limited to 'test')
-rw-r--r--test/core/client_channel/parse_address_test.c116
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.c2
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_test.c4
-rw-r--r--test/core/client_channel/resolvers/sockaddr_resolver_test.c4
-rw-r--r--test/core/client_channel/uri_fuzzer_test.c5
-rw-r--r--test/core/client_channel/uri_parser_test.c23
-rw-r--r--test/core/end2end/BUILD4
-rw-r--r--test/core/end2end/fixtures/h2_http_proxy.c2
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.c (renamed from test/core/end2end/fixtures/http_proxy.c)2
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.h (renamed from test/core/end2end/fixtures/http_proxy.h)0
-rw-r--r--test/core/fling/fling_stream_test.c81
-rw-r--r--test/core/iomgr/sockaddr_utils_test.c16
-rw-r--r--test/core/slice/percent_encoding_test.c1
-rw-r--r--test/core/util/port_server_client.c9
-rw-r--r--test/cpp/microbenchmarks/helpers.cc65
-rw-r--r--test/cpp/microbenchmarks/helpers.h32
16 files changed, 271 insertions, 95 deletions
diff --git a/test/core/client_channel/parse_address_test.c b/test/core/client_channel/parse_address_test.c
new file mode 100644
index 0000000000..37dd0fba52
--- /dev/null
+++ b/test/core/client_channel/parse_address_test.c
@@ -0,0 +1,116 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "src/core/ext/client_channel/parse_address.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+
+#include <string.h>
+#ifdef GRPC_HAVE_UNIX_SOCKET
+#include <sys/un.h>
+#endif
+
+#include <grpc/support/log.h>
+
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/iomgr/socket_utils.h"
+#include "test/core/util/test_config.h"
+
+#ifdef GRPC_HAVE_UNIX_SOCKET
+
+static void test_parse_unix(const char *uri_text, const char *pathname) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_resolved_address addr;
+
+ GPR_ASSERT(1 == parse_unix(uri, &addr));
+ struct sockaddr_un *addr_un = (struct sockaddr_un *)addr.addr;
+ GPR_ASSERT(AF_UNIX == addr_un->sun_family);
+ GPR_ASSERT(0 == strcmp(addr_un->sun_path, pathname));
+
+ grpc_uri_destroy(uri);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+#else /* GRPC_HAVE_UNIX_SOCKET */
+
+static void test_parse_unix(const char *uri_text, const char *pathname) {}
+
+#endif /* GRPC_HAVE_UNIX_SOCKET */
+
+static void test_parse_ipv4(const char *uri_text, const char *host,
+ unsigned short port) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_resolved_address addr;
+ char ntop_buf[INET_ADDRSTRLEN];
+
+ GPR_ASSERT(1 == parse_ipv4(uri, &addr));
+ struct sockaddr_in *addr_in = (struct sockaddr_in *)addr.addr;
+ GPR_ASSERT(AF_INET == addr_in->sin_family);
+ GPR_ASSERT(NULL != grpc_inet_ntop(AF_INET, &addr_in->sin_addr, ntop_buf,
+ sizeof(ntop_buf)));
+ GPR_ASSERT(0 == strcmp(ntop_buf, host));
+ GPR_ASSERT(ntohs(addr_in->sin_port) == port);
+
+ grpc_uri_destroy(uri);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+static void test_parse_ipv6(const char *uri_text, const char *host,
+ unsigned short port, uint32_t scope_id) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
+ grpc_resolved_address addr;
+ char ntop_buf[INET6_ADDRSTRLEN];
+
+ GPR_ASSERT(1 == parse_ipv6(uri, &addr));
+ struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr.addr;
+ GPR_ASSERT(AF_INET6 == addr_in6->sin6_family);
+ GPR_ASSERT(NULL != grpc_inet_ntop(AF_INET6, &addr_in6->sin6_addr, ntop_buf,
+ sizeof(ntop_buf)));
+ GPR_ASSERT(0 == strcmp(ntop_buf, host));
+ GPR_ASSERT(ntohs(addr_in6->sin6_port) == port);
+ GPR_ASSERT(addr_in6->sin6_scope_id == scope_id);
+
+ grpc_uri_destroy(uri);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+int main(int argc, char **argv) {
+ grpc_test_init(argc, argv);
+
+ test_parse_unix("unix:/path/name", "/path/name");
+ test_parse_ipv4("ipv4:192.0.2.1:12345", "192.0.2.1", 12345);
+ test_parse_ipv6("ipv6:[2001:db8::1]:12345", "2001:db8::1", 12345, 0);
+ test_parse_ipv6("ipv6:[2001:db8::1%252]:12345", "2001:db8::1", 12345, 2);
+}
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
index 3e3401165c..187757d5b3 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
@@ -69,7 +69,7 @@ static grpc_error *my_resolve_address(const char *name, const char *addr,
static grpc_resolver *create_resolver(grpc_exec_ctx *exec_ctx,
const char *name) {
grpc_resolver_factory *factory = grpc_resolver_factory_lookup("dns");
- grpc_uri *uri = grpc_uri_parse(name, 0);
+ grpc_uri *uri = grpc_uri_parse(exec_ctx, name, 0);
GPR_ASSERT(uri);
grpc_resolver_args args;
memset(&args, 0, sizeof(args));
diff --git a/test/core/client_channel/resolvers/dns_resolver_test.c b/test/core/client_channel/resolvers/dns_resolver_test.c
index 9dd5aed091..919a85d58f 100644
--- a/test/core/client_channel/resolvers/dns_resolver_test.c
+++ b/test/core/client_channel/resolvers/dns_resolver_test.c
@@ -43,7 +43,7 @@ static grpc_combiner *g_combiner;
static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(string, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
grpc_resolver_args args;
grpc_resolver *resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -61,7 +61,7 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
static void test_fails(grpc_resolver_factory *factory, const char *string) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(string, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
grpc_resolver_args args;
grpc_resolver *resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
diff --git a/test/core/client_channel/resolvers/sockaddr_resolver_test.c b/test/core/client_channel/resolvers/sockaddr_resolver_test.c
index 68831ab7c7..bc4f02c339 100644
--- a/test/core/client_channel/resolvers/sockaddr_resolver_test.c
+++ b/test/core/client_channel/resolvers/sockaddr_resolver_test.c
@@ -57,7 +57,7 @@ void on_resolution_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(string, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
grpc_resolver_args args;
grpc_resolver *resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string,
@@ -84,7 +84,7 @@ static void test_succeeds(grpc_resolver_factory *factory, const char *string) {
static void test_fails(grpc_resolver_factory *factory, const char *string) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_uri *uri = grpc_uri_parse(string, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, string, 0);
grpc_resolver_args args;
grpc_resolver *resolver;
gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string,
diff --git a/test/core/client_channel/uri_fuzzer_test.c b/test/core/client_channel/uri_fuzzer_test.c
index d2e3fb40ea..baadd4fc65 100644
--- a/test/core/client_channel/uri_fuzzer_test.c
+++ b/test/core/client_channel/uri_fuzzer_test.c
@@ -38,6 +38,7 @@
#include <grpc/support/alloc.h>
#include "src/core/ext/client_channel/uri_parser.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
bool squelch = true;
bool leak_check = true;
@@ -47,10 +48,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
memcpy(s, data, size);
s[size] = 0;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_uri *x;
- if ((x = grpc_uri_parse(s, 1))) {
+ if ((x = grpc_uri_parse(&exec_ctx, s, 1))) {
grpc_uri_destroy(x);
}
+ grpc_exec_ctx_finish(&exec_ctx);
gpr_free(s);
return 0;
}
diff --git a/test/core/client_channel/uri_parser_test.c b/test/core/client_channel/uri_parser_test.c
index 5f32d3270c..8a127f72eb 100644
--- a/test/core/client_channel/uri_parser_test.c
+++ b/test/core/client_channel/uri_parser_test.c
@@ -37,29 +37,35 @@
#include <grpc/support/log.h>
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "test/core/util/test_config.h"
static void test_succeeds(const char *uri_text, const char *scheme,
const char *authority, const char *path,
const char *query, const char *fragment) {
- grpc_uri *uri = grpc_uri_parse(uri_text, 0);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp(scheme, uri->scheme));
GPR_ASSERT(0 == strcmp(authority, uri->authority));
GPR_ASSERT(0 == strcmp(path, uri->path));
GPR_ASSERT(0 == strcmp(query, uri->query));
GPR_ASSERT(0 == strcmp(fragment, uri->fragment));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_uri_destroy(uri);
}
static void test_fails(const char *uri_text) {
- GPR_ASSERT(NULL == grpc_uri_parse(uri_text, 0));
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ GPR_ASSERT(NULL == grpc_uri_parse(&exec_ctx, uri_text, 0));
+ grpc_exec_ctx_finish(&exec_ctx);
}
static void test_query_parts() {
{
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
const char *uri_text = "http://foo/path?a&b=B&c=&#frag";
- grpc_uri *uri = grpc_uri_parse(uri_text, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -86,12 +92,14 @@ static void test_query_parts() {
GPR_ASSERT(NULL == grpc_uri_get_query_arg(uri, ""));
GPR_ASSERT(0 == strcmp("frag", uri->fragment));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_uri_destroy(uri);
}
{
/* test the current behavior of multiple query part values */
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
const char *uri_text = "http://auth/path?foo=bar=baz&foobar==";
- grpc_uri *uri = grpc_uri_parse(uri_text, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -103,12 +111,14 @@ static void test_query_parts() {
GPR_ASSERT(0 == strcmp("bar", grpc_uri_get_query_arg(uri, "foo")));
GPR_ASSERT(0 == strcmp("", grpc_uri_get_query_arg(uri, "foobar")));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_uri_destroy(uri);
}
{
/* empty query */
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
const char *uri_text = "http://foo/path";
- grpc_uri *uri = grpc_uri_parse(uri_text, 0);
+ grpc_uri *uri = grpc_uri_parse(&exec_ctx, uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp("http", uri->scheme));
@@ -119,6 +129,7 @@ static void test_query_parts() {
GPR_ASSERT(NULL == uri->query_parts);
GPR_ASSERT(NULL == uri->query_parts_values);
GPR_ASSERT(0 == strcmp("", uri->fragment));
+ grpc_exec_ctx_finish(&exec_ctx);
grpc_uri_destroy(uri);
}
}
@@ -142,6 +153,8 @@ int main(int argc, char **argv) {
test_succeeds("http:?legit#twice", "http", "", "", "legit", "twice");
test_succeeds("http://foo?bar#lol?", "http", "foo", "", "bar", "lol?");
test_succeeds("http://foo?bar#lol?/", "http", "foo", "", "bar", "lol?/");
+ test_succeeds("ipv6:[2001:db8::1%252]:12345", "ipv6", "",
+ "[2001:db8::1%2]:12345", "", "");
test_fails("xyz");
test_fails("http:?dangling-pct-%0");
diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD
index a40fb8e083..0cef7aa01d 100644
--- a/test/core/end2end/BUILD
+++ b/test/core/end2end/BUILD
@@ -63,8 +63,8 @@ cc_library(
cc_library(
name = 'http_proxy',
- hdrs = ['fixtures/http_proxy.h'],
- srcs = ['fixtures/http_proxy.c'],
+ hdrs = ['fixtures/http_proxy_fixture.h'],
+ srcs = ['fixtures/http_proxy_fixture.c'],
copts = ['-std=c99'],
deps = ['//:gpr', '//:grpc', '//test/core/util:grpc_test_util']
)
diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c
index 44b223664a..55c65fa70e 100644
--- a/test/core/end2end/fixtures/h2_http_proxy.c
+++ b/test/core/end2end/fixtures/h2_http_proxy.c
@@ -49,7 +49,7 @@
#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
-#include "test/core/end2end/fixtures/http_proxy.h"
+#include "test/core/end2end/fixtures/http_proxy_fixture.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
diff --git a/test/core/end2end/fixtures/http_proxy.c b/test/core/end2end/fixtures/http_proxy_fixture.c
index 9ccb1263ee..bcd1c9914b 100644
--- a/test/core/end2end/fixtures/http_proxy.c
+++ b/test/core/end2end/fixtures/http_proxy_fixture.c
@@ -31,7 +31,7 @@
*
*/
-#include "test/core/end2end/fixtures/http_proxy.h"
+#include "test/core/end2end/fixtures/http_proxy_fixture.h"
#include "src/core/lib/iomgr/sockaddr.h"
diff --git a/test/core/end2end/fixtures/http_proxy.h b/test/core/end2end/fixtures/http_proxy_fixture.h
index cd47b432af..cd47b432af 100644
--- a/test/core/end2end/fixtures/http_proxy.h
+++ b/test/core/end2end/fixtures/http_proxy_fixture.h
diff --git a/test/core/fling/fling_stream_test.c b/test/core/fling/fling_stream_test.c
index 7e4daaa84f..948659ab2f 100644
--- a/test/core/fling/fling_stream_test.c
+++ b/test/core/fling/fling_stream_test.c
@@ -31,22 +31,13 @@
*
*/
-#ifndef _POSIX_SOURCE
-#define _POSIX_SOURCE
-#endif
-
-#include <assert.h>
-#include <signal.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/host_port.h>
#include <grpc/support/string_util.h>
+#include <grpc/support/subprocess.h>
#include "src/core/lib/support/string.h"
#include "test/core/util/port.h"
@@ -57,10 +48,7 @@ int main(int argc, char **argv) {
int port = grpc_pick_unused_port_or_die();
char *args[10];
int status;
- pid_t svr, cli;
- /* seed rng with pid, so we don't end up with the same random numbers as a
- concurrently running test binary */
- srand((unsigned)getpid());
+ gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
memcpy(root, me, (size_t)(lslash - me));
@@ -69,45 +57,38 @@ int main(int argc, char **argv) {
strcpy(root, ".");
}
/* start the server */
- svr = fork();
- if (svr == 0) {
- gpr_asprintf(&args[0], "%s/fling_server", root);
- args[1] = "--bind";
- gpr_join_host_port(&args[2], "::", port);
- args[3] = "--no-secure";
- args[4] = 0;
- execv(args[0], args);
+ gpr_asprintf(&args[0], "%s/fling_server%s", root,
+ gpr_subprocess_binary_extension());
+ args[1] = "--bind";
+ gpr_join_host_port(&args[2], "::", port);
+ args[3] = "--no-secure";
+ svr = gpr_subprocess_create(4, (const char **)args);
+ gpr_free(args[0]);
+ gpr_free(args[2]);
- gpr_free(args[0]);
- gpr_free(args[2]);
- return 1;
- }
- /* wait a little */
- sleep(2);
/* start the client */
- cli = fork();
- if (cli == 0) {
- gpr_asprintf(&args[0], "%s/fling_client", root);
- args[1] = "--target";
- gpr_join_host_port(&args[2], "127.0.0.1", port);
- args[3] = "--scenario=ping-pong-stream";
- args[4] = "--no-secure";
- args[5] = 0;
- execv(args[0], args);
+ gpr_asprintf(&args[0], "%s/fling_client%s", root,
+ gpr_subprocess_binary_extension());
+ args[1] = "--target";
+ gpr_join_host_port(&args[2], "127.0.0.1", port);
+ args[3] = "--scenario=ping-pong-stream";
+ args[4] = "--no-secure";
+ args[5] = 0;
+ cli = gpr_subprocess_create(6, (const char **)args);
+ gpr_free(args[0]);
+ gpr_free(args[2]);
- gpr_free(args[0]);
- gpr_free(args[2]);
- return 1;
- }
/* wait for completion */
printf("waiting for client\n");
- if (waitpid(cli, &status, 0) == -1) return 2;
- if (!WIFEXITED(status)) return 4;
- if (WEXITSTATUS(status)) return WEXITSTATUS(status);
- printf("waiting for server\n");
- kill(svr, SIGINT);
- if (waitpid(svr, &status, 0) == -1) return 2;
- if (!WIFEXITED(status)) return 4;
- if (WEXITSTATUS(status)) return WEXITSTATUS(status);
- return 0;
+ if ((status = gpr_subprocess_join(cli))) {
+ gpr_subprocess_destroy(cli);
+ gpr_subprocess_destroy(svr);
+ return status;
+ }
+ gpr_subprocess_destroy(cli);
+
+ gpr_subprocess_interrupt(svr);
+ status = gpr_subprocess_join(svr);
+ gpr_subprocess_destroy(svr);
+ return status;
}
diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.c
index 8569c697fe..70a6c323e5 100644
--- a/test/core/iomgr/sockaddr_utils_test.c
+++ b/test/core/iomgr/sockaddr_utils_test.c
@@ -70,6 +70,12 @@ static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) {
return resolved_addr6;
}
+static void set_addr6_scope_id(grpc_resolved_address *addr, uint32_t scope_id) {
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr->addr;
+ GPR_ASSERT(addr6->sin6_family == AF_INET6);
+ addr6->sin6_scope_id = scope_id;
+}
+
static const uint8_t kMapped[] = {0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0xff, 0xff, 192, 0, 2, 1};
@@ -222,6 +228,16 @@ static void test_sockaddr_to_string(void) {
expect_sockaddr_str("[2001:db8::1]:12345", &input6, 1);
expect_sockaddr_uri("ipv6:[2001:db8::1]:12345", &input6);
+ set_addr6_scope_id(&input6, 2);
+ expect_sockaddr_str("[2001:db8::1%252]:12345", &input6, 0);
+ expect_sockaddr_str("[2001:db8::1%252]:12345", &input6, 1);
+ expect_sockaddr_uri("ipv6:[2001:db8::1%252]:12345", &input6);
+
+ set_addr6_scope_id(&input6, 101);
+ expect_sockaddr_str("[2001:db8::1%25101]:12345", &input6, 0);
+ expect_sockaddr_str("[2001:db8::1%25101]:12345", &input6, 1);
+ expect_sockaddr_uri("ipv6:[2001:db8::1%25101]:12345", &input6);
+
input6 = make_addr6(kMapped, sizeof(kMapped));
expect_sockaddr_str("[::ffff:192.0.2.1]:12345", &input6, 0);
expect_sockaddr_str("192.0.2.1:12345", &input6, 1);
diff --git a/test/core/slice/percent_encoding_test.c b/test/core/slice/percent_encoding_test.c
index 222e695fd4..89f8154955 100644
--- a/test/core/slice/percent_encoding_test.c
+++ b/test/core/slice/percent_encoding_test.c
@@ -146,6 +146,7 @@ int main(int argc, char **argv) {
TEST_VECTOR("\x0f", "%0F", grpc_url_percent_encoding_unreserved_bytes);
TEST_VECTOR("\xff", "%FF", grpc_url_percent_encoding_unreserved_bytes);
TEST_VECTOR("\xee", "%EE", grpc_url_percent_encoding_unreserved_bytes);
+ TEST_VECTOR("%2", "%252", grpc_url_percent_encoding_unreserved_bytes);
TEST_NONCONFORMANT_VECTOR("%", "%",
grpc_url_percent_encoding_unreserved_bytes);
TEST_NONCONFORMANT_VECTOR("%A", "%A",
diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c
index a851d01635..38054dd1e7 100644
--- a/test/core/util/port_server_client.c
+++ b/test/core/util/port_server_client.c
@@ -162,6 +162,15 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
if (failed) {
grpc_httpcli_request req;
memset(&req, 0, sizeof(req));
+ if (pr->retries >= 5) {
+ gpr_mu_lock(pr->mu);
+ pr->port = 0;
+ GRPC_LOG_IF_ERROR(
+ "pollset_kick",
+ grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), NULL));
+ gpr_mu_unlock(pr->mu);
+ return;
+ }
GPR_ASSERT(pr->retries < 10);
gpr_sleep_until(gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME),
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
new file mode 100644
index 0000000000..947e81ffd8
--- /dev/null
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "test/cpp/microbenchmarks/helpers.h"
+
+void TrackCounters::Finish(benchmark::State &state) {
+ std::ostringstream out;
+ AddToLabel(out, state);
+ auto label = out.str();
+ if (label.length() && label[0] == ' ') {
+ label = label.substr(1);
+ }
+ state.SetLabel(label);
+}
+
+void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
+#ifdef GPR_LOW_LEVEL_COUNTERS
+ out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) -
+ mu_locks_at_start_) /
+ (double)state.iterations())
+ << " atm_cas/iter:"
+ << ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_cas) -
+ atm_cas_at_start_) /
+ (double)state.iterations())
+ << " atm_add/iter:"
+ << ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_add) -
+ atm_add_at_start_) /
+ (double)state.iterations());
+#endif
+ grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
+ out << " allocs/iter:"
+ << ((double)(counters_at_end.total_allocs_absolute -
+ counters_at_start_.total_allocs_absolute) /
+ (double)state.iterations());
+}
diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h
index ea9024dce5..42a8fbaf0b 100644
--- a/test/cpp/microbenchmarks/helpers.h
+++ b/test/cpp/microbenchmarks/helpers.h
@@ -74,36 +74,8 @@ extern "C" gpr_atm gpr_counter_atm_add;
class TrackCounters {
public:
- virtual void Finish(benchmark::State& state) {
- std::ostringstream out;
- AddToLabel(out, state);
- auto label = out.str();
- if (label.length() && label[0] == ' ') {
- label = label.substr(1);
- }
- state.SetLabel(label);
- }
-
- virtual void AddToLabel(std::ostream& out, benchmark::State& state) {
-#ifdef GPR_LOW_LEVEL_COUNTERS
- out << " locks/iter:" << ((double)(gpr_atm_no_barrier_load(&gpr_mu_locks) -
- mu_locks_at_start_) /
- (double)state.iterations())
- << " atm_cas/iter:"
- << ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_cas) -
- atm_cas_at_start_) /
- (double)state.iterations())
- << " atm_add/iter:"
- << ((double)(gpr_atm_no_barrier_load(&gpr_counter_atm_add) -
- atm_add_at_start_) /
- (double)state.iterations());
-#endif
- grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
- out << " allocs/iter:"
- << ((double)(counters_at_end.total_allocs_absolute -
- counters_at_start_.total_allocs_absolute) /
- (double)state.iterations());
- }
+ virtual void Finish(benchmark::State& state);
+ virtual void AddToLabel(std::ostream& out, benchmark::State& state);
private:
#ifdef GPR_LOW_LEVEL_COUNTERS