1//===-- Failure unittests for select --------------------------------------===//
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
9#include "src/sys/select/select.h"
10#include "src/unistd/read.h"
11#include "test/UnitTest/ErrnoSetterMatcher.h"
12#include "test/UnitTest/Test.h"
13
14#include <errno.h>
15#include <sys/select.h>
16#include <unistd.h>
17
18using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
19
20TEST(LlvmLibcSelectTest, SelectInvalidFD) {
21 fd_set set;
22 FD_ZERO(&set);
23 struct timeval timeout {
24 .tv_sec: 0, .tv_usec: 0
25 };
26 ASSERT_THAT(LIBC_NAMESPACE::select(-1, &set, nullptr, nullptr, &timeout),
27 Fails(EINVAL));
28}
29

source code of libc/test/src/sys/select/select_failure_test.cpp