Commit 87fd6e8c authored by Kenton Varda's avatar Kenton Varda

OSX doesn't support sigqueue().

parent bcafdb77
...@@ -437,7 +437,7 @@ TEST(Async, TaskSet) { ...@@ -437,7 +437,7 @@ TEST(Async, TaskSet) {
})); }));
EXPECT_EQ(4, counter); EXPECT_EQ(4, counter);
EXPECT_EQ(1, errorHandler.exceptionCount); EXPECT_EQ(1u, errorHandler.exceptionCount);
} }
} // namespace } // namespace
......
...@@ -52,6 +52,22 @@ public: ...@@ -52,6 +52,22 @@ public:
TEST_F(AsyncUnixTest, Signals) { TEST_F(AsyncUnixTest, Signals) {
UnixEventLoop loop; UnixEventLoop loop;
kill(getpid(), SIGUSR2);
siginfo_t info = loop.wait(loop.onSignal(SIGUSR2));
EXPECT_EQ(SIGUSR2, info.si_signo);
EXPECT_EQ(SI_USER, info.si_code);
}
#ifdef SIGRTMIN
TEST_F(AsyncUnixTest, SignalWithValue) {
// This tests that if we use sigqueue() to attach a value to the signal, that value is received
// correctly. Note that this only works on platforms that support real-time signals -- even
// though the signal we're sending is SIGUSR2, the sigqueue() system call is introduced by RT
// signals. Hence this test won't run on e.g. Mac OSX.
UnixEventLoop loop;
union sigval value; union sigval value;
value.sival_int = 123; value.sival_int = 123;
sigqueue(getpid(), SIGUSR2, value); sigqueue(getpid(), SIGUSR2, value);
...@@ -61,6 +77,7 @@ TEST_F(AsyncUnixTest, Signals) { ...@@ -61,6 +77,7 @@ TEST_F(AsyncUnixTest, Signals) {
EXPECT_EQ(SI_QUEUE, info.si_code); EXPECT_EQ(SI_QUEUE, info.si_code);
EXPECT_EQ(123, info.si_value.sival_int); EXPECT_EQ(123, info.si_value.sival_int);
} }
#endif
TEST_F(AsyncUnixTest, SignalsMulti) { TEST_F(AsyncUnixTest, SignalsMulti) {
UnixEventLoop loop; UnixEventLoop loop;
...@@ -71,14 +88,11 @@ TEST_F(AsyncUnixTest, SignalsMulti) { ...@@ -71,14 +88,11 @@ TEST_F(AsyncUnixTest, SignalsMulti) {
ADD_FAILURE() << "Received wrong signal."; ADD_FAILURE() << "Received wrong signal.";
})); }));
union sigval value; kill(getpid(), SIGUSR2);
value.sival_int = 123;
sigqueue(getpid(), SIGUSR2, value);
siginfo_t info = loop.wait(loop.onSignal(SIGUSR2)); siginfo_t info = loop.wait(loop.onSignal(SIGUSR2));
EXPECT_EQ(SIGUSR2, info.si_signo); EXPECT_EQ(SIGUSR2, info.si_signo);
EXPECT_EQ(SI_QUEUE, info.si_code); EXPECT_EQ(SI_USER, info.si_code);
EXPECT_EQ(123, info.si_value.sival_int);
} }
TEST_F(AsyncUnixTest, SignalsAsync) { TEST_F(AsyncUnixTest, SignalsAsync) {
...@@ -96,17 +110,14 @@ TEST_F(AsyncUnixTest, SignalsAsync) { ...@@ -96,17 +110,14 @@ TEST_F(AsyncUnixTest, SignalsAsync) {
[&](siginfo_t&& info) { [&](siginfo_t&& info) {
received = true; received = true;
EXPECT_EQ(SIGUSR2, info.si_signo); EXPECT_EQ(SIGUSR2, info.si_signo);
EXPECT_EQ(SI_QUEUE, info.si_code); EXPECT_EQ(SI_USER, info.si_code);
EXPECT_EQ(123, info.si_value.sival_int);
}); });
delay(); delay();
EXPECT_FALSE(received); EXPECT_FALSE(received);
union sigval value; kill(getpid(), SIGUSR2);
value.sival_int = 123;
sigqueue(getpid(), SIGUSR2, value);
SimpleEventLoop mainLoop; SimpleEventLoop mainLoop;
mainLoop.wait(kj::mv(promise)); mainLoop.wait(kj::mv(promise));
......
...@@ -34,7 +34,7 @@ TEST(Common, Size) { ...@@ -34,7 +34,7 @@ TEST(Common, Size) {
for (size_t i: indices(arr)) { for (size_t i: indices(arr)) {
EXPECT_EQ(expected++, i); EXPECT_EQ(expected++, i);
} }
EXPECT_EQ(4, expected); EXPECT_EQ(4u, expected);
} }
TEST(Common, Maybe) { TEST(Common, Maybe) {
......
linux-gcc-4.7 1605 ./super-test.sh tmpdir capnp-gcc-4.7 quick linux-gcc-4.7 1630 ./super-test.sh tmpdir capnp-gcc-4.7 quick
linux-gcc-4.8 1608 ./super-test.sh tmpdir capnp-gcc-4.8 quick gcc-4.8 linux-gcc-4.8 1633 ./super-test.sh tmpdir capnp-gcc-4.8 quick gcc-4.8
linux-clang 1625 ./super-test.sh tmpdir capnp-clang quick clang linux-clang 1650 ./super-test.sh tmpdir capnp-clang quick clang
mac 758 ./super-test.sh remote beat caffeinate quick mac 758 ./super-test.sh remote beat caffeinate quick
cygwin 763 ./super-test.sh remote Kenton@flashman quick cygwin 769 ./super-test.sh remote Kenton@flashman quick
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment