Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
0d526f47
Commit
0d526f47
authored
9 years ago
by
vjpai
Browse files
Options
Downloads
Plain Diff
Merge branch 'poll_override2' of github.com:vjpai/grpc into poll_override2
parents
657107b6
845447f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cpp/end2end/async_end2end_test.cc
+22
-8
22 additions, 8 deletions
test/cpp/end2end/async_end2end_test.cc
with
22 additions
and
8 deletions
test/cpp/end2end/async_end2end_test.cc
+
22
−
8
View file @
0d526f47
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include
<grpc/grpc.h>
#include
<grpc/grpc.h>
#include
<grpc/support/thd.h>
#include
<grpc/support/thd.h>
#include
<grpc/support/time.h>
#include
<grpc/support/time.h>
#include
<grpc/support/tls.h>
#include
<gtest/gtest.h>
#include
<gtest/gtest.h>
#include
"src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
#include
"src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h"
...
@@ -59,6 +60,8 @@ using grpc::testing::EchoRequest;
...
@@ -59,6 +60,8 @@ using grpc::testing::EchoRequest;
using
grpc
::
testing
::
EchoResponse
;
using
grpc
::
testing
::
EchoResponse
;
using
std
::
chrono
::
system_clock
;
using
std
::
chrono
::
system_clock
;
GPR_TLS_DECL
(
g_is_async_end2end_test
);
namespace
grpc
{
namespace
grpc
{
namespace
testing
{
namespace
testing
{
...
@@ -67,9 +70,11 @@ namespace {
...
@@ -67,9 +70,11 @@ namespace {
void
*
tag
(
int
i
)
{
return
(
void
*
)(
intptr_t
)
i
;
}
void
*
tag
(
int
i
)
{
return
(
void
*
)(
intptr_t
)
i
;
}
#ifdef GPR_POSIX_SOCKET
#ifdef GPR_POSIX_SOCKET
static
int
assert_non_blocking_poll
(
struct
pollfd
*
pfds
,
nfds_t
nfds
,
static
int
maybe_assert_non_blocking_poll
(
struct
pollfd
*
pfds
,
nfds_t
nfds
,
int
timeout
)
{
int
timeout
)
{
GPR_ASSERT
(
timeout
==
0
);
if
(
gpr_tls_get
(
&
g_is_async_end2end_test
))
{
GPR_ASSERT
(
timeout
==
0
);
}
return
poll
(
pfds
,
nfds
,
timeout
);
return
poll
(
pfds
,
nfds
,
timeout
);
}
}
...
@@ -89,7 +94,7 @@ class PollOverride {
...
@@ -89,7 +94,7 @@ class PollOverride {
class
PollingOverrider
:
public
PollOverride
{
class
PollingOverrider
:
public
PollOverride
{
public:
public:
explicit
PollingOverrider
(
bool
allow_blocking
)
explicit
PollingOverrider
(
bool
allow_blocking
)
:
PollOverride
(
allow_blocking
?
poll
:
assert_non_blocking_poll
)
{}
:
PollOverride
(
allow_blocking
?
poll
:
maybe_
assert_non_blocking_poll
)
{}
};
};
#else
#else
class
PollingOverrider
{
class
PollingOverrider
{
...
@@ -180,9 +185,11 @@ class Verifier {
...
@@ -180,9 +185,11 @@ class Verifier {
class
AsyncEnd2endTest
:
public
::
testing
::
TestWithParam
<
bool
>
{
class
AsyncEnd2endTest
:
public
::
testing
::
TestWithParam
<
bool
>
{
protected:
protected:
AsyncEnd2endTest
()
:
poll_override_
(
GetParam
())
{}
AsyncEnd2endTest
()
{}
void
SetUp
()
GRPC_OVERRIDE
{
void
SetUp
()
GRPC_OVERRIDE
{
poll_overrider_
.
reset
(
new
PollingOverrider
(
!
GetParam
()));
int
port
=
grpc_pick_unused_port_or_die
();
int
port
=
grpc_pick_unused_port_or_die
();
server_address_
<<
"localhost:"
<<
port
;
server_address_
<<
"localhost:"
<<
port
;
...
@@ -193,6 +200,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
...
@@ -193,6 +200,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
builder
.
RegisterService
(
&
service_
);
builder
.
RegisterService
(
&
service_
);
cq_
=
builder
.
AddCompletionQueue
();
cq_
=
builder
.
AddCompletionQueue
();
server_
=
builder
.
BuildAndStart
();
server_
=
builder
.
BuildAndStart
();
gpr_tls_set
(
&
g_is_async_end2end_test
,
1
);
}
}
void
TearDown
()
GRPC_OVERRIDE
{
void
TearDown
()
GRPC_OVERRIDE
{
...
@@ -202,6 +211,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
...
@@ -202,6 +211,8 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
cq_
->
Shutdown
();
cq_
->
Shutdown
();
while
(
cq_
->
Next
(
&
ignored_tag
,
&
ignored_ok
))
while
(
cq_
->
Next
(
&
ignored_tag
,
&
ignored_ok
))
;
;
poll_overrider_
.
reset
();
gpr_tls_set
(
&
g_is_async_end2end_test
,
0
);
}
}
void
ResetStub
()
{
void
ResetStub
()
{
...
@@ -250,7 +261,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
...
@@ -250,7 +261,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> {
grpc
::
testing
::
EchoTestService
::
AsyncService
service_
;
grpc
::
testing
::
EchoTestService
::
AsyncService
service_
;
std
::
ostringstream
server_address_
;
std
::
ostringstream
server_address_
;
PollingOverrider
poll_override_
;
std
::
unique_ptr
<
PollingOverrider
>
poll_override
r
_
;
};
};
TEST_P
(
AsyncEnd2endTest
,
SimpleRpc
)
{
TEST_P
(
AsyncEnd2endTest
,
SimpleRpc
)
{
...
@@ -1089,7 +1100,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
...
@@ -1089,7 +1100,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest {
Verifier
(
GetParam
()).
Expect
(
7
,
true
).
Verify
(
cq_
.
get
());
Verifier
(
GetParam
()).
Expect
(
7
,
true
).
Verify
(
cq_
.
get
());
// This is expected to fail in all cases i.e for all values of
// This is expected to fail in all cases i.e for all values of
// server_try_cancel. This is beca
s
ue at this point, either there are no
// server_try_cancel. This is becau
s
e at this point, either there are no
// more msgs from the client (because client called WritesDone) or the RPC
// more msgs from the client (because client called WritesDone) or the RPC
// is cancelled on the server
// is cancelled on the server
srv_stream
.
Read
(
&
recv_request
,
tag
(
8
));
srv_stream
.
Read
(
&
recv_request
,
tag
(
8
));
...
@@ -1166,6 +1177,9 @@ INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel,
...
@@ -1166,6 +1177,9 @@ INSTANTIATE_TEST_CASE_P(AsyncEnd2endServerTryCancel,
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
grpc_test_init
(
argc
,
argv
);
grpc_test_init
(
argc
,
argv
);
gpr_tls_init
(
&
g_is_async_end2end_test
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
int
ret
=
RUN_ALL_TESTS
();
gpr_tls_destroy
(
&
g_is_async_end2end_test
);
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment