Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
e54850e9
Commit
e54850e9
authored
Jul 06, 2019
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for UnixEventPort polling for signals (without waiting).
Cygwin seems to be having an issue with this...
parent
3a9c6665
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
6 deletions
+64
-6
async-unix-test.c++
c++/src/kj/async-unix-test.c++
+64
-6
No files found.
c++/src/kj/async-unix-test.c++
View file @
e54850e9
...
...
@@ -679,14 +679,48 @@ TEST(AsyncUnixTest, Wake) {
EXPECT_FALSE
(
port
.
wait
());
}
bool
woken
=
false
;
Thread
thread
([
&
]()
{
// Test wake() when already wait()ing.
{
Thread
thread
([
&
]()
{
delay
();
port
.
wake
();
});
EXPECT_TRUE
(
port
.
wait
());
}
// Test wait() after wake() already happened.
{
Thread
thread
([
&
]()
{
port
.
wake
();
});
delay
();
woken
=
true
;
port
.
wake
();
});
EXPECT_TRUE
(
port
.
wait
());
}
EXPECT_TRUE
(
port
.
wait
());
// Test wake() during poll() busy loop.
{
Thread
thread
([
&
]()
{
delay
();
port
.
wake
();
});
EXPECT_FALSE
(
port
.
poll
());
while
(
!
port
.
poll
())
{}
}
// Test poll() when wake() already delivered.
{
EXPECT_FALSE
(
port
.
poll
());
Thread
thread
([
&
]()
{
port
.
wake
();
});
delay
();
EXPECT_TRUE
(
port
.
poll
());
}
}
int
exitCodeForSignal
=
0
;
...
...
@@ -815,6 +849,30 @@ KJ_TEST("UnixEventPort whenWriteDisconnected()") {
hupPromise
.
wait
(
waitScope
);
}
KJ_TEST
(
"UnixEventPort poll for signals"
)
{
captureSignals
();
UnixEventPort
port
;
EventLoop
loop
(
port
);
WaitScope
waitScope
(
loop
);
auto
promise1
=
port
.
onSignal
(
SIGURG
);
auto
promise2
=
port
.
onSignal
(
SIGIO
);
KJ_EXPECT
(
!
promise1
.
poll
(
waitScope
));
KJ_EXPECT
(
!
promise2
.
poll
(
waitScope
));
KJ_SYSCALL
(
raise
(
SIGURG
));
KJ_SYSCALL
(
raise
(
SIGIO
));
port
.
wake
();
KJ_EXPECT
(
port
.
poll
());
KJ_EXPECT
(
promise1
.
poll
(
waitScope
));
KJ_EXPECT
(
promise2
.
poll
(
waitScope
));
promise1
.
wait
(
waitScope
);
promise2
.
wait
(
waitScope
);
}
}
// namespace
}
// namespace kj
...
...
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