1//===-- Unittests for epoll_create ----------------------------------------===//
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 "src/sys/epoll/epoll_create.h"
9#include "src/unistd/close.h"
10#include "test/UnitTest/ErrnoCheckingTest.h"
11#include "test/UnitTest/ErrnoSetterMatcher.h"
12#include "test/UnitTest/Test.h"
13#include <sys/syscall.h> // For syscall numbers.
14
15using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
16using LlvmLibcEpollCreateTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
17
18TEST_F(LlvmLibcEpollCreateTest, Basic) {
19 int fd = LIBC_NAMESPACE::epoll_create(1);
20 ASSERT_GT(fd, 0);
21 ASSERT_ERRNO_SUCCESS();
22
23 ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
24}
25
26#ifdef SYS_epoll_create
27TEST_F(LlvmLibcEpollCreateTest, Fails) {
28 ASSERT_THAT(LIBC_NAMESPACE::epoll_create(0), Fails(EINVAL));
29}
30#endif
31

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

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