From 65dbb9df6485bd0c48718c00b8e05e1a7ca18345 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 29 Nov 2017 10:06:30 -0800 Subject: Add test for RecvStatus error_string API --- test/core/end2end/tests/simple_request.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index ec7425aa09..86fe5d1e20 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -99,6 +99,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_metadata_array request_metadata_recv; grpc_call_details call_details; grpc_status_code status; + const char* error_string; grpc_call_error error; grpc_slice details; int was_cancelled = 2; @@ -148,6 +149,7 @@ static void simple_request_body(grpc_end2end_test_config config, op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; op->data.recv_status_on_client.status = &status; op->data.recv_status_on_client.status_details = &details; + op->data.recv_status_on_client.error_string = &error_string; op->flags = 0; op->reserved = nullptr; op++; @@ -199,6 +201,16 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); + // the following sanity check makes sure that the requested error string is + // correctly populated by the core. It looks for certain substrings that are + // not likely to change much. Some parts of the error, like time created, + // obviously are not checked. + GPR_ASSERT(nullptr != strstr(error_string, "xyz")); + GPR_ASSERT(nullptr != strstr(error_string, "description")); + GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer")); + GPR_ASSERT(nullptr != strstr(error_string, "src/core/lib/surface/call.cc")); + GPR_ASSERT(nullptr != strstr(error_string, "grpc_message")); + GPR_ASSERT(nullptr != strstr(error_string, "grpc_status")); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); @@ -206,6 +218,7 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(was_cancelled == 1); grpc_slice_unref(details); + gpr_free((void*)error_string); grpc_metadata_array_destroy(&initial_metadata_recv); grpc_metadata_array_destroy(&trailing_metadata_recv); grpc_metadata_array_destroy(&request_metadata_recv); -- cgit v1.2.3 From 6ab0ba8df5ada5f39dc5a828d6f433cb170a0941 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 29 Nov 2017 13:32:46 -0800 Subject: clang fmt --- test/core/end2end/tests/simple_request.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index 86fe5d1e20..2ff5434813 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -201,7 +201,7 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); - // the following sanity check makes sure that the requested error string is + // the following sanity check makes sure that the requested error string is // correctly populated by the core. It looks for certain substrings that are // not likely to change much. Some parts of the error, like time created, // obviously are not checked. @@ -210,7 +210,7 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer")); GPR_ASSERT(nullptr != strstr(error_string, "src/core/lib/surface/call.cc")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_message")); - GPR_ASSERT(nullptr != strstr(error_string, "grpc_status")); + GPR_ASSERT(nullptr != strstr(error_string, "grpc_status")); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); -- cgit v1.2.3 From c7d1f93e7695d5de2a4fccef93e81471d05b64a8 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 29 Nov 2017 14:05:33 -0800 Subject: Fix windows --- test/core/end2end/tests/simple_request.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc index 2ff5434813..7eb7467981 100644 --- a/test/core/end2end/tests/simple_request.cc +++ b/test/core/end2end/tests/simple_request.cc @@ -208,7 +208,6 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(nullptr != strstr(error_string, "xyz")); GPR_ASSERT(nullptr != strstr(error_string, "description")); GPR_ASSERT(nullptr != strstr(error_string, "Error received from peer")); - GPR_ASSERT(nullptr != strstr(error_string, "src/core/lib/surface/call.cc")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_message")); GPR_ASSERT(nullptr != strstr(error_string, "grpc_status")); GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo")); -- cgit v1.2.3 From 9b6283a95223546805ea794d3b7b4126b104f0eb Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 29 Nov 2017 14:06:17 -0800 Subject: Make API comment more specific: --- include/grpc/impl/codegen/grpc_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index c8c1437c91..ad668b4f11 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -560,7 +560,7 @@ typedef struct grpc_op { grpc_slice* status_details; /** If this is not nullptr, it will be populated with the full fidelity * error string for debugging purposes. The application is responsible - * for freeing the data. */ + * for freeing the data by using gpr_free(). */ const char** error_string; } recv_status_on_client; struct grpc_op_recv_close_on_server { -- cgit v1.2.3