Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Bluetooth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
LMODroid
platform_packages_modules_Bluetooth
Commits
6dd2123b
Commit
6dd2123b
authored
2 years ago
by
Henri Chataing
Committed by
Gerrit Code Review
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge "RootCanal: Improvements in rootcanal_test_host"
parents
2627355a
158545c8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/rootcanal/test/async_manager_unittest.cc
+13
-12
13 additions, 12 deletions
tools/rootcanal/test/async_manager_unittest.cc
with
13 additions
and
12 deletions
tools/rootcanal/test/async_manager_unittest.cc
+
13
−
12
View file @
6dd2123b
...
...
@@ -112,12 +112,13 @@ class AsyncManagerSocketTest : public ::testing::Test {
do
{
n
=
read
(
fd
,
server_buffer_
,
kBufferSize
-
1
);
}
while
(
n
==
-
1
&&
errno
==
EAGAIN
);
ASSERT_GE
(
n
,
0
)
<<
strerror
(
errno
);
if
(
n
==
0
)
{
// got EOF
if
(
n
==
0
||
errno
==
EBADF
)
{
// Got EOF, or file descriptor disconnected.
async_manager_
.
StopWatchingFileDescriptor
(
fd
);
close
(
fd
);
}
else
{
ASSERT_GE
(
n
,
0
)
<<
strerror
(
errno
);
n
=
write
(
fd
,
"1"
,
1
);
}
}
...
...
@@ -235,33 +236,33 @@ TEST_F(AsyncManagerSocketTest, CanUnsubscribeTaskFromWithinTask) {
running
.
set
(
true
);
});
EXPECT_TRUE
(
running
.
wait_for
(
10ms
));
EXPECT_TRUE
(
running
.
wait_for
(
10
0
ms
));
}
TEST_F
(
AsyncManagerSocketTest
,
UnsubScribeWaitsUntilCompletion
)
{
using
namespace
std
::
chrono_literals
;
Event
running
;
bool
cancel_done
=
false
;
bool
task_complete
=
false
;
async_manager_
.
ExecAsyncPeriodically
(
std
::
atomic
<
bool
>
cancel_done
=
false
;
std
::
atomic
<
bool
>
task_complete
=
false
;
AsyncTaskId
task_id
=
async_manager_
.
ExecAsyncPeriodically
(
1
,
1ms
,
2ms
,
[
&
running
,
&
cancel_done
,
&
task_complete
]()
{
// Let the other thread now we are in the callback..
running
.
set
(
true
);
// Wee bit of a hack that relies on timing..
std
::
this_thread
::
sleep_for
(
20ms
);
EXPECT_FALSE
(
cancel_done
)
EXPECT_FALSE
(
cancel_done
.
load
()
)
<<
"Task cancellation did not wait for us to complete!"
;
task_complete
=
true
;
task_complete
.
store
(
true
)
;
});
EXPECT_TRUE
(
running
.
wait_for
(
10ms
));
EXPECT_TRUE
(
running
.
wait_for
(
10
0
ms
));
auto
start
=
std
::
chrono
::
system_clock
::
now
();
// There is a 20ms wait.. so we know that this should take some time.
EXPECT_TRUE
(
async_manager_
.
CancelAsyncTask
(
1
))
EXPECT_TRUE
(
async_manager_
.
CancelAsyncTask
(
task_id
))
<<
"We were scheduled, so cancel should return true"
;
cancel_done
=
true
;
EXPECT_TRUE
(
task_complete
)
cancel_done
.
store
(
true
)
;
EXPECT_TRUE
(
task_complete
.
load
()
)
<<
"We managed to cancel a task while it was not yet finished."
;
auto
end
=
std
::
chrono
::
system_clock
::
now
();
auto
passed_ms
=
...
...
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