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
bb29c724
Commit
bb29c724
authored
7 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Fix combiner test
parent
55a82130
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/core/iomgr/combiner_test.c
+22
-10
22 additions, 10 deletions
test/core/iomgr/combiner_test.c
with
22 additions
and
10 deletions
test/core/iomgr/combiner_test.c
+
22
−
10
View file @
bb29c724
...
@@ -48,23 +48,25 @@ static void test_no_op(void) {
...
@@ -48,23 +48,25 @@ static void test_no_op(void) {
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
}
static
void
set_
bool
_to_true
(
grpc_exec_ctx
*
exec_ctx
,
void
*
value
,
static
void
set_
event
_to_true
(
grpc_exec_ctx
*
exec_ctx
,
void
*
value
,
grpc_error
*
error
)
{
grpc_error
*
error
)
{
*
(
bool
*
)
value
=
true
;
gpr_event_set
(
value
,
(
void
*
)
1
)
;
}
}
static
void
test_execute_one
(
void
)
{
static
void
test_execute_one
(
void
)
{
gpr_log
(
GPR_DEBUG
,
"test_execute_one"
);
gpr_log
(
GPR_DEBUG
,
"test_execute_one"
);
grpc_combiner
*
lock
=
grpc_combiner_create
();
grpc_combiner
*
lock
=
grpc_combiner_create
();
bool
done
=
false
;
gpr_event
done
;
gpr_event_init
(
&
done
);
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_closure_sched
(
&
exec_ctx
,
grpc_closure_sched
(
&
exec_ctx
,
grpc_closure_create
(
set_
bool
_to_true
,
&
done
,
grpc_closure_create
(
set_
event
_to_true
,
&
done
,
grpc_combiner_scheduler
(
lock
)),
grpc_combiner_scheduler
(
lock
)),
GRPC_ERROR_NONE
);
GRPC_ERROR_NONE
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
GPR_ASSERT
(
done
);
GPR_ASSERT
(
gpr_event_wait
(
&
done
,
grpc_timeout_seconds_to_deadline
(
5
))
!=
NULL
);
GRPC_COMBINER_UNREF
(
&
exec_ctx
,
lock
,
"test_execute_one"
);
GRPC_COMBINER_UNREF
(
&
exec_ctx
,
lock
,
"test_execute_one"
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
}
...
@@ -72,6 +74,7 @@ static void test_execute_one(void) {
...
@@ -72,6 +74,7 @@ static void test_execute_one(void) {
typedef
struct
{
typedef
struct
{
size_t
ctr
;
size_t
ctr
;
grpc_combiner
*
lock
;
grpc_combiner
*
lock
;
gpr_event
done
;
}
thd_args
;
}
thd_args
;
typedef
struct
{
typedef
struct
{
...
@@ -105,6 +108,10 @@ static void execute_many_loop(void *a) {
...
@@ -105,6 +108,10 @@ static void execute_many_loop(void *a) {
// picking it up
// picking it up
gpr_sleep_until
(
grpc_timeout_milliseconds_to_deadline
(
100
));
gpr_sleep_until
(
grpc_timeout_milliseconds_to_deadline
(
100
));
}
}
grpc_closure_sched
(
&
exec_ctx
,
grpc_closure_create
(
set_event_to_true
,
&
args
->
done
,
grpc_combiner_scheduler
(
args
->
lock
)),
GRPC_ERROR_NONE
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
}
...
@@ -119,9 +126,12 @@ static void test_execute_many(void) {
...
@@ -119,9 +126,12 @@ static void test_execute_many(void) {
gpr_thd_options_set_joinable
(
&
options
);
gpr_thd_options_set_joinable
(
&
options
);
ta
[
i
].
ctr
=
0
;
ta
[
i
].
ctr
=
0
;
ta
[
i
].
lock
=
lock
;
ta
[
i
].
lock
=
lock
;
gpr_event_init
(
&
ta
[
i
].
done
);
GPR_ASSERT
(
gpr_thd_new
(
&
thds
[
i
],
execute_many_loop
,
&
ta
[
i
],
&
options
));
GPR_ASSERT
(
gpr_thd_new
(
&
thds
[
i
],
execute_many_loop
,
&
ta
[
i
],
&
options
));
}
}
for
(
size_t
i
=
0
;
i
<
GPR_ARRAY_SIZE
(
thds
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
GPR_ARRAY_SIZE
(
thds
);
i
++
)
{
GPR_ASSERT
(
gpr_event_wait
(
&
ta
[
i
].
done
,
gpr_inf_future
(
GPR_CLOCK_REALTIME
))
!=
NULL
);
gpr_thd_join
(
thds
[
i
]);
gpr_thd_join
(
thds
[
i
]);
}
}
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
...
@@ -129,15 +139,15 @@ static void test_execute_many(void) {
...
@@ -129,15 +139,15 @@ static void test_execute_many(void) {
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
}
static
bool
got_in_finally
=
false
;
static
gpr_event
got_in_finally
;
static
void
in_finally
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
static
void
in_finally
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
got_in_finally
=
true
;
gpr_event_set
(
&
got_in_finally
,
(
void
*
)
1
)
;
}
}
static
void
add_finally
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
static
void
add_finally
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
grpc_closure_sched
(
exec_ctx
,
grpc_closure_sched
(
exec_ctx
,
grpc_closure_create
(
in_finally
,
NULL
,
grpc_closure_create
(
in_finally
,
arg
,
grpc_combiner_finally_scheduler
(
arg
)),
grpc_combiner_finally_scheduler
(
arg
)),
GRPC_ERROR_NONE
);
GRPC_ERROR_NONE
);
}
}
...
@@ -147,12 +157,14 @@ static void test_execute_finally(void) {
...
@@ -147,12 +157,14 @@ static void test_execute_finally(void) {
grpc_combiner
*
lock
=
grpc_combiner_create
();
grpc_combiner
*
lock
=
grpc_combiner_create
();
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
gpr_event_init
(
&
got_in_finally
);
grpc_closure_sched
(
grpc_closure_sched
(
&
exec_ctx
,
&
exec_ctx
,
grpc_closure_create
(
add_finally
,
lock
,
grpc_combiner_scheduler
(
lock
)),
grpc_closure_create
(
add_finally
,
lock
,
grpc_combiner_scheduler
(
lock
)),
GRPC_ERROR_NONE
);
GRPC_ERROR_NONE
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
grpc_exec_ctx_flush
(
&
exec_ctx
);
GPR_ASSERT
(
got_in_finally
);
GPR_ASSERT
(
gpr_event_wait
(
&
got_in_finally
,
grpc_timeout_seconds_to_deadline
(
5
))
!=
NULL
);
GRPC_COMBINER_UNREF
(
&
exec_ctx
,
lock
,
"test_execute_finally"
);
GRPC_COMBINER_UNREF
(
&
exec_ctx
,
lock
,
"test_execute_finally"
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
}
...
...
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