Skip to content

Commit

Permalink
[tests] Added test case for PR #605
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored and rndi committed Mar 20, 2019
1 parent 7f9d5e6 commit 959ae55
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/test_epoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,42 @@ TEST(CEPoll, WaitNoSocketsInEpoll)
}


TEST(CEPoll, WaitEmptyCall)
{
ASSERT_EQ(srt_startup(), 0);

SRTSOCKET client_sock = srt_socket(AF_INET, SOCK_DGRAM, 0);
ASSERT_NE(client_sock, SRT_ERROR);

const int yes = 1;
const int no = 0;
ASSERT_NE(srt_setsockopt(client_sock, 0, SRTO_RCVSYN, &no, sizeof no), SRT_ERROR); // for async connect
ASSERT_NE(srt_setsockopt(client_sock, 0, SRTO_SNDSYN, &no, sizeof no), SRT_ERROR); // for async connect
ASSERT_NE(srt_setsockflag(client_sock, SRTO_SENDER, &yes, sizeof yes), SRT_ERROR);
ASSERT_NE(srt_setsockopt(client_sock, 0, SRTO_TSBPDMODE, &yes, sizeof yes), SRT_ERROR);

const int epoll_id = srt_epoll_create();
ASSERT_GE(epoll_id, 0);

const int epoll_out = SRT_EPOLL_OUT | SRT_EPOLL_ERR;
ASSERT_NE(srt_epoll_add_usock(epoll_id, client_sock, &epoll_out), SRT_ERROR);

ASSERT_EQ(srt_epoll_wait(epoll_id, 0, NULL, 0, NULL,
-1, 0, 0, 0, 0), SRT_ERROR);

try
{
EXPECT_EQ(srt_epoll_release(epoll_id), 0);
}
catch (CUDTException &ex)
{
cerr << ex.getErrorMessage() << endl;
EXPECT_EQ(0, 1);
}
EXPECT_EQ(srt_cleanup(), 0);
}


TEST(CEPoll, WaitAllSocketsInEpollReleased)
{
ASSERT_EQ(srt_startup(), 0);
Expand Down

0 comments on commit 959ae55

Please sign in to comment.