From db014c85124f168523d7272ce57fc931c543671f Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Wed, 24 Aug 2016 13:59:55 -0700 Subject: [PATCH] Allow building the NotificationQueue tests without event FDs Summary: Because event file descriptors don't exist on Windows. This also disables the fork() test on Windows, as we don't have fork(). Reviewed By: yfeldblum Differential Revision: D3766266 fbshipit-source-id: af8d81615957a3d7bdfcb204afbf648723921f76 --- folly/io/async/test/NotificationQueueTest.cpp | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/folly/io/async/test/NotificationQueueTest.cpp b/folly/io/async/test/NotificationQueueTest.cpp index f8e1e51a..c24e6842 100644 --- a/folly/io/async/test/NotificationQueueTest.cpp +++ b/folly/io/async/test/NotificationQueueTest.cpp @@ -22,7 +22,10 @@ #include #include #include + +#ifndef _WIN32 #include +#endif #include @@ -48,11 +51,8 @@ class QueueConsumer : public IntQueue::Consumer { class QueueTest { public: - explicit QueueTest(uint32_t maxSize = 0, - IntQueue::FdType type = IntQueue::FdType::EVENTFD) : - queue(maxSize, type), - terminationQueue(maxSize, type) - {} + explicit QueueTest(uint32_t maxSize, IntQueue::FdType type) + : queue(maxSize, type), terminationQueue(maxSize, type) {} void sendOne(); void putMessages(); @@ -507,35 +507,37 @@ TEST(NotificationQueueTest, ConsumeUntilDrainedStress) { } } -TEST(NotificationQueueTest, SendOne) { - QueueTest qt; +#ifdef FOLLY_HAVE_EVENTFD +TEST(NotificationQueueTest, SendOneEventFD) { + QueueTest qt(0, IntQueue::FdType::EVENTFD); qt.sendOne(); } -TEST(NotificationQueueTest, PutMessages) { - QueueTest qt; +TEST(NotificationQueueTest, PutMessagesEventFD) { + QueueTest qt(0, IntQueue::FdType::EVENTFD); qt.sendOne(); } -TEST(NotificationQueueTest, MultiConsumer) { - QueueTest qt; +TEST(NotificationQueueTest, MultiConsumerEventFD) { + QueueTest qt(0, IntQueue::FdType::EVENTFD); qt.multiConsumer(); } -TEST(NotificationQueueTest, MaxQueueSize) { - QueueTest qt(5); +TEST(NotificationQueueTest, MaxQueueSizeEventFD) { + QueueTest qt(5, IntQueue::FdType::EVENTFD); qt.maxQueueSize(); } -TEST(NotificationQueueTest, MaxReadAtOnce) { - QueueTest qt; +TEST(NotificationQueueTest, MaxReadAtOnceEventFD) { + QueueTest qt(0, IntQueue::FdType::EVENTFD); qt.maxReadAtOnce(); } -TEST(NotificationQueueTest, DestroyCallback) { - QueueTest qt; +TEST(NotificationQueueTest, DestroyCallbackEventFD) { + QueueTest qt(0, IntQueue::FdType::EVENTFD); qt.destroyCallback(); } +#endif TEST(NotificationQueueTest, SendOnePipe) { QueueTest qt(0, IntQueue::FdType::PIPE); @@ -567,6 +569,7 @@ TEST(NotificationQueueTest, DestroyCallbackPipe) { qt.destroyCallback(); } +#ifndef _WIN32 /* * Test code that creates a NotificationQueue, then forks, and incorrectly * tries to send a message to the queue from the child process. @@ -640,6 +643,7 @@ TEST(NotificationQueueTest, UseAfterFork) { EXPECT_EQ(5678, consumer.messages.front()); consumer.messages.pop_front(); } +#endif TEST(NotificationQueueConsumer, make) { int value = 0; -- 2.34.1