aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/inproc_callback_test.cc
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-08-24 09:04:28 -0700
committerGravatar Vijay Pai <vpai@google.com>2018-08-24 09:04:28 -0700
commit679cbb83a4178e3073d08e293a020fb39244bfe0 (patch)
treeb67bc31a2c70f3a182e2dfd999be5085a74128a1 /test/core/end2end/inproc_callback_test.cc
parent4f98f82c36d47ff6b3c85b61854c093f93c15eb3 (diff)
Improve comments and revert much of 373cb20
Diffstat (limited to 'test/core/end2end/inproc_callback_test.cc')
-rw-r--r--test/core/end2end/inproc_callback_test.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/test/core/end2end/inproc_callback_test.cc b/test/core/end2end/inproc_callback_test.cc
index a07b4df29a..0d6c7c75a8 100644
--- a/test/core/end2end/inproc_callback_test.cc
+++ b/test/core/end2end/inproc_callback_test.cc
@@ -106,7 +106,7 @@ bool tags_needed[kAvailableTags];
// Mark that a tag is expected; this function must be executed in the
// main thread only while there are no other threads altering the
-// expectation set (e.g., running callbacks).
+// expectation set (e.g., by calling expect_tag or verify_tags)
static void expect_tag(intptr_t tag, bool ok) {
size_t idx = static_cast<size_t>(tag);
GPR_ASSERT(idx < kAvailableTags);
@@ -114,10 +114,14 @@ static void expect_tag(intptr_t tag, bool ok) {
tags_expected[idx] = ok;
}
-// The tag verifier doesn't have to drive the CQ at all (unlike the
-// next-based end2end tests) because the tags will get set when the
-// callbacks are executed, which happens when a particular batch
-// related to a callback is complete
+// Check that the expected tags have reached, within a certain
+// deadline. This must also be executed only on the main thread while
+// there are no other threads altering the expectation set (e.g., by
+// calling expect_tag or verify_tags). The tag verifier doesn't have
+// to drive the CQ at all (unlike the next-based end2end tests)
+// because the tags will get set when the callbacks are executed,
+// which happens when a particular batch related to a callback is
+// complete.
static void verify_tags(gpr_timespec deadline) {
bool done = false;
@@ -342,14 +346,13 @@ static void simple_request_body(grpc_end2end_test_config config,
GPR_ASSERT(GRPC_CALL_OK == error);
// Register a call at the server-side to match the incoming client call
- // First mark that we are expecting its tag to complete in this round
- expect_tag(2, true);
error = grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(2));
GPR_ASSERT(GRPC_CALL_OK == error);
// We expect that the server call creation callback (and no others) will
// execute now since no other batch should be complete.
+ expect_tag(2, true);
verify_tags(deadline);
peer = grpc_call_get_peer(s);
@@ -361,11 +364,6 @@ static void simple_request_body(grpc_end2end_test_config config,
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
- // Both the client request and server response batches should get complete
- // in this round and we should see that their callbacks get executed
- expect_tag(3, true);
- expect_tag(1, true);
-
// Create the server response batch (no payload)
memset(ops, 0, sizeof(ops));
op = ops;
@@ -391,7 +389,10 @@ static void simple_request_body(grpc_end2end_test_config config,
nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
- // Make sure that the tags get executed by the deadline
+ // Both the client request and server response batches should get complete
+ // now and we should see that their callbacks have been executed
+ expect_tag(3, true);
+ expect_tag(1, true);
verify_tags(deadline);
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED);