Allow building the NotificationQueue tests without event FDs
authorChristopher Dykes <cdykes@fb.com>
Wed, 24 Aug 2016 20:59:55 +0000 (13:59 -0700)
committerFacebook Github Bot 2 <facebook-github-bot-2-bot@fb.com>
Wed, 24 Aug 2016 21:08:41 +0000 (14:08 -0700)
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

index f8e1e51ab01e9e7c94a328cb9c6ca411c76af7d9..c24e6842d2debf3f389b4a76cd44731a3d796718 100644 (file)
 #include <iostream>
 #include <thread>
 #include <sys/types.h>
+
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 
 #include <gtest/gtest.h>
 
@@ -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;