Skip to content

Commit

Permalink
Merge pull request grpc#4978 from nicolasnoble/alarming
Browse files Browse the repository at this point in the history
Fixing, using and testing alarm code.
  • Loading branch information
ctiller committed Feb 1, 2016
2 parents 9734b9c + 10fe786 commit cbc4629
Showing 19 changed files with 354 additions and 3 deletions.
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -387,6 +387,7 @@ cc_library(
"src/core/json/json_reader.c",
"src/core/json/json_string.c",
"src/core/json/json_writer.c",
"src/core/surface/alarm.c",
"src/core/surface/api_trace.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_reader.c",
@@ -664,6 +665,7 @@ cc_library(
"src/core/json/json_reader.c",
"src/core/json/json_string.c",
"src/core/json/json_writer.c",
"src/core/surface/alarm.c",
"src/core/surface/api_trace.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_reader.c",
@@ -1339,6 +1341,7 @@ objc_library(
"src/core/json/json_reader.c",
"src/core/json/json_string.c",
"src/core/json/json_writer.c",
"src/core/surface/alarm.c",
"src/core/surface/api_trace.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_reader.c",
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -824,6 +824,7 @@ systemtap_dep_error:
stop:
@false

alarm_test: $(BINDIR)/$(CONFIG)/alarm_test
algorithm_test: $(BINDIR)/$(CONFIG)/algorithm_test
alloc_test: $(BINDIR)/$(CONFIG)/alloc_test
alpn_test: $(BINDIR)/$(CONFIG)/alpn_test
@@ -1132,6 +1133,7 @@ endif
buildtests: buildtests_c buildtests_cxx buildtests_zookeeper

buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/alarm_test \
$(BINDIR)/$(CONFIG)/algorithm_test \
$(BINDIR)/$(CONFIG)/alloc_test \
$(BINDIR)/$(CONFIG)/alpn_test \
@@ -1359,6 +1361,8 @@ test: test_c test_cxx test_zookeeper
flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper

test_c: buildtests_c
$(E) "[RUN] Testing alarm_test"
$(Q) $(BINDIR)/$(CONFIG)/alarm_test || ( echo test alarm_test failed ; exit 1 )
$(E) "[RUN] Testing algorithm_test"
$(Q) $(BINDIR)/$(CONFIG)/algorithm_test || ( echo test algorithm_test failed ; exit 1 )
$(E) "[RUN] Testing alloc_test"
@@ -2454,6 +2458,7 @@ LIBGRPC_SRC = \
src/core/json/json_reader.c \
src/core/json/json_string.c \
src/core/json/json_writer.c \
src/core/surface/alarm.c \
src/core/surface/api_trace.c \
src/core/surface/byte_buffer.c \
src/core/surface/byte_buffer_reader.c \
@@ -2759,6 +2764,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/json/json_reader.c \
src/core/json/json_string.c \
src/core/json/json_writer.c \
src/core/surface/alarm.c \
src/core/surface/api_trace.c \
src/core/surface/byte_buffer.c \
src/core/surface/byte_buffer_reader.c \
@@ -5750,6 +5756,38 @@ endif
# All of the test targets, and protoc plugins


ALARM_TEST_SRC = \
test/core/surface/alarm_test.c \

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

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

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

else



$(BINDIR)/$(CONFIG)/alarm_test: $(ALARM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(ALARM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alarm_test

endif

$(OBJDIR)/$(CONFIG)/test/core/surface/alarm_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a

deps_alarm_test: $(ALARM_TEST_OBJS:.o=.dep)

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


ALGORITHM_TEST_SRC = \
test/core/compression/algorithm_test.c \

1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -648,6 +648,7 @@
'src/core/json/json_reader.c',
'src/core/json/json_string.c',
'src/core/json/json_writer.c',
'src/core/surface/alarm.c',
'src/core/surface/api_trace.c',
'src/core/surface/byte_buffer.c',
'src/core/surface/byte_buffer_reader.c',
11 changes: 11 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -335,6 +335,7 @@ filegroups:
- src/core/json/json_reader.c
- src/core/json/json_string.c
- src/core/json/json_writer.c
- src/core/surface/alarm.c
- src/core/surface/api_trace.c
- src/core/surface/byte_buffer.c
- src/core/surface/byte_buffer_reader.c
@@ -883,6 +884,16 @@ libs:
- winsock
- global
targets:
- name: alarm_test
build: test
language: c
src:
- test/core/surface/alarm_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: algorithm_test
build: test
language: c
1 change: 1 addition & 0 deletions gRPC.podspec
Original file line number Diff line number Diff line change
@@ -398,6 +398,7 @@ Pod::Spec.new do |s|
'src/core/json/json_reader.c',
'src/core/json/json_string.c',
'src/core/json/json_writer.c',
'src/core/surface/alarm.c',
'src/core/surface/api_trace.c',
'src/core/surface/byte_buffer.c',
'src/core/surface/byte_buffer_reader.c',
1 change: 1 addition & 0 deletions grpc.gemspec
Original file line number Diff line number Diff line change
@@ -381,6 +381,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/json/json_reader.c )
s.files += %w( src/core/json/json_string.c )
s.files += %w( src/core/json/json_writer.c )
s.files += %w( src/core/surface/alarm.c )
s.files += %w( src/core/surface/api_trace.c )
s.files += %w( src/core/surface/byte_buffer.c )
s.files += %w( src/core/surface/byte_buffer_reader.c )
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -322,6 +322,7 @@
"src/core/json/json_reader.c",
"src/core/json/json_string.c",
"src/core/json/json_writer.c",
"src/core/surface/alarm.c",
"src/core/surface/api_trace.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_reader.c",
6 changes: 3 additions & 3 deletions src/core/surface/alarm.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -48,7 +48,7 @@ struct grpc_alarm {
static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg,
grpc_cq_completion *c) {}

static void alarm_cb(grpc_exec_ctx *exec_ctx, void *arg, int success) {
static void alarm_cb(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
grpc_alarm *alarm = arg;
grpc_cq_end_op(exec_ctx, alarm->cq, alarm->tag, success,
do_nothing_end_completion, NULL, &alarm->completion);
@@ -65,7 +65,7 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline,

grpc_timer_init(&exec_ctx, &alarm->alarm, deadline, alarm_cb, alarm,
gpr_now(GPR_CLOCK_MONOTONIC));
grpc_cq_begin_op(cq);
grpc_cq_begin_op(cq, tag);
grpc_exec_ctx_finish(&exec_ctx);
return alarm;
}
1 change: 1 addition & 0 deletions src/python/grpcio/grpc_core_dependencies.py
Original file line number Diff line number Diff line change
@@ -170,6 +170,7 @@
'src/core/json/json_reader.c',
'src/core/json/json_string.c',
'src/core/json/json_writer.c',
'src/core/surface/alarm.c',
'src/core/surface/api_trace.c',
'src/core/surface/byte_buffer.c',
'src/core/surface/byte_buffer_reader.c',
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.core.internal
Original file line number Diff line number Diff line change
@@ -996,6 +996,7 @@ src/core/json/json.c \
src/core/json/json_reader.c \
src/core/json/json_string.c \
src/core/json/json_writer.c \
src/core/surface/alarm.c \
src/core/surface/api_trace.c \
src/core/surface/byte_buffer.c \
src/core/surface/byte_buffer_reader.c \
16 changes: 16 additions & 0 deletions tools/run_tests/sources_and_headers.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@


[
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
],
"headers": [],
"language": "c",
"name": "alarm_test",
"src": [
"test/core/surface/alarm_test.c"
]
},
{
"deps": [
"gpr",
@@ -3272,6 +3286,7 @@
"src/core/security/server_secure_chttp2.c",
"src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h",
"src/core/surface/alarm.c",
"src/core/surface/api_trace.c",
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer.c",
@@ -3747,6 +3762,7 @@
"src/core/json/json_writer.h",
"src/core/statistics/census_interface.h",
"src/core/statistics/census_rpc_stats.h",
"src/core/surface/alarm.c",
"src/core/surface/api_trace.c",
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer.c",
20 changes: 20 additions & 0 deletions tools/run_tests/tests.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@


[
{
"args": [],
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"flaky": false,
"language": "c",
"name": "alarm_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
]
},
{
"args": [],
"ci_platforms": [
27 changes: 27 additions & 0 deletions vsprojects/buildtests_c.sln
Original file line number Diff line number Diff line change
@@ -114,6 +114,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "end2end_certs", "vcxproj\te
lib = "True"
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "alarm_test", "vcxproj\test\alarm_test\alarm_test.vcxproj", "{AFD362D7-0E2A-E700-1F27-9D90F76166DF}"
ProjectSection(myProperties) = preProject
lib = "False"
EndProjectSection
ProjectSection(ProjectDependencies) = postProject
{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}
{29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9}
{EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037}
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "algorithm_test", "vcxproj\test\algorithm_test\algorithm_test.vcxproj", "{216FDCB2-9D93-0D86-F0F1-12E16312A191}"
ProjectSection(myProperties) = preProject
lib = "False"
@@ -1499,6 +1510,22 @@ Global
{80EA2691-C037-6DD3-D3AB-21510BF0E64B}.Release-DLL|Win32.Build.0 = Release|Win32
{80EA2691-C037-6DD3-D3AB-21510BF0E64B}.Release-DLL|x64.ActiveCfg = Release|x64
{80EA2691-C037-6DD3-D3AB-21510BF0E64B}.Release-DLL|x64.Build.0 = Release|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug|Win32.ActiveCfg = Debug|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug|x64.ActiveCfg = Debug|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release|Win32.ActiveCfg = Release|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release|x64.ActiveCfg = Release|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug|Win32.Build.0 = Debug|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug|x64.Build.0 = Debug|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release|Win32.Build.0 = Release|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release|x64.Build.0 = Release|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug-DLL|Win32.ActiveCfg = Debug|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug-DLL|Win32.Build.0 = Debug|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug-DLL|x64.ActiveCfg = Debug|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Debug-DLL|x64.Build.0 = Debug|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release-DLL|Win32.ActiveCfg = Release|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release-DLL|Win32.Build.0 = Release|Win32
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release-DLL|x64.ActiveCfg = Release|x64
{AFD362D7-0E2A-E700-1F27-9D90F76166DF}.Release-DLL|x64.Build.0 = Release|x64
{216FDCB2-9D93-0D86-F0F1-12E16312A191}.Debug|Win32.ActiveCfg = Debug|Win32
{216FDCB2-9D93-0D86-F0F1-12E16312A191}.Debug|x64.ActiveCfg = Debug|x64
{216FDCB2-9D93-0D86-F0F1-12E16312A191}.Release|Win32.ActiveCfg = Release|Win32
2 changes: 2 additions & 0 deletions vsprojects/vcxproj/grpc/grpc.vcxproj
Original file line number Diff line number Diff line change
@@ -606,6 +606,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\json\json_writer.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\alarm.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\api_trace.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\byte_buffer.c">
3 changes: 3 additions & 0 deletions vsprojects/vcxproj/grpc/grpc.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -298,6 +298,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\json\json_writer.c">
<Filter>src\core\json</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\alarm.c">
<Filter>src\core\surface</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\api_trace.c">
<Filter>src\core\surface</Filter>
</ClCompile>
2 changes: 2 additions & 0 deletions vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
Original file line number Diff line number Diff line change
@@ -542,6 +542,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\json\json_writer.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\alarm.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\api_trace.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\byte_buffer.c">
Original file line number Diff line number Diff line change
@@ -238,6 +238,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\json\json_writer.c">
<Filter>src\core\json</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\alarm.c">
<Filter>src\core\surface</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\surface\api_trace.c">
<Filter>src\core\surface</Filter>
</ClCompile>
Loading

0 comments on commit cbc4629

Please sign in to comment.