Convert tests to new error scheme

pull/6897/head
Craig Tiller 9 years ago
parent ddad978996
commit f707d62db6
  1. 130
      Makefile
  2. 23
      build.yaml
  3. 4
      src/core/ext/client_config/channel_connectivity.c
  4. 6
      src/core/ext/client_config/client_channel.c
  5. 2
      src/core/ext/client_config/subchannel.c
  6. 4
      src/core/ext/client_config/subchannel_call_holder.c
  7. 18
      src/core/ext/lb_policy/pick_first/pick_first.c
  8. 14
      src/core/ext/lb_policy/round_robin/round_robin.c
  9. 2
      src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
  10. 4
      src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
  11. 18
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  12. 4
      src/core/ext/transport/chttp2/transport/frame_data.c
  13. 4
      src/core/ext/transport/chttp2/transport/hpack_parser.c
  14. 2
      src/core/ext/transport/chttp2/transport/parsing.c
  15. 4
      src/core/lib/iomgr/closure.c
  16. 22
      src/core/lib/iomgr/error.c
  17. 8
      src/core/lib/iomgr/error.h
  18. 2
      src/core/lib/iomgr/exec_ctx.c
  19. 4
      src/core/lib/iomgr/tcp_server_posix.c
  20. 4
      src/core/lib/iomgr/timer.c
  21. 1
      src/core/lib/security/credentials/composite/composite_credentials.c
  22. 1
      src/core/lib/security/credentials/composite/composite_credentials.h
  23. 8
      src/core/lib/security/credentials/credentials.c
  24. 1
      src/core/lib/security/credentials/fake/fake_credentials.h
  25. 2
      src/core/lib/security/credentials/google_default/google_default_credentials.h
  26. 2
      src/core/lib/security/credentials/iam/iam_credentials.c
  27. 3
      src/core/lib/security/credentials/iam/iam_credentials.h
  28. 1
      src/core/lib/security/credentials/jwt/json_token.c
  29. 1
      src/core/lib/security/credentials/jwt/jwt_credentials.c
  30. 1
      src/core/lib/security/credentials/jwt/jwt_credentials.h
  31. 2
      src/core/lib/security/credentials/plugin/plugin_credentials.c
  32. 3
      src/core/lib/security/credentials/plugin/plugin_credentials.h
  33. 4
      src/core/lib/security/credentials/ssl/ssl_credentials.c
  34. 1
      src/core/lib/security/credentials/ssl/ssl_credentials.h
  35. 2
      src/core/lib/security/transport/secure_endpoint.c
  36. 2
      src/core/lib/security/transport/server_auth_filter.c
  37. 1
      src/core/lib/security/util/json_util.c
  38. 4
      src/core/lib/security/util/json_util.h
  39. 6
      src/core/lib/surface/call.c
  40. 11
      src/core/lib/transport/connectivity_state.c
  41. 6
      src/core/lib/transport/transport.c
  42. 2
      test/core/bad_client/bad_client.c
  43. 5
      test/core/channel/channel_stack_test.c
  44. 18
      test/core/client_config/resolvers/dns_resolver_connectivity_test.c
  45. 4
      test/core/client_config/set_initial_connect_string_test.c
  46. 4
      test/core/end2end/dualstack_socket_test.c
  47. 6
      test/core/end2end/fuzzers/api_fuzzer.c
  48. 27
      test/core/end2end/goaway_server_test.c
  49. 5
      test/core/end2end/tests/filter_causes_close.c
  50. 17
      test/core/http/httpcli_test.c
  51. 17
      test/core/http/httpscli_test.c
  52. 146
      test/core/http/parser_test.c
  53. 0
      test/core/http/request_corpus/0299ca2580e4398d170c4a336e0c33eb2cd9d427
  54. 0
      test/core/http/request_corpus/05e613853d64a9669ea3cf41b0de777dc24931ba
  55. 0
      test/core/http/request_corpus/069352518a1d1baa05f317c677d275cefda2ac97
  56. 0
      test/core/http/request_corpus/0925527c9358b1e10ec0f0387cd99f35204d9a34
  57. 0
      test/core/http/request_corpus/0c5b7c2569410b526605e308309a7f36574e530d
  58. 0
      test/core/http/request_corpus/0ef3d0a84360bb5ad66274f1226f5cb273ecdbcf
  59. 0
      test/core/http/request_corpus/1e1273f90187fdf5df3625764245610f86af6aa4
  60. 0
      test/core/http/request_corpus/1fbc57d118f3733287e9a9d808bb8947b3260e55
  61. 0
      test/core/http/request_corpus/24756c396bc72894fd720092bb6f9c03e66b469f
  62. 0
      test/core/http/request_corpus/276def41311933421ae7a9ee42e906c85b6a4d3f
  63. 0
      test/core/http/request_corpus/29daa75432381937fd005cb25e314e328de6e9f9
  64. 0
      test/core/http/request_corpus/2a75204bc492084ad853682f8de3fb137d5907bc
  65. 0
      test/core/http/request_corpus/2d34ba249b755a880525cf53c665633a5e359305
  66. 0
      test/core/http/request_corpus/33f4ea0c7ea27c37d8f95cfa64d282370efdafd2
  67. 0
      test/core/http/request_corpus/35554617ea6418bd43161fe9a2c337ed82d7ec5b
  68. 0
      test/core/http/request_corpus/35f0c561297cfc840ddaeebb9fc61091f4eadece
  69. 0
      test/core/http/request_corpus/3787bcc22ef645e665cc5f722b8a633af86de9cf
  70. 0
      test/core/http/request_corpus/3953688866ccb3b4f371f1a858570d6afdb6452d
  71. 0
      test/core/http/request_corpus/39b19c41ba537f37511eff7727733715db432e76
  72. 0
      test/core/http/request_corpus/3e3c4756d5e40b5aa250954cbac86b826e70a7ac
  73. 0
      test/core/http/request_corpus/3f03265921120c6ffa61b944e213e062a5538d4b
  74. 0
      test/core/http/request_corpus/3fb034e66ee5494a67acae1b4e6ff64ba92a2046
  75. 0
      test/core/http/request_corpus/466059ed07a0d55d6ad5e522c7d367cbf278eaf9
  76. 0
      test/core/http/request_corpus/487725eb38511c79a9340bf4560a1411061fa6fa
  77. 0
      test/core/http/request_corpus/48b9b205cae8ac21512a3f26f49fd53e21ee13c5
  78. 0
      test/core/http/request_corpus/4b1f1f79a0bfa3f942479dd5f8edb59a7c257c55
  79. 0
      test/core/http/request_corpus/5028c56a5116a186b7343ff59567b47347a0796d
  80. 0
      test/core/http/request_corpus/533f62b3f495ce704babf3ee8d840f196a714dff
  81. 0
      test/core/http/request_corpus/5892cbb284771fc9761caae37b19cd6e27dbc104
  82. 0
      test/core/http/request_corpus/5aeab6e4f7c2a1c09d4ac0dbdb3beac4893607ee
  83. 0
      test/core/http/request_corpus/5b6292bdf009b0daecbc90b85cca30a88c36eec5
  84. 0
      test/core/http/request_corpus/5c1659b77678b41faa4fa13df7772dae3238d1c0
  85. 0
      test/core/http/request_corpus/5c81f61621e29ec9c6a64ac3af9b3b216141618e
  86. 0
      test/core/http/request_corpus/657368df512ca6294b9df16adf935a3f374a8be2
  87. 0
      test/core/http/request_corpus/7fc4520094902ce2c760d70eaad5b674d2817337
  88. 0
      test/core/http/request_corpus/81f59a12b458ec3604035cb962165c604d1355e6
  89. 0
      test/core/http/request_corpus/8f41c50e88ee8c17ecad3d41d63d38fb12aca0b9
  90. 0
      test/core/http/request_corpus/97c16de7fe3c390a2e6c09ff5c28f17d5c67542c
  91. 0
      test/core/http/request_corpus/97e4499d450c95660de86747f527e670f2012548
  92. 0
      test/core/http/request_corpus/9a996857196e0998a1278994a9bab3d35526e7f1
  93. 0
      test/core/http/request_corpus/9b7e00049ec356ecd84b1747e4e1941140139ae8
  94. 0
      test/core/http/request_corpus/9f0c38ec455cc363369b3674a2d32bc21c206de1
  95. 0
      test/core/http/request_corpus/a1dc7bc235e46eb21d91084d7b52d5ff9f45df85
  96. 0
      test/core/http/request_corpus/aa3bbb876eafa8ad8ca4ff2eabc6dd94341d2441
  97. 0
      test/core/http/request_corpus/ae8ba95d7dbe99926a8f5bfd80347fd6a4b616a0
  98. 0
      test/core/http/request_corpus/b04fea5c041c707db0ad9c09a81672557b52cc47
  99. 0
      test/core/http/request_corpus/c4acff8aa2ff886f35439f72625d05002990c940
  100. 0
      test/core/http/request_corpus/c55ce9995b002e88a102ae2891a71e8bacb346c8
  101. Some files were not shown because too many files have changed in this diff Show More

@ -941,8 +941,9 @@ grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
hpack_parser_fuzzer_test: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
http_fuzzer_test: $(BINDIR)/$(CONFIG)/http_fuzzer_test
http_parser_test: $(BINDIR)/$(CONFIG)/http_parser_test
http_request_fuzzer_test: $(BINDIR)/$(CONFIG)/http_request_fuzzer_test
http_response_fuzzer_test: $(BINDIR)/$(CONFIG)/http_response_fuzzer_test
httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test
httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test
httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test
@ -1125,7 +1126,8 @@ h2_uds_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds_nosec_test
api_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry
client_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry
hpack_parser_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry
http_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/http_fuzzer_test_one_entry
http_request_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry
http_response_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry
json_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry
nanopb_fuzzer_response_test_one_entry: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry
nanopb_fuzzer_serverlist_test_one_entry: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry
@ -1354,7 +1356,8 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/api_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/client_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry \
$(BINDIR)/$(CONFIG)/http_fuzzer_test_one_entry \
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry \
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry \
$(BINDIR)/$(CONFIG)/json_fuzzer_test_one_entry \
$(BINDIR)/$(CONFIG)/nanopb_fuzzer_response_test_one_entry \
$(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test_one_entry \
@ -8017,66 +8020,98 @@ endif
endif
HTTP_FUZZER_TEST_SRC = \
test/core/http/fuzzer.c \
HTTP_PARSER_TEST_SRC = \
test/core/http/parser_test.c \
HTTP_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_FUZZER_TEST_SRC))))
HTTP_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_fuzzer_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/http_parser_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_fuzzer_test: $(HTTP_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_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) $(LDXX) $(LDFLAGS) $(HTTP_FUZZER_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) -lFuzzer -o $(BINDIR)/$(CONFIG)/http_fuzzer_test
$(Q) $(LD) $(LDFLAGS) $(HTTP_PARSER_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)/http_parser_test
endif
$(OBJDIR)/$(CONFIG)/test/core/http/fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_fuzzer_test: $(HTTP_FUZZER_TEST_OBJS:.o=.dep)
deps_http_parser_test: $(HTTP_PARSER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_FUZZER_TEST_OBJS:.o=.dep)
-include $(HTTP_PARSER_TEST_OBJS:.o=.dep)
endif
endif
HTTP_PARSER_TEST_SRC = \
test/core/http/parser_test.c \
HTTP_REQUEST_FUZZER_TEST_SRC = \
test/core/http/request_fuzzer.c \
HTTP_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_PARSER_TEST_SRC))))
HTTP_REQUEST_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_REQUEST_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_parser_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test: $(HTTP_REQUEST_FUZZER_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) $(HTTP_PARSER_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)/http_parser_test
$(Q) $(LDXX) $(LDFLAGS) $(HTTP_REQUEST_FUZZER_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) -lFuzzer -o $(BINDIR)/$(CONFIG)/http_request_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/http/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/request_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_parser_test: $(HTTP_PARSER_TEST_OBJS:.o=.dep)
deps_http_request_fuzzer_test: $(HTTP_REQUEST_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_PARSER_TEST_OBJS:.o=.dep)
-include $(HTTP_REQUEST_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
HTTP_RESPONSE_FUZZER_TEST_SRC = \
test/core/http/response_fuzzer.c \
HTTP_RESPONSE_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_RESPONSE_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test: $(HTTP_RESPONSE_FUZZER_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) $(LDXX) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_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) -lFuzzer -o $(BINDIR)/$(CONFIG)/http_response_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/http/response_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_response_fuzzer_test: $(HTTP_RESPONSE_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_RESPONSE_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
@ -14108,37 +14143,72 @@ endif
endif
HTTP_FUZZER_TEST_ONE_ENTRY_SRC = \
test/core/http/fuzzer.c \
HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_SRC = \
test/core/http/request_fuzzer.c \
test/core/util/one_corpus_entry_fuzzer.c \
HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test_one_entry: $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_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) $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_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)/http_request_fuzzer_test_one_entry
endif
$(OBJDIR)/$(CONFIG)/test/core/http/request_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/util/one_corpus_entry_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_request_fuzzer_test_one_entry: $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_REQUEST_FUZZER_TEST_ONE_ENTRY_OBJS:.o=.dep)
endif
endif
HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_SRC = \
test/core/http/response_fuzzer.c \
test/core/util/one_corpus_entry_fuzzer.c \
HTTP_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_FUZZER_TEST_ONE_ENTRY_SRC))))
HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_fuzzer_test_one_entry: openssl_dep_error
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_fuzzer_test_one_entry: $(HTTP_FUZZER_TEST_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test_one_entry: $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_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) $(HTTP_FUZZER_TEST_ONE_ENTRY_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)/http_fuzzer_test_one_entry
$(Q) $(LD) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_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)/http_response_fuzzer_test_one_entry
endif
$(OBJDIR)/$(CONFIG)/test/core/http/fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/response_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/util/one_corpus_entry_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_fuzzer_test_one_entry: $(HTTP_FUZZER_TEST_ONE_ENTRY_OBJS:.o=.dep)
deps_http_response_fuzzer_test_one_entry: $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_FUZZER_TEST_ONE_ENTRY_OBJS:.o=.dep)
-include $(HTTP_RESPONSE_FUZZER_TEST_ONE_ENTRY_OBJS:.o=.dep)
endif
endif

@ -1751,11 +1751,21 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: http_fuzzer_test
- name: http_parser_test
build: test
language: c
src:
- test/core/http/parser_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: http_request_fuzzer_test
build: fuzzer
language: c
src:
- test/core/http/fuzzer.c
- test/core/http/request_fuzzer.c
deps:
- grpc_test_util
- grpc
@ -1764,16 +1774,19 @@ targets:
corpus_dirs:
- test/core/http/corpus
maxlen: 2048
- name: http_parser_test
build: test
- name: http_response_fuzzer_test
build: fuzzer
language: c
src:
- test/core/http/parser_test.c
- test/core/http/response_fuzzer.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/http/corpus
maxlen: 2048
- name: httpcli_format_request_test
build: test
language: c

