proxygen
AsyncSignalHandlerTest.cpp File Reference

Go to the source code of this file.

Functions

 TEST (AsyncSignalHandler, basic)
 
 TEST (AsyncSignalHandler, attachEventBase)
 

Function Documentation

TEST ( AsyncSignalHandler  ,
basic   
)

Definition at line 36 of file AsyncSignalHandlerTest.cpp.

References EXPECT_FALSE, EXPECT_TRUE, handler(), and folly::EventBase::loopOnce().

36  {
37  EventBase evb;
38  TestSignalHandler handler{&evb};
39 
40  handler.registerSignalHandler(SIGUSR1);
41  kill(getpid(), SIGUSR1);
42 
43  EXPECT_FALSE(handler.called);
44  evb.loopOnce(EVLOOP_NONBLOCK);
45  EXPECT_TRUE(handler.called);
46 }
void handler(int, siginfo_t *, void *)
bool loopOnce(int flags=0)
Definition: EventBase.cpp:271
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( AsyncSignalHandler  ,
attachEventBase   
)

Definition at line 48 of file AsyncSignalHandlerTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, and handler().

48  {
49  TestSignalHandler handler{nullptr};
50  EXPECT_FALSE(handler.getEventBase());
51  EventBase evb;
52 
53  handler.attachEventBase(&evb);
54  EXPECT_EQ(&evb, handler.getEventBase());
55 
56  handler.registerSignalHandler(SIGUSR1);
57  kill(getpid(), SIGUSR1);
58  EXPECT_FALSE(handler.called);
59  evb.loopOnce(EVLOOP_NONBLOCK);
60  EXPECT_TRUE(handler.called);
61 
62  handler.unregisterSignalHandler(SIGUSR1);
63  handler.detachEventBase();
64  EXPECT_FALSE(handler.getEventBase());
65 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
void handler(int, siginfo_t *, void *)
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862