@ -29,6 +29,7 @@
# include <ares.h>
# include <gtest/gtest.h>
# include "absl/log/check.h"
# include "absl/strings/str_cat.h"
# include "absl/strings/str_format.h"
# include "absl/time/clock.h"
@ -94,7 +95,7 @@ class HttpRequestTest : public ::testing::Test {
void RunAndKick ( const std : : function < void ( ) > & f ) {
grpc_core : : MutexLockForGprMu lock ( mu_ ) ;
f ( ) ;
GPR_ASSERT ( GRPC_LOG_IF_ERROR (
CHECK ( GRPC_LOG_IF_ERROR (
" pollset_kick " ,
grpc_pollset_kick ( grpc_polling_entity_pollset ( & pops_ ) , nullptr ) ) ) ;
}
@ -102,9 +103,9 @@ class HttpRequestTest : public ::testing::Test {
void PollUntil ( const std : : function < bool ( ) > & predicate , absl : : Time deadline ) {
gpr_mu_lock ( mu_ ) ;
while ( ! predicate ( ) ) {
GPR_ASSERT ( absl : : Now ( ) < deadline ) ;
CHECK ( absl : : Now ( ) < deadline ) ;
grpc_pollset_worker * worker = nullptr ;
GPR_ASSERT ( GRPC_LOG_IF_ERROR (
CHECK ( GRPC_LOG_IF_ERROR (
" pollset_work " , grpc_pollset_work ( grpc_polling_entity_pollset ( & pops_ ) ,
& worker , NSecondsTime ( 1 ) ) ) ) ;
gpr_mu_unlock ( mu_ ) ;
@ -164,10 +165,10 @@ void OnFinish(void* arg, grpc_error_handle error) {
grpc_http_response response = request_state - > response ;
gpr_log ( GPR_INFO , " response status=%d error=%s " , response . status ,
grpc_core : : StatusToString ( error ) . c_str ( ) ) ;
GPR_ASSERT ( error . ok ( ) ) ;
GPR_ASSERT ( response . status = = 200 ) ;
GPR_ASSERT ( response . body_length = = strlen ( expect ) ) ;
GPR_ASSERT ( 0 = = memcmp ( expect , response . body , response . body_length ) ) ;
CHECK ( error . ok ( ) ) ;
CHECK_EQ ( response . status , 200 ) ;
CHECK ( response . body_length = = strlen ( expect ) ) ;
CHECK_EQ ( memcmp ( expect , response . body , response . body_length ) , 0 ) ;
request_state - > test - > RunAndKick (
[ request_state ] ( ) { request_state - > done = true ; } ) ;
}
@ -183,7 +184,7 @@ void OnFinishExpectFailure(void* arg, grpc_error_handle error) {
grpc_http_response response = request_state - > response ;
gpr_log ( GPR_INFO , " response status=%d error=%s " , response . status ,
grpc_core : : StatusToString ( error ) . c_str ( ) ) ;
GPR_ASSERT ( ! error . ok ( ) ) ;
CHECK ( ! error . ok ( ) ) ;
request_state - > test - > RunAndKick (
[ request_state ] ( ) { request_state - > done = true ; } ) ;
}
@ -197,7 +198,7 @@ TEST_F(HttpRequestTest, Get) {
memset ( & req , 0 , sizeof ( req ) ) ;
auto uri = grpc_core : : URI : : Create ( " http " , host , " /get " , { } /* query params */ ,
" " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Get (
std : : move ( * uri ) , nullptr /* channel args */ , pops ( ) , & req ,
@ -223,7 +224,7 @@ TEST_F(HttpRequestTest, Post) {
req . body_length = 5 ;
auto uri = grpc_core : : URI : : Create ( " http " , host , " /post " ,
{ } /* query params */ , " " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Post (
std : : move ( * uri ) , nullptr /* channel args */ , pops ( ) , & req ,
@ -252,8 +253,7 @@ void InjectNonResponsiveDNSServer(ares_channel* channel) {
dns_server_addrs [ 0 ] . tcp_port = g_fake_non_responsive_dns_server_port ;
dns_server_addrs [ 0 ] . udp_port = g_fake_non_responsive_dns_server_port ;
dns_server_addrs [ 0 ] . next = nullptr ;
GPR_ASSERT ( ares_set_servers_ports ( * channel , dns_server_addrs ) = =
ARES_SUCCESS ) ;
CHECK ( ares_set_servers_ports ( * channel , dns_server_addrs ) = = ARES_SUCCESS ) ;
}
TEST_F ( HttpRequestTest , CancelGetDuringDNSResolution ) {
@ -280,7 +280,7 @@ TEST_F(HttpRequestTest, CancelGetDuringDNSResolution) {
auto uri = grpc_core : : URI : : Create (
" http " , " dont-care-since-wont-be-resolved.test.com:443 " , " /get " ,
{ } /* query params */ , " " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Get (
std : : move ( * uri ) , nullptr /* channel args */ , pops ( ) , & req ,
@ -336,7 +336,7 @@ TEST_F(HttpRequestTest, CancelGetWhileReadingResponse) {
auto uri = grpc_core : : URI : : Create ( " http " , fake_http_server_ptr - > address ( ) ,
" /get " , { } /* query params */ ,
" " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Get (
std : : move ( * uri ) , nullptr /* channel args */ , pops ( ) , & req ,
@ -397,7 +397,7 @@ TEST_F(HttpRequestTest, CancelGetRacesWithConnectionFailure) {
auto uri =
grpc_core : : URI : : Create ( " http " , fake_server_address , " /get " ,
{ } /* query params */ , " " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Get (
std : : move ( * uri ) , nullptr /* channel args */ , pops ( ) , & req ,
@ -462,7 +462,7 @@ TEST_F(HttpRequestTest, CallerPollentsAreNotReferencedAfterCallbackIsRan) {
request_state . pollset_set_to_destroy_eagerly ) ;
auto uri = grpc_core : : URI : : Create ( " http " , fake_server_address , " /get " ,
{ } /* query params */ , " " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Get (
std : : move ( * uri ) , nullptr /* channel args */ ,
@ -515,7 +515,7 @@ TEST_F(HttpRequestTest,
memset ( & req , 0 , sizeof ( req ) ) ;
auto uri = grpc_core : : URI : : Create ( " http " , host , " /get " , { } /* query params */ ,
" " /* fragment */ ) ;
GPR_ASSERT ( uri . ok ( ) ) ;
CHECK ( uri . ok ( ) ) ;
grpc_core : : OrphanablePtr < grpc_core : : HttpRequest > http_request =
grpc_core : : HttpRequest : : Get (
std : : move ( * uri ) , nullptr /* channel args */ , pops ( ) , & req ,