@ -131,13 +131,13 @@ static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w,
gpr_mu_lock(&w->mu);
if (due_to_completion) {
grpc_error_unref(w->error);
GRPC_ERROR_UNREF(w->error);
w->error = GRPC_ERROR_NONE;
}
switch (w->phase) {
case WAITING:
w->phase = CALLING_BACK;
grpc_cq_end_op(exec_ctx, w->cq, w->tag, grpc_error_ref(w->error),
grpc_cq_end_op(exec_ctx, w->cq, w->tag, GRPC_ERROR_REF(w->error),
finished_completion, w, &w->completion_storage);
break;
case CALLING_BACK:

@ -193,7 +193,7 @@ static void cc_on_config_changed(grpc_exec_ctx *exec_ctx, void *arg,
if (lb_policy != NULL) {
GRPC_LB_POLICY_REF(lb_policy, "channel");
GRPC_LB_POLICY_REF(lb_policy, "config_change");
grpc_error_unref(state_error);
GRPC_ERROR_UNREF(state_error);
state =
grpc_lb_policy_check_connectivity(exec_ctx, lb_policy, &state_error);
}
@ -308,7 +308,7 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx,
if (op->disconnect_with_error != GRPC_ERROR_NONE && chand->resolver != NULL) {
set_channel_connectivity_state_locked(
exec_ctx, chand, GRPC_CHANNEL_FATAL_FAILURE,
grpc_error_ref(op->disconnect_with_error), "disconnect");
GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
grpc_resolver_shutdown(exec_ctx, chand->resolver);
GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
chand->resolver = NULL;
@ -350,7 +350,7 @@ static void continue_picking(grpc_exec_ctx *exec_ctx, void *arg,
if (cpa->connected_subchannel == NULL) {
/* cancelled, do nothing */
} else if (error != GRPC_ERROR_NONE) {
grpc_exec_ctx_push(exec_ctx, cpa->on_ready, grpc_error_ref(error), NULL);
grpc_exec_ctx_push(exec_ctx, cpa->on_ready, GRPC_ERROR_REF(error), NULL);
} else if (cc_pick_subchannel(exec_ctx, cpa->elem, cpa->initial_metadata,
cpa->initial_metadata_flags,
cpa->connected_subchannel, cpa->on_ready)) {

@ -602,7 +602,7 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
if (c->disconnected) {
error = GRPC_ERROR_CREATE_REFERENCING("Disconnected", &error, 1);
} else {
grpc_error_ref(error);
GRPC_ERROR_REF(error);
}
if (error != GRPC_ERROR_NONE) {
c->next_attempt =

@ -255,10 +255,10 @@ static void fail_locked(grpc_exec_ctx *exec_ctx,
size_t i;
for (i = 0; i < holder->waiting_ops_count; i++) {
grpc_transport_stream_op_finish_with_failure(
exec_ctx, &holder->waiting_ops[i], grpc_error_ref(error));
exec_ctx, &holder->waiting_ops[i], GRPC_ERROR_REF(error));
}
holder->waiting_ops_count = 0;
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
}
char *grpc_subchannel_call_holder_get_peer(

@ -265,7 +265,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
pending_pick *pp;
grpc_connected_subchannel *selected;
grpc_error_ref(error);
GRPC_ERROR_REF(error);
gpr_mu_lock(&p->mu);
@ -281,7 +281,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
p->checking_connectivity = GRPC_CHANNEL_FATAL_FAILURE;
}
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
p->checking_connectivity, grpc_error_ref(error),
p->checking_connectivity, GRPC_ERROR_REF(error),
"selected_changed");
if (p->checking_connectivity != GRPC_CHANNEL_FATAL_FAILURE) {
grpc_connected_subchannel_notify_on_state_change(
@ -328,9 +328,9 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
/* only trigger transient failure when we've tried all alternatives */
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_error_ref(error), "connecting_transient_failure");
GRPC_ERROR_REF(error), "connecting_transient_failure");
}
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
p->checking_connectivity = grpc_subchannel_check_connectivity(
p->subchannels[p->checking_subchannel], &error);
if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
@ -346,7 +346,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
case GRPC_CHANNEL_IDLE:
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_CONNECTING,
grpc_error_ref(error), "connecting_changed");
GRPC_ERROR_REF(error), "connecting_changed");
grpc_subchannel_notify_on_state_change(
exec_ctx, p->subchannels[p->checking_subchannel],
p->base.interested_parties, &p->checking_connectivity,
@ -359,7 +359,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[p->num_subchannels],
"pick_first");
if (p->num_subchannels == 0) {
grpc_error_ref(error);
GRPC_ERROR_REF(error);
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_FATAL_FAILURE,
GRPC_ERROR_CREATE_REFERENCING("Pick first exhausted channels",
@ -377,9 +377,9 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
} else {
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_error_ref(error), "subchannel_failed");
GRPC_ERROR_REF(error), "subchannel_failed");
p->checking_subchannel %= p->num_subchannels;
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
p->checking_connectivity = grpc_subchannel_check_connectivity(
p->subchannels[p->checking_subchannel], &error);
goto loop;
@ -389,7 +389,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_unlock(&p->mu);
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
}
static grpc_connectivity_state pf_check_connectivity(grpc_exec_ctx *exec_ctx,

@ -376,7 +376,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
int unref = 0;
grpc_error_ref(error);
GRPC_ERROR_REF(error);
gpr_mu_lock(&p->mu);
if (p->shutdown) {
@ -385,7 +385,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
switch (sd->connectivity_state) {
case GRPC_CHANNEL_READY:
grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
GRPC_CHANNEL_READY, grpc_error_ref(error),
GRPC_CHANNEL_READY, GRPC_ERROR_REF(error),
"connecting_ready");
/* add the newly connected subchannel to the list of connected ones.
* Note that it goes to the "end of the line". */
@ -421,7 +421,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
case GRPC_CHANNEL_IDLE:
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, sd->connectivity_state,
grpc_error_ref(error), "connecting_changed");
GRPC_ERROR_REF(error), "connecting_changed");
grpc_subchannel_notify_on_state_change(
exec_ctx, sd->subchannel, p->base.interested_parties,
&sd->connectivity_state, &sd->connectivity_changed_closure);
@ -439,7 +439,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
}
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_error_ref(error), "connecting_transient_failure");
GRPC_ERROR_REF(error), "connecting_transient_failure");
break;
case GRPC_CHANNEL_FATAL_FAILURE:
if (sd->ready_list_node != NULL) {
@ -456,7 +456,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
unref = 1;
if (p->num_subchannels == 0) {
grpc_error_ref(error);
GRPC_ERROR_REF(error);
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_FATAL_FAILURE,
GRPC_ERROR_CREATE_REFERENCING("Round Robin Channels Exhausted",
@ -472,7 +472,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
} else {
grpc_connectivity_state_set(
exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
grpc_error_ref(error), "subchannel_failed");
GRPC_ERROR_REF(error), "subchannel_failed");
}
} /* switch */
} /* !unref */
@ -483,7 +483,7 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "round_robin_connectivity");
}
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
}
static grpc_connectivity_state rr_check_connectivity(grpc_exec_ctx *exec_ctx,

@ -139,7 +139,7 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
/* we managed to bind some addresses: continue */
} else {
for (i = 0; i < resolved->naddrs; i++) {
grpc_error_unref(errors[i]);
GRPC_ERROR_UNREF(errors[i]);
}
}
gpr_free(errors);

@ -145,7 +145,7 @@ static void destroy_done(grpc_exec_ctx *exec_ctx, void *statep,
grpc_server_secure_state *state = statep;
if (state->destroy_callback != NULL) {
state->destroy_callback->cb(exec_ctx, state->destroy_callback->cb_arg,
grpc_error_ref(error));
GRPC_ERROR_REF(error));
}
grpc_server_security_connector_shutdown(exec_ctx, state->sc);
state_unref(state);
@ -249,7 +249,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
/* we managed to bind some addresses: continue */
} else {
for (i = 0; i < resolved->naddrs; i++) {
grpc_error_unref(errors[i]);
GRPC_ERROR_UNREF(errors[i]);
}
}
gpr_free(errors);

@ -741,7 +741,7 @@ static void terminate_writing_with_lock(grpc_exec_ctx *exec_ctx,
allow_endpoint_shutdown_locked(exec_ctx, t);
if (error != GRPC_ERROR_NONE) {
drop_connection(exec_ctx, t, grpc_error_ref(error));
drop_connection(exec_ctx, t, GRPC_ERROR_REF(error));
}
grpc_chttp2_cleanup_writing(exec_ctx, &t->global, &t->writing);
@ -749,7 +749,7 @@ static void terminate_writing_with_lock(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_global *stream_global;
while (grpc_chttp2_list_pop_closed_waiting_for_writing(&t->global,
&stream_global)) {
fail_pending_writes(exec_ctx, stream_global, grpc_error_ref(error));
fail_pending_writes(exec_ctx, stream_global, GRPC_ERROR_REF(error));
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "finish_writes");
}
@ -1325,10 +1325,10 @@ static void fail_pending_writes(grpc_exec_ctx *exec_ctx,
grpc_error *error) {
grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_initial_metadata_finished,
grpc_error_ref(error));
GRPC_ERROR_REF(error));
grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_trailing_metadata_finished,
grpc_error_ref(error));
GRPC_ERROR_REF(error));
grpc_chttp2_complete_closure_step(
exec_ctx, stream_global, &stream_global->send_message_finished, error);
}
@ -1339,7 +1339,7 @@ void grpc_chttp2_mark_stream_closed(
grpc_error *error) {
if (stream_global->read_closed && stream_global->write_closed) {
/* already closed */
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
return;
}
grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
@ -1356,7 +1356,7 @@ void grpc_chttp2_mark_stream_closed(
grpc_chttp2_list_add_closed_waiting_for_writing(transport_global,
stream_global);
} else {
fail_pending_writes(exec_ctx, stream_global, grpc_error_ref(error));
fail_pending_writes(exec_ctx, stream_global, GRPC_ERROR_REF(error));
}
}
if (stream_global->read_closed && stream_global->write_closed) {
@ -1372,7 +1372,7 @@ void grpc_chttp2_mark_stream_closed(
GRPC_CHTTP2_STREAM_UNREF(exec_ctx, stream_global, "chttp2");
}
}
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
}
static void close_from_api(grpc_exec_ctx *exec_ctx,
@ -1788,7 +1788,7 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
*arg->slice = gpr_slice_buffer_take_first(&bs->slices);
grpc_exec_ctx_push(exec_ctx, arg->on_complete, GRPC_ERROR_NONE, NULL);
} else if (bs->error != GRPC_ERROR_NONE) {
grpc_exec_ctx_push(exec_ctx, arg->on_complete, grpc_error_ref(bs->error),
grpc_exec_ctx_push(exec_ctx, arg->on_complete, GRPC_ERROR_REF(bs->error),
NULL);
} else {
bs->on_next = arg->on_complete;
@ -1869,7 +1869,7 @@ static void incoming_byte_stream_finished_failed_locked(
void *argp) {
grpc_chttp2_incoming_byte_stream *bs = argp;
grpc_error *error = argp;
grpc_exec_ctx_push(exec_ctx, bs->on_next, grpc_error_ref(error), NULL);
grpc_exec_ctx_push(exec_ctx, bs->on_next, GRPC_ERROR_REF(error), NULL);
bs->on_next = NULL;
bs->error = error;
incoming_byte_stream_unref(exec_ctx, bs);

@ -167,7 +167,7 @@ grpc_error *grpc_chttp2_data_parser_parse(
switch (p->state) {
case GRPC_CHTTP2_DATA_ERROR:
p->state = GRPC_CHTTP2_DATA_ERROR;
return grpc_error_ref(p->error);
return GRPC_ERROR_REF(p->error);
fh_0:
case GRPC_CHTTP2_DATA_FH_0:
stream_parsing->stats.incoming.framing_bytes++;
@ -192,7 +192,7 @@ grpc_error *grpc_chttp2_data_parser_parse(
p->error =
grpc_error_set_int(p->error, GRPC_ERROR_INT_OFFSET, cur - beg);
p->state = GRPC_CHTTP2_DATA_ERROR;
return grpc_error_ref(p->error);
return GRPC_ERROR_REF(p->error);
}
if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_1;

@ -1004,14 +1004,14 @@ static grpc_error *parse_max_tbl_size_x(grpc_chttp2_hpack_parser *p,
static grpc_error *parse_error(grpc_chttp2_hpack_parser *p, const uint8_t *cur,
const uint8_t *end, grpc_error *err) {
GPR_ASSERT(err != GRPC_ERROR_NONE);
p->last_error = grpc_error_ref(err);
p->last_error = GRPC_ERROR_REF(err);
p->state = still_parse_error;
return err;
}
static grpc_error *still_parse_error(grpc_chttp2_hpack_parser *p,
const uint8_t *cur, const uint8_t *end) {
return grpc_error_ref(p->last_error);
return GRPC_ERROR_REF(p->last_error);
}
static grpc_error *parse_illegal_op(grpc_chttp2_hpack_parser *p,

@ -922,7 +922,7 @@ static grpc_error *parse_frame_slice(
GRPC_CHTTP2_PROTOCOL_ERROR,
&stream_parsing->stats.outgoing));
} else {
grpc_error_unref(err);
GRPC_ERROR_UNREF(err);
}
}
return err;

@ -58,10 +58,10 @@ void grpc_closure_list_fail_all(grpc_closure_list *list,
grpc_error *forced_failure) {
for (grpc_closure *c = list->head; c != NULL; c = c->next_data.next) {
if (c->error == GRPC_ERROR_NONE) {
c->error = grpc_error_ref(forced_failure);
c->error = GRPC_ERROR_REF(forced_failure);
}
}
grpc_error_unref(forced_failure);
GRPC_ERROR_UNREF(forced_failure);
}
bool grpc_closure_list_empty(grpc_closure_list closure_list) {

@ -54,9 +54,9 @@ static void destroy_string(void *str) { gpr_free(str); }
static void *copy_string(void *str) { return gpr_strdup(str); }
static void destroy_err(void *err) { grpc_error_unref(err); }
static void destroy_err(void *err) { GRPC_ERROR_UNREF(err); }
static void *copy_err(void *err) { return grpc_error_ref(err); }
static void *copy_err(void *err) { return GRPC_ERROR_REF(err); }
static void destroy_time(void *tm) { gpr_free(tm); }
@ -156,8 +156,9 @@ static bool is_special(grpc_error *err) {
err == GRPC_ERROR_CANCELLED;
}
grpc_error *grpc_error_ref(grpc_error *err) {
grpc_error *grpc_error_ref(grpc_error *err, const char *file, int line) {
if (is_special(err)) return err;
gpr_log(GPR_DEBUG, "%p: %d -> %d [%s:%d]", err, err->refs.count, err->refs.count + 1, file, line);
gpr_ref(&err->refs);
return err;
}
@ -168,10 +169,13 @@ static void error_destroy(grpc_error *err) {
gpr_avl_unref(err->strs);
gpr_avl_unref(err->errs);
gpr_avl_unref(err->times);
gpr_free(err);
}
void grpc_error_unref(grpc_error *err) {
if (!is_special(err) && gpr_unref(&err->refs)) {
void grpc_error_unref(grpc_error *err, const char *file, int line) {
if (is_special(err)) return;
gpr_log(GPR_DEBUG, "%p: %d -> %d [%s:%d]", err, err->refs.count, err->refs.count - 1, file, line);
if (gpr_unref(&err->refs)) {
error_destroy(err);
}
}
@ -188,13 +192,13 @@ grpc_error *grpc_error_create(const char *file, int line, const char *desc,
(void *)(uintptr_t)line);
err->strs = gpr_avl_add(
gpr_avl_add(gpr_avl_create(&avl_vtable_strs),
(void *)(uintptr_t)GRPC_ERROR_STR_FILE, (void *)file),
(void *)(uintptr_t)GRPC_ERROR_STR_DESCRIPTION, (void *)desc);
(void *)(uintptr_t)GRPC_ERROR_STR_FILE, gpr_strdup(file)),
(void *)(uintptr_t)GRPC_ERROR_STR_DESCRIPTION, gpr_strdup(desc));
err->errs = gpr_avl_create(&avl_vtable_errs);
for (size_t i = 0; i < num_referencing; i++) {
if (referencing[i] == GRPC_ERROR_NONE) continue;
err->errs =
gpr_avl_add(err->errs, (void *)(err->next_err++), referencing[i]);
gpr_avl_add(err->errs, (void *)(err->next_err++), GRPC_ERROR_REF(referencing[i]));
}
err->times = gpr_avl_add(gpr_avl_create(&avl_vtable_times),
(void *)(uintptr_t)GRPC_ERROR_TIME_CREATED,
@ -218,7 +222,7 @@ static grpc_error *copy_error_and_unref(grpc_error *in) {
out->times = gpr_avl_ref(in->times);
out->next_err = in->next_err;
gpr_ref_init(&out->refs, 1);
grpc_error_unref(in);
GRPC_ERROR_UNREF(in);
return out;
}

@ -83,8 +83,12 @@ grpc_error *grpc_error_create(const char *file, int line, const char *desc,
grpc_error_create(__FILE__, __LINE__, desc, NULL, 0)
#define GRPC_ERROR_CREATE_REFERENCING(desc, errs, count) \
grpc_error_create(__FILE__, __LINE__, desc, errs, count)
grpc_error *grpc_error_ref(grpc_error *err);
void grpc_error_unref(grpc_error *err);
grpc_error *grpc_error_ref(grpc_error *err, const char *file, int line);
void grpc_error_unref(grpc_error *err, const char *file, int line);
#define GRPC_ERROR_REF(err) grpc_error_ref(err, __FILE__, __LINE__)
#define GRPC_ERROR_UNREF(err) grpc_error_unref(err, __FILE__, __LINE__)
grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which,
intptr_t value);
const intptr_t *grpc_error_get_int(grpc_error *error, grpc_error_ints which);

@ -52,7 +52,7 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
did_something = true;
GPR_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0);
c->cb(exec_ctx, c->cb_arg, error);
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
GPR_TIMER_END("grpc_exec_ctx_flush.cb", 0);
c = next;
}

@ -516,8 +516,8 @@ done:
gpr_free(allocated_addr);
if (sp != NULL) {
*out_port = sp->port;
grpc_error_unref(errs[0]);
grpc_error_unref(errs[1]);
GRPC_ERROR_UNREF(errs[0]);
GRPC_ERROR_UNREF(errs[1]);
return GRPC_ERROR_NONE;
} else {
*out_port = -1;

@ -307,7 +307,7 @@ static size_t pop_timers(grpc_exec_ctx *exec_ctx, shard_type *shard,
grpc_timer *timer;
gpr_mu_lock(&shard->mu);
while ((timer = pop_one(shard, now))) {
grpc_exec_ctx_push(exec_ctx, &timer->closure, grpc_error_ref(error), NULL);
grpc_exec_ctx_push(exec_ctx, &timer->closure, GRPC_ERROR_REF(error), NULL);
n++;
}
*new_min_deadline = compute_min_deadline(shard);
@ -362,7 +362,7 @@ static int run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_timespec now,
*next, gpr_time_add(now, gpr_time_from_millis(1, GPR_TIMESPAN)));
}
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
return (int)n;
}

@ -260,4 +260,3 @@ grpc_channel_credentials *grpc_composite_channel_credentials_create(
c->call_creds = grpc_call_credentials_ref(call_creds);
return &c->base;
}

@ -69,4 +69,3 @@ typedef struct {
} grpc_composite_call_credentials;
#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_CREDENTIALS_H

@ -53,10 +53,9 @@
/* -- Common. -- */
grpc_credentials_metadata_request *
grpc_credentials_metadata_request_create(grpc_call_credentials *creds,
grpc_credentials_metadata_cb cb,
void *user_data) {
grpc_credentials_metadata_request *grpc_credentials_metadata_request_create(
grpc_call_credentials *creds, grpc_credentials_metadata_cb cb,
void *user_data) {
grpc_credentials_metadata_request *r =
gpr_malloc(sizeof(grpc_credentials_metadata_request));
r->creds = grpc_call_credentials_ref(creds);
@ -230,4 +229,3 @@ grpc_server_credentials *grpc_find_server_credentials_in_args(
}
return NULL;
}

@ -53,4 +53,3 @@ typedef struct {
} grpc_md_only_test_credentials;
#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_CREDENTIALS_H

@ -43,5 +43,3 @@
void grpc_flush_cached_google_default_credentials(void);
#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_CREDENTIALS_H

@ -83,5 +83,3 @@ grpc_call_credentials *grpc_google_iam_credentials_create(
c->iam_md, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, authority_selector);
return &c->base;
}

@ -42,6 +42,3 @@ typedef struct {
} grpc_google_iam_credentials;
#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_CREDENTIALS_H

@ -318,4 +318,3 @@ void grpc_jwt_encode_and_sign_set_override(
grpc_jwt_encode_and_sign_override func) {
g_jwt_encode_and_sign_override = func;
}

@ -158,4 +158,3 @@ grpc_call_credentials *grpc_service_account_jwt_access_credentials_create(
return grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
grpc_auth_json_key_create_from_string(json_key), token_lifetime);
}

@ -60,4 +60,3 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
grpc_auth_json_key key, gpr_timespec token_lifetime);
#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_CREDENTIALS_H

@ -127,5 +127,3 @@ grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
c->plugin = plugin;
return &c->base;
}

@ -43,6 +43,3 @@ typedef struct {
} grpc_plugin_credentials;
#endif // GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_CREDENTIALS_H

@ -160,7 +160,6 @@ static void ssl_server_destruct(grpc_server_credentials *creds) {
if (c->config.pem_root_certs != NULL) gpr_free(c->config.pem_root_certs);
}
static grpc_security_status ssl_server_create_security_connector(
grpc_server_credentials *creds, grpc_server_security_connector **sc) {
grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds;
@ -170,7 +169,6 @@ static grpc_security_status ssl_server_create_security_connector(
static grpc_server_credentials_vtable ssl_server_vtable = {
ssl_server_destruct, ssl_server_create_security_connector};
static void ssl_build_server_config(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
size_t num_key_cert_pairs,
@ -206,7 +204,6 @@ static void ssl_build_server_config(
}
}
grpc_server_credentials *grpc_ssl_server_credentials_create(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
size_t num_key_cert_pairs, int force_client_auth, void *reserved) {
@ -241,4 +238,3 @@ grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
&c->config);
return &c->base;
}

@ -46,4 +46,3 @@ typedef struct {
} grpc_ssl_server_credentials;
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H */

@ -138,7 +138,7 @@ static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
}
}
ep->read_buffer = NULL;
grpc_exec_ctx_push(exec_ctx, ep->read_cb, grpc_error_ref(error), NULL);
grpc_exec_ctx_push(exec_ctx, ep->read_cb, GRPC_ERROR_REF(error), NULL);
SECURE_ENDPOINT_UNREF(exec_ctx, ep, "read");
}

