Skip to content

Commit

Permalink
Make C++ alarm class usable and testable - there were some build issu…
Browse files Browse the repository at this point in the history
…es and

it was not actually even included in the library or the test suite.
  • Loading branch information
vjpai committed Feb 11, 2016
1 parent 42fad8e commit 04e992a
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 2 deletions.
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ cc_library(
"src/cpp/client/credentials.cc",
"src/cpp/client/generic_stub.cc",
"src/cpp/client/insecure_credentials.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc",
Expand Down Expand Up @@ -991,6 +992,7 @@ cc_library(
"src/cpp/client/credentials.cc",
"src/cpp/client/generic_stub.cc",
"src/cpp/client/insecure_credentials.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc",
Expand Down
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ transport_security_test: $(BINDIR)/$(CONFIG)/transport_security_test
udp_server_test: $(BINDIR)/$(CONFIG)/udp_server_test
uri_parser_test: $(BINDIR)/$(CONFIG)/uri_parser_test
workqueue_test: $(BINDIR)/$(CONFIG)/workqueue_test
alarm_cpp_test: $(BINDIR)/$(CONFIG)/alarm_cpp_test
async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test
async_streaming_ping_pong_test: $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test
async_unary_ping_pong_test: $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test
Expand Down Expand Up @@ -1270,6 +1271,7 @@ buildtests_c: privatelibs_c \


buildtests_cxx: buildtests_zookeeper privatelibs_cxx \
$(BINDIR)/$(CONFIG)/alarm_cpp_test \
$(BINDIR)/$(CONFIG)/async_end2end_test \
$(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test \
$(BINDIR)/$(CONFIG)/async_unary_ping_pong_test \
Expand Down Expand Up @@ -1563,6 +1565,8 @@ flaky_test_c: buildtests_c


test_cxx: test_zookeeper buildtests_cxx
$(E) "[RUN] Testing alarm_cpp_test"
$(Q) $(BINDIR)/$(CONFIG)/alarm_cpp_test || ( echo test alarm_cpp_test failed ; exit 1 )
$(E) "[RUN] Testing async_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/async_end2end_test || ( echo test async_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing async_streaming_ping_pong_test"
Expand Down Expand Up @@ -2942,6 +2946,7 @@ LIBGRPC++_SRC = \
src/cpp/client/credentials.cc \
src/cpp/client/generic_stub.cc \
src/cpp/client/insecure_credentials.cc \
src/cpp/common/alarm.cc \
src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \
Expand Down Expand Up @@ -3220,6 +3225,7 @@ LIBGRPC++_UNSECURE_SRC = \
src/cpp/client/credentials.cc \
src/cpp/client/generic_stub.cc \
src/cpp/client/insecure_credentials.cc \
src/cpp/common/alarm.cc \
src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \
Expand Down Expand Up @@ -8745,6 +8751,49 @@ endif
endif


ALARM_CPP_TEST_SRC = \
test/cpp/common/alarm_cpp_test.cc \

ALARM_CPP_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALARM_CPP_TEST_SRC))))
ifeq ($(NO_SECURE),true)

# You can't build secure targets if you don't have OpenSSL.

$(BINDIR)/$(CONFIG)/alarm_cpp_test: openssl_dep_error

else




ifeq ($(NO_PROTOBUF),true)

# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.

$(BINDIR)/$(CONFIG)/alarm_cpp_test: protobuf_dep_error

else

