30 lines · cpp
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-exception6//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 18using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;19using LlvmLibcSelectTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;20 21TEST_F(LlvmLibcSelectTest, SelectInvalidFD) {22 fd_set set;23 FD_ZERO(&set);24 struct timeval timeout {25 0, 026 };27 ASSERT_THAT(LIBC_NAMESPACE::select(-1, &set, nullptr, nullptr, &timeout),28 Fails(EINVAL));29}30