@ -169,7 +169,7 @@ static void auth_on_recv(grpc_exec_ctx *exec_ctx, void *user_data,
return;
}
}
grpc_exec_ctx_push(exec_ctx, calld->on_done_recv, grpc_error_ref(error),
grpc_exec_ctx_push(exec_ctx, calld->on_done_recv, GRPC_ERROR_REF(error),
NULL);
}

@ -59,4 +59,3 @@ bool grpc_copy_json_string_property(const grpc_json *json,
*copied_value = gpr_strdup(prop_value);
return true;
}

@ -50,8 +50,6 @@ const char *grpc_json_get_string_property(const grpc_json *json,
// Copies the value of the json child property specified by prop_name.
// Returns false if the property was not found.
bool grpc_copy_json_string_property(const grpc_json *json,
const char *prop_name,
char **copied_value);
const char *prop_name, char **copied_value);
#endif // GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H

@ -1082,7 +1082,7 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
gpr_mu_lock(&call->mu);
if (error != GRPC_ERROR_NONE) {
bctl->error = grpc_error_ref(error);
bctl->error = GRPC_ERROR_REF(error);
} else {
grpc_metadata_batch *md =
&call->metadata_batch[1 /* is_receiving */][0 /* is_trailing */];
@ -1167,10 +1167,10 @@ static void finish_batch(grpc_exec_ctx *exec_ctx, void *bctlp,
call->final_op.server.cancelled);
}
grpc_error_unref(error);
GRPC_ERROR_UNREF(error);
error = GRPC_ERROR_NONE;
}
bctl->error = grpc_error_ref(error);
bctl->error = GRPC_ERROR_REF(error);
gpr_mu_unlock(&call->mu);
if (gpr_unref(&bctl->steps_to_complete)) {
post_batch_completion(exec_ctx, bctl);

@ -61,6 +61,7 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker *tracker,
grpc_connectivity_state init_state,
const char *name) {
tracker->current_state = init_state;
tracker->current_error = GRPC_ERROR_NONE;
tracker->watchers = NULL;
tracker->name = gpr_strdup(name);
}
@ -69,7 +70,6 @@ void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
grpc_connectivity_state_tracker *tracker) {
grpc_error *error;
grpc_connectivity_state_watcher *w;
grpc_error_unref(tracker->current_error);
while ((w = tracker->watchers)) {
tracker->watchers = w->next;
@ -82,6 +82,7 @@ void grpc_connectivity_state_destroy(grpc_exec_ctx *exec_ctx,
grpc_exec_ctx_push(exec_ctx, w->notify, error, NULL);
gpr_free(w);
}
GRPC_ERROR_UNREF(tracker->current_error);
gpr_free(tracker->name);
}
@ -92,7 +93,7 @@ grpc_connectivity_state grpc_connectivity_state_check(
grpc_connectivity_state_name(tracker->current_state));
}
if (error != NULL) {
*error = grpc_error_ref(tracker->current_error);
*error = GRPC_ERROR_REF(tracker->current_error);
}
return tracker->current_state;
}
@ -132,7 +133,7 @@ int grpc_connectivity_state_notify_on_state_change(
} else {
if (tracker->current_state != *current) {
*current = tracker->current_state;
grpc_exec_ctx_push(exec_ctx, notify, GRPC_ERROR_NONE, NULL);
grpc_exec_ctx_push(exec_ctx, notify, GRPC_ERROR_REF(tracker->current_error), NULL);
} else {
grpc_connectivity_state_watcher *w = gpr_malloc(sizeof(*w));
w->current = current;
@ -165,7 +166,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(error != GRPC_ERROR_NONE);
break;
}
grpc_error_unref(tracker->current_error);
GRPC_ERROR_UNREF(tracker->current_error);
tracker->current_error = error;
if (tracker->current_state == state) {
return;
@ -176,7 +177,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx *exec_ctx,
*w->current = tracker->current_state;
tracker->watchers = w->next;
grpc_exec_ctx_push(exec_ctx, w->notify,
grpc_error_ref(tracker->current_error), NULL);
GRPC_ERROR_REF(tracker->current_error), NULL);
gpr_free(w);
}
}

@ -146,10 +146,10 @@ char *grpc_transport_get_peer(grpc_exec_ctx *exec_ctx,
void grpc_transport_stream_op_finish_with_failure(grpc_exec_ctx *exec_ctx,
grpc_transport_stream_op *op,
grpc_error *error) {
grpc_exec_ctx_push(exec_ctx, op->recv_message_ready, grpc_error_ref(error),
grpc_exec_ctx_push(exec_ctx, op->recv_message_ready, GRPC_ERROR_REF(error),
NULL);
grpc_exec_ctx_push(exec_ctx, op->recv_initial_metadata_ready,
grpc_error_ref(error), NULL);
GRPC_ERROR_REF(error), NULL);
grpc_exec_ctx_push(exec_ctx, op->on_complete, error, NULL);
}
@ -178,7 +178,7 @@ static void free_message(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
close_message_data *cmd = p;
gpr_slice_unref(cmd->message);
if (cmd->then_call != NULL) {
cmd->then_call->cb(exec_ctx, cmd->then_call->cb_arg, grpc_error_ref(error));
cmd->then_call->cb(exec_ctx, cmd->then_call->cb_arg, GRPC_ERROR_REF(error));
}
gpr_free(cmd);
}

@ -62,7 +62,7 @@ static void thd_func(void *arg) {
gpr_event_set(&a->done_thd, (void *)1);
}
static void done_write(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
thd_args *a = arg;
gpr_event_set(&a->done_write, (void *)1);
}

@ -81,12 +81,13 @@ static char *get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
return gpr_strdup("peer");
}
static void free_channel(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
static void free_channel(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_channel_stack_destroy(exec_ctx, arg);
gpr_free(arg);
}
static void free_call(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
static void free_call(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_call_stack_destroy(exec_ctx, arg, NULL);
gpr_free(arg);
}

@ -67,21 +67,21 @@ static grpc_client_channel_factory cc_factory = {&sc_vtable};
static gpr_mu g_mu;
static bool g_fail_resolution = true;
static grpc_resolved_addresses *my_resolve_address(const char *name,
const char *addr) {
static grpc_error *my_resolve_address(const char *name, const char *addr,
grpc_resolved_addresses **addrs) {
gpr_mu_lock(&g_mu);
GPR_ASSERT(0 == strcmp("test", name));
if (g_fail_resolution) {
g_fail_resolution = false;
gpr_mu_unlock(&g_mu);
return NULL;
return GRPC_ERROR_CREATE("Forced Failure");
} else {
gpr_mu_unlock(&g_mu);
grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(*addrs->addrs));
addrs->addrs[0].len = 123;
return addrs;
*addrs = gpr_malloc(sizeof(*addrs));
(*addrs)->naddrs = 1;
(*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs));
(*addrs)->addrs[0].len = 123;
return GRPC_ERROR_NONE;
}
}
@ -100,7 +100,7 @@ static grpc_resolver *create_resolver(const char *name) {
return resolver;
}
static void on_done(grpc_exec_ctx *exec_ctx, void *ev, bool success) {
static void on_done(grpc_exec_ctx *exec_ctx, void *ev, grpc_error *error) {
gpr_event_set(ev, (void *)1);
}

@ -64,8 +64,8 @@ static int server_port;
static struct rpc_state state;
static grpc_closure on_read;
static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
GPR_ASSERT(success);
static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
GPR_ASSERT(error == GRPC_ERROR_NONE);
gpr_slice_buffer_move_into(&state.temp_incoming_buffer,
&state.incoming_buffer);
if (state.incoming_buffer.length > strlen(magic_connect_string)) {

@ -266,7 +266,9 @@ void test_connect(const char *server_host, const char *client_host, int port,
}
int external_dns_works(const char *host) {
grpc_resolved_addresses *res = grpc_blocking_resolve_address(host, "80");
grpc_resolved_addresses *res;
grpc_error *error = grpc_blocking_resolve_address(host, "80", &res);
GRPC_ERROR_UNREF(error);
if (res != NULL) {
grpc_resolved_addresses_destroy(res);
return 1;

@ -50,7 +50,7 @@
////////////////////////////////////////////////////////////////////////////////
// logging
static const bool squelch = true;
static const bool squelch = !true;
static void dont_log(gpr_log_func_args *args) {}
@ -202,7 +202,7 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg,
*r->addrs = addrs;
grpc_exec_ctx_push(exec_ctx, r->on_done, GRPC_ERROR_NONE, NULL);
} else {
grpc_error_ref(error);
GRPC_ERROR_REF(error);
grpc_exec_ctx_push(
exec_ctx, r->on_done,
GRPC_ERROR_CREATE_REFERENCING("Resolution failed", &error, 1), NULL);
@ -248,7 +248,7 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
future_connect *fc = arg;
if (error != GRPC_ERROR_NONE) {
*fc->ep = NULL;
grpc_exec_ctx_push(exec_ctx, fc->closure, grpc_error_ref(error), NULL);
grpc_exec_ctx_push(exec_ctx, fc->closure, GRPC_ERROR_REF(error), NULL);
} else if (g_server != NULL) {
grpc_endpoint *client;
grpc_endpoint *server;

@ -46,8 +46,9 @@ static void *tag(intptr_t i) { return (void *)i; }
static gpr_mu g_mu;
static int g_resolve_port = -1;
static grpc_resolved_addresses *(*iomgr_resolve_address)(
const char *name, const char *default_port);
static grpc_error *(*iomgr_resolve_address)(const char *name,
const char *default_port,
grpc_resolved_addresses **addrs);
static void set_resolve_port(int port) {
gpr_mu_lock(&g_mu);
@ -55,28 +56,28 @@ static void set_resolve_port(int port) {
gpr_mu_unlock(&g_mu);
}
static grpc_resolved_addresses *my_resolve_address(const char *name,
const char *addr) {
static grpc_error *my_resolve_address(const char *name, const char *addr,
grpc_resolved_addresses **addrs) {
if (0 != strcmp(name, "test")) {
return iomgr_resolve_address(name, addr);
return iomgr_resolve_address(name, addr, addrs);
}
gpr_mu_lock(&g_mu);
if (g_resolve_port < 0) {
gpr_mu_unlock(&g_mu);
return NULL;
return GRPC_ERROR_CREATE("Forced Failure");
} else {
grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(*addrs->addrs));
memset(addrs->addrs, 0, sizeof(*addrs->addrs));
struct sockaddr_in *sa = (struct sockaddr_in *)addrs->addrs[0].addr;
*addrs = gpr_malloc(sizeof(*addrs));
(*addrs)->naddrs = 1;
(*addrs)->addrs = gpr_malloc(sizeof(*(*addrs)->addrs));
memset((*addrs)->addrs, 0, sizeof(*(*addrs)->addrs));
struct sockaddr_in *sa = (struct sockaddr_in *)(*addrs)->addrs[0].addr;
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = htonl(0x7f000001);
sa->sin_port = htons((uint16_t)g_resolve_port);
addrs->addrs[0].len = sizeof(*sa);
(*addrs)->addrs[0].len = sizeof(*sa);
gpr_mu_unlock(&g_mu);
return addrs;
return GRPC_ERROR_NONE;
}
}

@ -202,10 +202,11 @@ typedef struct { grpc_closure *recv_im_ready; } call_data;
typedef struct { uint8_t unused; } channel_data;
static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_call_element *elem = arg;
call_data *calld = elem->call_data;
if (success) {
if (error == GRPC_ERROR_NONE) {
// close the stream with an error.
gpr_slice message =
gpr_slice_from_copied_string("Random failure that's not preventable.");

@ -54,12 +54,11 @@ static gpr_timespec n_seconds_time(int seconds) {
return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds);
}
static void on_finish(grpc_exec_ctx *exec_ctx, void *arg,
const grpc_httpcli_response *response) {
static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
const char *expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
GPR_ASSERT(arg == (void *)42);
grpc_http_response *response = arg;
GPR_ASSERT(response);
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
@ -86,8 +85,10 @@ static void test_get(int port) {
req.http.path = "/get";
req.handshaker = &grpc_httpcli_plaintext;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15),
on_finish, (void *)42);
grpc_closure_create(on_finish, &response), &response);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@ -117,8 +118,11 @@ static void test_post(int port) {
req.http.path = "/post";
req.handshaker = &grpc_httpcli_plaintext;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42);
n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@ -132,7 +136,8 @@ static void test_post(int port) {
gpr_free(host);
}
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, bool success) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
grpc_pollset_destroy(p);
}

@ -54,12 +54,11 @@ static gpr_timespec n_seconds_time(int seconds) {
return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(seconds);
}
static void on_finish(grpc_exec_ctx *exec_ctx, void *arg,
const grpc_httpcli_response *response) {
static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
const char *expect =
"<html><head><title>Hello world!</title></head>"
"<body><p>This is a test</p></body></html>";
GPR_ASSERT(arg == (void *)42);
grpc_http_response *response = arg;
GPR_ASSERT(response);
GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect));
@ -87,8 +86,10 @@ static void test_get(int port) {
req.http.path = "/get";
req.handshaker = &grpc_httpcli_ssl;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15),
on_finish, (void *)42);
grpc_closure_create(on_finish, &response), &response);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@ -119,8 +120,11 @@ static void test_post(int port) {
req.http.path = "/post";
req.handshaker = &grpc_httpcli_ssl;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42);
n_seconds_time(15),
grpc_closure_create(on_finish, &response), &response);
gpr_mu_lock(g_mu);
while (!g_done) {
grpc_pollset_worker *worker = NULL;
@ -134,7 +138,8 @@ static void test_post(int port) {
gpr_free(host);
}
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, bool success) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
grpc_pollset_destroy(p);
}

