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