aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-02-16 09:20:50 -0800
committerGravatar Vijay Pai <vpai@google.com>2016-02-16 09:20:50 -0800
commit018879aa9a37fa2351c71d6699e71743a92f6a18 (patch)
tree3faecef189a43470db51422fc1740982c808b670 /test
parentcf4daebe2764cb5da664c7b2e406c48ee44dfeaa (diff)
Set up poll overrides
Diffstat (limited to 'test')
-rw-r--r--test/cpp/end2end/async_end2end_test.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 78417fc6d0..aa99061fe9 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -67,10 +67,10 @@ namespace {
void* tag(int i) { return (void*)(intptr_t)i; }
#ifdef GPR_POSIX_SOCKET
-static int assert_non_blocking_poll(struct pollfd* pfds, nfds_t nfds,
+static int non_blocking_poll(struct pollfd* pfds, nfds_t nfds,
int timeout) {
- GPR_ASSERT(timeout == 0);
- return poll(pfds, nfds, timeout);
+ /* ignore timeout and always use timeout 0 */
+ return poll(pfds, nfds, 0);
}
class PollOverride {
@@ -89,7 +89,7 @@ class PollOverride {
class PollingOverrider : public PollOverride {
public:
explicit PollingOverrider(bool allow_blocking)
- : PollOverride(allow_blocking ? poll : assert_non_blocking_poll) {}
+ : PollOverride(allow_blocking ? poll : non_blocking_poll) {}
};
#else
class PollingOverrider {
@@ -180,9 +180,11 @@ class Verifier {
class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
protected:
- AsyncEnd2endTest(): poll_override_(GetParam()) {}
+ AsyncEnd2endTest() {}
void SetUp() GRPC_OVERRIDE {
+ poll_overrider_.reset(new PollingOverrider(!GetParam()));
+
int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port;
@@ -202,6 +204,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
cq_->Shutdown();
while (cq_->Next(&ignored_tag, &ignored_ok))
;
+ poll_overrider_.reset();
}
void ResetStub() {
@@ -250,7 +253,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
grpc::testing::EchoTestService::AsyncService service_;
std::ostringstream server_address_;
- PollingOverrider poll_override_;
+ std::unique_ptr<PollingOverrider> poll_overrider_;
};
TEST_P(AsyncEnd2endTest, SimpleRpc) {
@@ -1089,7 +1092,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
Verifier(GetParam()).Expect(7, true).Verify(cq_.get());
// This is expected to fail in all cases i.e for all values of
- // server_try_cancel. This is becasue at this point, either there are no
+ // server_try_cancel. This is because at this point, either there are no
// more msgs from the client (because client called WritesDone) or the RPC
// is cancelled on the server
srv_stream.Read(&recv_request, tag(8));