Merge pull request #13549 from ncteisen/test-error-string-api

Add test for RecvStatus error_string API
pull/13013/head^2
Noah Eisen 7 years ago committed by GitHub
commit c49b24a7c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      include/grpc/impl/codegen/grpc_types.h
  2. 12
      test/core/end2end/tests/simple_request.cc

@ -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 {

@ -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,15 @@ 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, "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 +217,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);

Loading…
Cancel
Save