1//===-- Unittests for epoll_create1 ---------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8#include "hdr/sys_epoll_macros.h"
9#include "src/sys/epoll/epoll_create1.h"
10#include "src/unistd/close.h"
11#include "test/UnitTest/ErrnoCheckingTest.h"
12#include "test/UnitTest/ErrnoSetterMatcher.h"
13#include "test/UnitTest/Test.h"
14
15using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
16using LlvmLibcEpollCreate1Test = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
17
18TEST_F(LlvmLibcEpollCreate1Test, Basic) {
19 int fd = LIBC_NAMESPACE::epoll_create1(0);
20 ASSERT_GT(fd, 0);
21 ASSERT_ERRNO_SUCCESS();
22
23 ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
24}
25
26TEST_F(LlvmLibcEpollCreate1Test, CloseOnExecute) {
27 int fd = LIBC_NAMESPACE::epoll_create1(EPOLL_CLOEXEC);
28 ASSERT_GT(fd, 0);
29 ASSERT_ERRNO_SUCCESS();
30
31 ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
32}
33

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of libc/test/src/sys/epoll/linux/epoll_create1_test.cpp