@ -44,38 +44,39 @@
#include "test/core/util/test_config.h"
static void test_request_succeeds(grpc_slice_split_mode split_mode,
char *request, char *expect_method,
char *request_text, char *expect_method,
grpc_http_version expect_version,
char *expect_path, char *expect_body, ...) {
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(request);
gpr_slice input_slice = gpr_slice_from_copied_string(request_text);
size_t num_slices;
size_t i;
gpr_slice *slices;
va_list args;
grpc_http_request request;
memset(&request, 0, sizeof(request));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_http_parser_init(&parser);
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
for (i = 0; i < num_slices; i++) {
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i]));
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i]) == GRPC_ERROR_NONE);
gpr_slice_unref(slices[i]);
}
GPR_ASSERT(grpc_http_parser_eof(&parser));
GPR_ASSERT(GRPC_HTTP_REQUEST == parser.type);
GPR_ASSERT(0 == strcmp(expect_method, parser.http.request.method));
GPR_ASSERT(0 == strcmp(expect_path, parser.http.request.path));
GPR_ASSERT(expect_version == parser.http.request.version);
GPR_ASSERT(0 == strcmp(expect_method, request.method));
GPR_ASSERT(0 == strcmp(expect_path, request.path));
GPR_ASSERT(expect_version == request.version);
if (expect_body != NULL) {
GPR_ASSERT(strlen(expect_body) == parser.http.request.body_length);
GPR_ASSERT(0 == memcmp(expect_body, parser.http.request.body,
parser.http.request.body_length));
GPR_ASSERT(strlen(expect_body) == request.body_length);
GPR_ASSERT(0 == memcmp(expect_body, request.body, request.body_length));
} else {
GPR_ASSERT(parser.http.request.body_length == 0);
GPR_ASSERT(request.body_length == 0);
}
va_start(args, expect_body);
@ -85,48 +86,48 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode,
char *expect_value;
expect_key = va_arg(args, char *);
if (!expect_key) break;
GPR_ASSERT(i < parser.http.request.hdr_count);
GPR_ASSERT(i < request.hdr_count);
expect_value = va_arg(args, char *);
GPR_ASSERT(expect_value);
GPR_ASSERT(0 == strcmp(expect_key, parser.http.request.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, parser.http.request.hdrs[i].value));
GPR_ASSERT(0 == strcmp(expect_key, request.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, request.hdrs[i].value));
i++;
}
va_end(args);
GPR_ASSERT(i == parser.http.request.hdr_count);
GPR_ASSERT(i == request.hdr_count);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
static void test_succeeds(grpc_slice_split_mode split_mode, char *response,
static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text,
int expect_status, char *expect_body, ...) {
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(response);
gpr_slice input_slice = gpr_slice_from_copied_string(response_text);
size_t num_slices;
size_t i;
gpr_slice *slices;
va_list args;
grpc_http_response response;
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_http_parser_init(&parser);
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
for (i = 0; i < num_slices; i++) {
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i]));
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i]) == GRPC_ERROR_NONE);
gpr_slice_unref(slices[i]);
}
GPR_ASSERT(grpc_http_parser_eof(&parser));
GPR_ASSERT(GRPC_HTTP_RESPONSE == parser.type);
GPR_ASSERT(expect_status == parser.http.response.status);
GPR_ASSERT(expect_status == response.status);
if (expect_body != NULL) {
GPR_ASSERT(strlen(expect_body) == parser.http.response.body_length);
GPR_ASSERT(0 == memcmp(expect_body, parser.http.response.body,
parser.http.response.body_length));
GPR_ASSERT(strlen(expect_body) == response.body_length);
GPR_ASSERT(0 == memcmp(expect_body, response.body, response.body_length));
} else {
GPR_ASSERT(parser.http.response.body_length == 0);
GPR_ASSERT(response.body_length == 0);
}
va_start(args, expect_body);
@ -136,32 +137,67 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response,
char *expect_value;
expect_key = va_arg(args, char *);
if (!expect_key) break;
GPR_ASSERT(i < parser.http.response.hdr_count);
GPR_ASSERT(i < response.hdr_count);
expect_value = va_arg(args, char *);
GPR_ASSERT(expect_value);
GPR_ASSERT(0 == strcmp(expect_key, parser.http.response.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, parser.http.response.hdrs[i].value));
GPR_ASSERT(0 == strcmp(expect_key, response.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, response.hdrs[i].value));
i++;
}
va_end(args);
GPR_ASSERT(i == parser.http.response.hdr_count);
GPR_ASSERT(i == response.hdr_count);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
static void test_fails(grpc_slice_split_mode split_mode, char *response) {
static void test_fails(grpc_slice_split_mode split_mode, char *response_text) {
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(response);
gpr_slice input_slice = gpr_slice_from_copied_string(response_text);
size_t num_slices;
size_t i;
gpr_slice *slices;
grpc_error *error = GRPC_ERROR_NONE;
grpc_http_response response;
memset(&response, 0, sizeof(response));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
for (i = 0; i < num_slices; i++) {
if (GRPC_ERROR_NONE == error) {
error = grpc_http_parser_parse(&parser, slices[i]);
}
gpr_slice_unref(slices[i]);
}
if (GRPC_ERROR_NONE == error) {
error = grpc_http_parser_eof(&parser);
}
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_ERROR_UNREF(error);
grpc_http_response_destroy(&response);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
static void test_request_fails(grpc_slice_split_mode split_mode,
char *request_text) {
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(request_text);
size_t num_slices;
size_t i;
gpr_slice *slices;
int done = 0;
grpc_http_request request;
memset(&request, 0, sizeof(request));
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_http_parser_init(&parser);
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
for (i = 0; i < num_slices; i++) {
if (!done && !grpc_http_parser_parse(&parser, slices[i])) {
@ -174,41 +210,11 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response) {
}
GPR_ASSERT(done);
grpc_http_request_destroy(&request);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
static const uint8_t failed_test1[] = {
0x9e, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x4a,
0x48, 0x54, 0x54, 0x30, 0x32, 0x16, 0xa, 0x2f, 0x48, 0x20,
0x31, 0x2e, 0x31, 0x20, 0x32, 0x30, 0x31, 0x54, 0x54, 0xb9,
0x32, 0x31, 0x2e, 0x20, 0x32, 0x30, 0x20,
};
typedef struct {
const char *name;
const uint8_t *data;
size_t length;
} failed_test;
#define FAILED_TEST(name) \
{ #name, name, sizeof(name) }
failed_test failed_tests[] = {
FAILED_TEST(failed_test1),
};
static void test_doesnt_crash(failed_test t) {
gpr_log(GPR_DEBUG, "Run previously failed test: %s", t.name);
grpc_http_parser p;
grpc_http_parser_init(&p);
gpr_slice slice =
gpr_slice_from_copied_buffer((const char *)t.data, t.length);
grpc_http_parser_parse(&p, slice);
gpr_slice_unref(slice);
grpc_http_parser_destroy(&p);
}
int main(int argc, char **argv) {
size_t i;
const grpc_slice_split_mode split_modes[] = {GRPC_SLICE_SPLIT_IDENTITY,
@ -217,10 +223,6 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
for (i = 0; i < GPR_ARRAY_SIZE(failed_tests); i++) {
test_doesnt_crash(failed_tests[i]);
}
for (i = 0; i < GPR_ARRAY_SIZE(split_modes); i++) {
test_succeeds(split_modes[i],
"HTTP/1.0 200 OK\r\n"
@ -286,12 +288,12 @@ int main(int argc, char **argv) {
" def\r\n"
"\r\n"
"hello world!");
test_fails(split_modes[i], "GET\r\n");
test_fails(split_modes[i], "GET /\r\n");
test_fails(split_modes[i], "GET / HTTP/0.0\r\n");
test_fails(split_modes[i], "GET / ____/1.0\r\n");
test_fails(split_modes[i], "GET / HTTP/1.2\r\n");
test_fails(split_modes[i], "GET / HTTP/1.0\n");
test_request_fails(split_modes[i], "GET\r\n");
test_request_fails(split_modes[i], "GET /\r\n");
test_request_fails(split_modes[i], "GET / HTTP/0.0\r\n");
test_request_fails(split_modes[i], "GET / ____/1.0\r\n");
test_request_fails(split_modes[i], "GET / HTTP/1.2\r\n");
test_request_fails(split_modes[i], "GET / HTTP/1.0\n");
tmp1 = gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save