Skip to content

Commit

Permalink
Merge pull request grpc#18082 from rmstar/cfstreamtestv2
Browse files Browse the repository at this point in the history
Re-add cfstream_test
  • Loading branch information
rmstar committed Feb 20, 2019
2 parents b03e014 + 1ee4706 commit 22109ad
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 8 deletions.
7 changes: 7 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ config_setting(
values = {"cpu": "x64_windows_msvc"},
)

config_setting(
name = "mac_x86_64",
values = {"cpu": "darwin"},
)

# This should be updated along with build.yaml
g_stands_for = "godric"

Expand Down Expand Up @@ -981,6 +986,7 @@ grpc_cc_library(
],
language = "c++",
public_hdrs = GRPC_PUBLIC_HDRS,
use_cfstream = True,
deps = [
"gpr_base",
"grpc_codegen",
Expand Down Expand Up @@ -1044,6 +1050,7 @@ grpc_cc_library(
"src/core/lib/iomgr/endpoint_cfstream.h",
"src/core/lib/iomgr/error_cfstream.h",
],
use_cfstream = True,
deps = [
":gpr_base",
":grpc_base",
Expand Down
23 changes: 17 additions & 6 deletions bazel/grpc_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def if_not_windows(a):
"//conditions:default": a,
})

def if_mac(a):
return select({
"//:mac_x86_64": a,
"//conditions:default": [],
})

def _get_external_deps(external_deps):
ret = []
for dep in external_deps:
Expand Down Expand Up @@ -73,10 +79,16 @@ def grpc_cc_library(
testonly = False,
visibility = None,
alwayslink = 0,
data = []):
data = [],
use_cfstream = False):
copts = []
if use_cfstream:
copts = if_mac(["-DGRPC_CFSTREAM"])
if language.upper() == "C":
copts = if_not_windows(["-std=c99"])
copts = copts + if_not_windows(["-std=c99"])
linkopts = if_not_windows(["-pthread"])
if use_cfstream:
linkopts = linkopts + if_mac(["-framework CoreFoundation"])
native.cc_library(
name = name,
srcs = srcs,
Expand All @@ -98,7 +110,7 @@ def grpc_cc_library(
copts = copts,
visibility = visibility,
testonly = testonly,
linkopts = if_not_windows(["-pthread"]),
linkopts = linkopts,
includes = [
"include",
],
Expand All @@ -113,7 +125,6 @@ def grpc_proto_plugin(name, srcs = [], deps = []):
deps = deps,
)


def grpc_proto_library(
name,
srcs = [],
Expand All @@ -133,9 +144,9 @@ def grpc_proto_library(
)

def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True, language = "C++", size = "medium", timeout = None, tags = [], exec_compatible_with = []):
copts = []
copts = if_mac(["-DGRPC_CFSTREAM"])
if language.upper() == "C":
copts = if_not_windows(["-std=c99"])
copts = copts + if_not_windows(["-std=c99"])
args = {
"name": name,
"srcs": srcs,
Expand Down
4 changes: 2 additions & 2 deletions src/core/lib/iomgr/endpoint_cfstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static void ReadAction(void* arg, grpc_error* error) {
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Socket closed"), ep));
EP_UNREF(ep, "read");
} else {
if (read_size < len) {
if (read_size < static_cast<CFIndex>(len)) {
grpc_slice_buffer_trim_end(ep->read_slices, len - read_size, nullptr);
}
CallReadCb(ep, GRPC_ERROR_NONE);
Expand Down Expand Up @@ -217,7 +217,7 @@ static void WriteAction(void* arg, grpc_error* error) {
CallWriteCb(ep, error);
EP_UNREF(ep, "write");
} else {
if (write_size < GRPC_SLICE_LENGTH(slice)) {
if (write_size < static_cast<CFIndex>(GRPC_SLICE_LENGTH(slice))) {
grpc_slice_buffer_undo_take_first(
ep->write_slices, grpc_slice_sub(slice, write_size, slice_len));
}
Expand Down
21 changes: 21 additions & 0 deletions test/cpp/end2end/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,24 @@ grpc_cc_test(
"//test/cpp/util:test_util",
],
)

grpc_cc_test(
name = "cfstream_test",
srcs = ["cfstream_test.cc"],
external_deps = [
"gtest",
],
tags = ["manual"], # test requires root, won't work with bazel RBE
deps = [
":test_service_impl",
"//:gpr",
"//:grpc",
"//:grpc++",
"//:grpc_cfstream",
"//src/proto/grpc/testing:echo_messages_proto",
"//src/proto/grpc/testing:echo_proto",
"//src/proto/grpc/testing:simple_messages_proto",
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
)
Loading

0 comments on commit 22109ad

Please sign in to comment.