From 959ae556cd285420bf07d4726f3b27d35ae7d75a Mon Sep 17 00:00:00 2001 From: Maxim Sharabayko Date: Tue, 12 Mar 2019 15:46:49 +0100 Subject: [PATCH] [tests] Added test case for PR #605 --- test/test_epoll.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/test_epoll.cpp b/test/test_epoll.cpp index 31a1fb8b0..212046e8a 100644 --- a/test/test_epoll.cpp +++ b/test/test_epoll.cpp @@ -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);