|
|
|
@ -31,50 +31,50 @@ |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include "src/core/ext/transport/chttp2/transport/status_conversion.h" |
|
|
|
|
#include "src/core/lib/transport/status_conversion.h" |
|
|
|
|
#include <grpc/support/log.h> |
|
|
|
|
#include "test/core/util/test_config.h" |
|
|
|
|
|
|
|
|
|
#define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \ |
|
|
|
|
GPR_ASSERT(grpc_chttp2_grpc_status_to_http2_error(a) == (b)) |
|
|
|
|
GPR_ASSERT(grpc_status_to_http2_error(a) == (b)) |
|
|
|
|
#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \ |
|
|
|
|
GPR_ASSERT(grpc_chttp2_http2_error_to_grpc_status(a, deadline) == (b)) |
|
|
|
|
GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)) |
|
|
|
|
#define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \ |
|
|
|
|
GPR_ASSERT(grpc_chttp2_grpc_status_to_http2_status(a) == (b)) |
|
|
|
|
GPR_ASSERT(grpc_status_to_http2_status(a) == (b)) |
|
|
|
|
#define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \ |
|
|
|
|
GPR_ASSERT(grpc_chttp2_http2_status_to_grpc_status(a) == (b)) |
|
|
|
|
GPR_ASSERT(grpc_http2_status_to_grpc_status(a) == (b)) |
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) { |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
grpc_test_init(argc, argv); |
|
|
|
|
|
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_CHTTP2_NO_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_CHTTP2_CANCEL); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OK, GRPC_HTTP2_NO_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_CANCELLED, GRPC_HTTP2_CANCEL); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNKNOWN, GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_INVALID_ARGUMENT, |
|
|
|
|
GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DEADLINE_EXCEEDED, GRPC_CHTTP2_CANCEL); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_NOT_FOUND, GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DEADLINE_EXCEEDED, GRPC_HTTP2_CANCEL); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_NOT_FOUND, GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_ALREADY_EXISTS, |
|
|
|
|
GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_PERMISSION_DENIED, |
|
|
|
|
GRPC_CHTTP2_INADEQUATE_SECURITY); |
|
|
|
|
GRPC_HTTP2_INADEQUATE_SECURITY); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAUTHENTICATED, |
|
|
|
|
GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_RESOURCE_EXHAUSTED, |
|
|
|
|
GRPC_CHTTP2_ENHANCE_YOUR_CALM); |
|
|
|
|
GRPC_HTTP2_ENHANCE_YOUR_CALM); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_FAILED_PRECONDITION, |
|
|
|
|
GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_ABORTED, GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_ABORTED, GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_OUT_OF_RANGE, |
|
|
|
|
GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNIMPLEMENTED, |
|
|
|
|
GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_INTERNAL, GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_INTERNAL, GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_UNAVAILABLE, |
|
|
|
|
GRPC_CHTTP2_REFUSED_STREAM); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_CHTTP2_INTERNAL_ERROR); |
|
|
|
|
GRPC_HTTP2_REFUSED_STREAM); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_ERROR(GRPC_STATUS_DATA_LOSS, GRPC_HTTP2_INTERNAL_ERROR); |
|
|
|
|
|
|
|
|
|
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_OK, 200); |
|
|
|
|
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_CANCELLED, 200); |
|
|
|
@ -95,59 +95,59 @@ int main(int argc, char **argv) { |
|
|
|
|
GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200); |
|
|
|
|
|
|
|
|
|
const gpr_timespec before_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_NO_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_PROTOCOL_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INTERNAL_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INTERNAL_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FLOW_CONTROL_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FLOW_CONTROL_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_SETTINGS_TIMEOUT, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_SETTINGS_TIMEOUT, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_STREAM_CLOSED, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_STREAM_CLOSED, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FRAME_SIZE_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FRAME_SIZE_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_REFUSED_STREAM, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_REFUSED_STREAM, before_deadline, |
|
|
|
|
GRPC_STATUS_UNAVAILABLE); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CANCEL, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CANCEL, before_deadline, |
|
|
|
|
GRPC_STATUS_CANCELLED); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_COMPRESSION_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_COMPRESSION_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CONNECT_ERROR, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CONNECT_ERROR, before_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_ENHANCE_YOUR_CALM, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_ENHANCE_YOUR_CALM, before_deadline, |
|
|
|
|
GRPC_STATUS_RESOURCE_EXHAUSTED); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INADEQUATE_SECURITY, before_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, before_deadline, |
|
|
|
|
GRPC_STATUS_PERMISSION_DENIED); |
|
|
|
|
|
|
|
|
|
const gpr_timespec after_deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_NO_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_PROTOCOL_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INTERNAL_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INTERNAL_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FLOW_CONTROL_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FLOW_CONTROL_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_SETTINGS_TIMEOUT, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_SETTINGS_TIMEOUT, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_STREAM_CLOSED, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_STREAM_CLOSED, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_FRAME_SIZE_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_FRAME_SIZE_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_REFUSED_STREAM, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_REFUSED_STREAM, after_deadline, |
|
|
|
|
GRPC_STATUS_UNAVAILABLE); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CANCEL, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CANCEL, after_deadline, |
|
|
|
|
GRPC_STATUS_DEADLINE_EXCEEDED); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_COMPRESSION_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_COMPRESSION_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_CONNECT_ERROR, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_CONNECT_ERROR, after_deadline, |
|
|
|
|
GRPC_STATUS_INTERNAL); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_ENHANCE_YOUR_CALM, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_ENHANCE_YOUR_CALM, after_deadline, |
|
|
|
|
GRPC_STATUS_RESOURCE_EXHAUSTED); |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_CHTTP2_INADEQUATE_SECURITY, after_deadline, |
|
|
|
|
HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, after_deadline, |
|
|
|
|
GRPC_STATUS_PERMISSION_DENIED); |
|
|
|
|
|
|
|
|
|
HTTP2_STATUS_TO_GRPC_STATUS(200, GRPC_STATUS_OK); |
|
|
|
@ -165,7 +165,7 @@ int main(int argc, char **argv) { |
|
|
|
|
|
|
|
|
|
/* check all status values can be converted */ |
|
|
|
|
for (i = 0; i <= 999; i++) { |
|
|
|
|
grpc_chttp2_http2_status_to_grpc_status(i); |
|
|
|
|
grpc_http2_status_to_grpc_status(i); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |