Commit db014c85 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 2

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
parent 0826d16b
...@@ -22,7 +22,10 @@ ...@@ -22,7 +22,10 @@
#include <iostream> #include <iostream>
#include <thread> #include <thread>
#include <sys/types.h> #include <sys/types.h>
#ifndef _WIN32
#include <sys/wait.h> #include <sys/wait.h>
#endif
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -48,11 +51,8 @@ class QueueConsumer : public IntQueue::Consumer { ...@@ -48,11 +51,8 @@ class QueueConsumer : public IntQueue::Consumer {
class QueueTest { class QueueTest {
public: public:
explicit QueueTest(uint32_t maxSize = 0, explicit QueueTest(uint32_t maxSize, IntQueue::FdType type)
IntQueue::FdType type = IntQueue::FdType::EVENTFD) : : queue(maxSize, type), terminationQueue(maxSize, type) {}
queue(maxSize, type),
terminationQueue(maxSize, type)
{}
void sendOne(); void sendOne();
void putMessages(); void putMessages();
...@@ -507,35 +507,37 @@ TEST(NotificationQueueTest, ConsumeUntilDrainedStress) { ...@@ -507,35 +507,37 @@ TEST(NotificationQueueTest, ConsumeUntilDrainedStress) {
} }
} }
TEST(NotificationQueueTest, SendOne) { #ifdef FOLLY_HAVE_EVENTFD
QueueTest qt; TEST(NotificationQueueTest, SendOneEventFD) {
QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.sendOne(); qt.sendOne();
} }
TEST(NotificationQueueTest, PutMessages) { TEST(NotificationQueueTest, PutMessagesEventFD) {
QueueTest qt; QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.sendOne(); qt.sendOne();
} }
TEST(NotificationQueueTest, MultiConsumer) { TEST(NotificationQueueTest, MultiConsumerEventFD) {
QueueTest qt; QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.multiConsumer(); qt.multiConsumer();
} }
TEST(NotificationQueueTest, MaxQueueSize) { TEST(NotificationQueueTest, MaxQueueSizeEventFD) {
QueueTest qt(5); QueueTest qt(5, IntQueue::FdType::EVENTFD);
qt.maxQueueSize(); qt.maxQueueSize();
} }
TEST(NotificationQueueTest, MaxReadAtOnce) { TEST(NotificationQueueTest, MaxReadAtOnceEventFD) {
QueueTest qt; QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.maxReadAtOnce(); qt.maxReadAtOnce();
} }
TEST(NotificationQueueTest, DestroyCallback) { TEST(NotificationQueueTest, DestroyCallbackEventFD) {
QueueTest qt; QueueTest qt(0, IntQueue::FdType::EVENTFD);
qt.destroyCallback(); qt.destroyCallback();
} }
#endif
TEST(NotificationQueueTest, SendOnePipe) { TEST(NotificationQueueTest, SendOnePipe) {
QueueTest qt(0, IntQueue::FdType::PIPE); QueueTest qt(0, IntQueue::FdType::PIPE);
...@@ -567,6 +569,7 @@ TEST(NotificationQueueTest, DestroyCallbackPipe) { ...@@ -567,6 +569,7 @@ TEST(NotificationQueueTest, DestroyCallbackPipe) {
qt.destroyCallback(); qt.destroyCallback();
} }
#ifndef _WIN32
/* /*
* Test code that creates a NotificationQueue, then forks, and incorrectly * Test code that creates a NotificationQueue, then forks, and incorrectly
* tries to send a message to the queue from the child process. * tries to send a message to the queue from the child process.
...@@ -640,6 +643,7 @@ TEST(NotificationQueueTest, UseAfterFork) { ...@@ -640,6 +643,7 @@ TEST(NotificationQueueTest, UseAfterFork) {
EXPECT_EQ(5678, consumer.messages.front()); EXPECT_EQ(5678, consumer.messages.front());
consumer.messages.pop_front(); consumer.messages.pop_front();
} }
#endif
TEST(NotificationQueueConsumer, make) { TEST(NotificationQueueConsumer, make) {
int value = 0; int value = 0;
......
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