1 | //===-- Unittests for fpathconf -------------------------------------------===// |
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/fcntl_macros.h" |
9 | #include "hdr/limits_macros.h" |
10 | #include "hdr/sys_stat_macros.h" |
11 | #include "hdr/unistd_macros.h" |
12 | #include "src/fcntl/open.h" |
13 | #include "src/unistd/close.h" |
14 | #include "src/unistd/fpathconf.h" |
15 | #include "test/UnitTest/ErrnoCheckingTest.h" |
16 | #include "test/UnitTest/ErrnoSetterMatcher.h" |
17 | #include "test/UnitTest/Test.h" |
18 | |
19 | using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher; |
20 | using LlvmLibcFpathconfTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest; |
21 | |
22 | TEST_F(LlvmLibcFpathconfTest, SmokeTest) { |
23 | constexpr const char *FILENAME = "fpathconf.test" ; |
24 | auto TEST_FILE = libc_make_test_file_path(FILENAME); |
25 | int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU); |
26 | ASSERT_ERRNO_SUCCESS(); |
27 | ASSERT_GT(fd, 0); |
28 | |
29 | EXPECT_EQ(LIBC_NAMESPACE::fpathconf(fd, _PC_SYNC_IO), -1l); |
30 | EXPECT_EQ(LIBC_NAMESPACE::fpathconf(fd, _PC_PATH_MAX), |
31 | static_cast<long>(_POSIX_PATH_MAX)); |
32 | ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0)); |
33 | } |
34 | |
35 | // TODO: Functionality tests |
36 | |