$(BINDIR)/$(CONFIG)/alarm_cpp_test: $(PROTOBUF_DEP) $(ALARM_CPP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(ALARM_CPP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/alarm_cpp_test

endif

endif

$(OBJDIR)/$(CONFIG)/test/cpp/common/alarm_cpp_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a

deps_alarm_cpp_test: $(ALARM_CPP_TEST_OBJS:.o=.dep)

ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(ALARM_CPP_TEST_OBJS:.o=.dep)
endif
endif


ASYNC_END2END_TEST_SRC = \
test/cpp/end2end/async_end2end_test.cc \

Expand Down
11 changes: 11 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ filegroups:
- src/cpp/client/credentials.cc
- src/cpp/client/generic_stub.cc
- src/cpp/client/insecure_credentials.cc
- src/cpp/common/alarm.cc
- src/cpp/common/call.cc
- src/cpp/common/channel_arguments.cc
- src/cpp/common/completion_queue.cc
Expand Down Expand Up @@ -1705,6 +1706,16 @@ targets:
- mac
- linux
- posix
- name: alarm_cpp_test
build: test
language: c++
src:
- test/cpp/common/alarm_cpp_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- name: async_end2end_test
build: test
language: c++
Expand Down
2 changes: 2 additions & 0 deletions include/grpc++/alarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/time.h>

struct grpc_alarm;

namespace grpc {

class CompletionQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

#include <grpc++/alarm.h>
#include <grpc++/completion_queue.h>
#include <grpc++/impl/codegen/completion_queue_tag.h>
#include <gtest/gtest.h>

#include <grpc++/completion_queue.h>
#include "test/core/util/test_config.h"

namespace grpc {
Expand All @@ -45,7 +45,7 @@ class TestTag : public CompletionQueueTag {
public:
TestTag() : tag_(0) {}
TestTag(intptr_t tag) : tag_(tag) {}
bool FinalizeResult(void** tag, bool* status) { return true; }
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { return true; }
intptr_t tag() { return tag_; }

private:
Expand Down
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.c++.internal
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ src/cpp/client/create_channel_internal.cc \
src/cpp/client/credentials.cc \
src/cpp/client/generic_stub.cc \
src/cpp/client/insecure_credentials.cc \
src/cpp/common/alarm.cc \
src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \
Expand Down
16 changes: 16 additions & 0 deletions tools/run_tests/sources_and_headers.json
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,20 @@
"test/core/iomgr/workqueue_test.c"
]
},
{
"deps": [
"grpc",
"grpc++",
"grpc++_test_util",
"grpc_test_util"
],
"headers": [],
"language": "c++",
"name": "alarm_cpp_test",
"src": [
"test/cpp/common/alarm_cpp_test.cc"
]
},
{
"deps": [
"grpc",
Expand Down Expand Up @@ -3884,6 +3898,7 @@
"src/cpp/client/secure_credentials.cc",
"src/cpp/client/secure_credentials.h",
"src/cpp/codegen/grpc_library.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/auth_property_iterator.cc",
"src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc",
Expand Down Expand Up @@ -4133,6 +4148,7 @@
"src/cpp/client/generic_stub.cc",
"src/cpp/client/insecure_credentials.cc",
"src/cpp/codegen/grpc_library.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc",
Expand Down
20 changes: 20 additions & 0 deletions tools/run_tests/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,26 @@
"posix"
]
},
{
"args": [],
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"flaky": false,
"language": "c++",
"name": "alarm_cpp_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
]
},
{
"args": [],
"ci_platforms": [
Expand Down
2 changes: 2 additions & 0 deletions vsprojects/vcxproj/grpc++/grpc++.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\client\insecure_credentials.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\alarm.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\call.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\channel_arguments.cc">
Expand Down
3 changes: 3 additions & 0 deletions vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<ClCompile Include="$(SolutionDir)\..\src\cpp\client\insecure_credentials.cc">
<Filter>src\cpp\client</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\alarm.cc">
<Filter>src\cpp\common</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\call.cc">
<Filter>src\cpp\common</Filter>
</ClCompile>
Expand Down
2 changes: 2 additions & 0 deletions vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\client\insecure_credentials.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\alarm.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\call.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\channel_arguments.cc">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<ClCompile Include="$(SolutionDir)\..\src\cpp\client\insecure_credentials.cc">
<Filter>src\cpp\client</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\alarm.cc">
<Filter>src\cpp\common</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\common\call.cc">
<Filter>src\cpp\common</Filter>
</ClCompile>
Expand Down
Loading

0 comments on commit 04e992a

Please sign in to comment.