Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
c4e34572
Commit
c4e34572
authored
Oct 23, 2017
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix UT on ESTOP temporarily (the impl. will be replaced in next commits)
parent
a5532e30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
bthread_id_unittest.cpp
test/bthread_id_unittest.cpp
+21
-7
No files found.
test/bthread_id_unittest.cpp
View file @
c4e34572
...
...
@@ -284,10 +284,16 @@ TEST(BthreadIdTest, join_after_destroy_before_unlock) {
ASSERT_EQ
(
1UL
,
non_null_ret
);
}
void
*
stopped_waiter
(
void
*
arg
)
{
bthread_id_t
id
=
{
(
uintptr_t
)
arg
};
EXPECT_EQ
(
ESTOP
,
bthread_id_join
(
id
));
EXPECT_EQ
(
get_version
(
id
)
+
4
,
bthread
::
id_value
(
id
));
struct
StoppedWaiterArgs
{
bthread_id_t
id
;
bool
thread_started
;
};
void
*
stopped_waiter
(
void
*
void_arg
)
{
StoppedWaiterArgs
*
args
=
(
StoppedWaiterArgs
*
)
void_arg
;
args
->
thread_started
=
true
;
EXPECT_EQ
(
ESTOP
,
bthread_id_join
(
args
->
id
));
EXPECT_EQ
(
get_version
(
args
->
id
)
+
4
,
bthread
::
id_value
(
args
->
id
));
return
NULL
;
}
...
...
@@ -300,18 +306,26 @@ TEST(BthreadIdTest, stop_a_wait_after_fight_before_signal) {
ASSERT_EQ
(
0
,
bthread_id_trylock
(
id1
,
&
data
));
ASSERT_EQ
(
&
x
,
data
);
bthread_t
th
[
8
];
StoppedWaiterArgs
args
[
ARRAY_SIZE
(
th
)];
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
th
);
++
i
)
{
ASSERT_EQ
(
0
,
bthread_start_urgent
(
&
th
[
i
],
NULL
,
stopped_waiter
,
(
void
*
)(
intptr_t
)
id1
.
value
));
args
[
i
].
id
=
id1
;
args
[
i
].
thread_started
=
false
;
ASSERT_EQ
(
0
,
bthread_start_urgent
(
&
th
[
i
],
NULL
,
stopped_waiter
,
&
args
[
i
]));
}
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
th
);
++
i
)
{
bthread_stop
(
th
[
i
]);
if
(
!
args
[
i
].
thread_started
)
{
bthread_usleep
(
1000
);
}
}
// stop does not wake up bthread_id_join
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
th
);
++
i
)
{
bthread_stop
(
th
[
i
]);
}
bthread_usleep
(
10000
);
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
th
);
++
i
)
{
ASSERT_TRUE
(
bthread
::
TaskGroup
::
exists
(
th
[
i
]));
}
// destroy the id to end the joinings.
ASSERT_EQ
(
0
,
bthread_id_unlock_and_destroy
(
id1
));
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
th
);
++
i
)
{
ASSERT_EQ
(
0
,
bthread_join
(
th
[
i
],
NULL
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment