xref: /llvm-project/libc/test/src/unistd/pathconf_test.cpp (revision 7f3c40a6613346a4ea856c1462de4fca12dc4fef)
1*7f3c40a6SNhat Nguyen //===-- Unittests for pathconf --------------------------------------------===//
2*7f3c40a6SNhat Nguyen //
3*7f3c40a6SNhat Nguyen // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7f3c40a6SNhat Nguyen // See https://llvm.org/LICENSE.txt for license information.
5*7f3c40a6SNhat Nguyen // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7f3c40a6SNhat Nguyen //
7*7f3c40a6SNhat Nguyen //===----------------------------------------------------------------------===//
8*7f3c40a6SNhat Nguyen #include "hdr/fcntl_macros.h"
9*7f3c40a6SNhat Nguyen #include "hdr/limits_macros.h"
10*7f3c40a6SNhat Nguyen #include "hdr/sys_stat_macros.h"
11*7f3c40a6SNhat Nguyen #include "hdr/unistd_macros.h"
12*7f3c40a6SNhat Nguyen #include "src/fcntl/open.h"
13*7f3c40a6SNhat Nguyen #include "src/unistd/close.h"
14*7f3c40a6SNhat Nguyen #include "src/unistd/pathconf.h"
15*7f3c40a6SNhat Nguyen #include "test/UnitTest/ErrnoSetterMatcher.h"
16*7f3c40a6SNhat Nguyen #include "test/UnitTest/Test.h"
17*7f3c40a6SNhat Nguyen 
18*7f3c40a6SNhat Nguyen using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
19*7f3c40a6SNhat Nguyen 
TEST(LlvmLibcPipeTest,SmokeTest)20*7f3c40a6SNhat Nguyen TEST(LlvmLibcPipeTest, SmokeTest) {
21*7f3c40a6SNhat Nguyen   constexpr const char *FILENAME = "pathconf.test";
22*7f3c40a6SNhat Nguyen   auto TEST_FILE = libc_make_test_file_path(FILENAME);
23*7f3c40a6SNhat Nguyen   int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
24*7f3c40a6SNhat Nguyen   EXPECT_EQ(LIBC_NAMESPACE::pathconf(FILENAME, _PC_SYNC_IO), -1l);
25*7f3c40a6SNhat Nguyen   EXPECT_EQ(LIBC_NAMESPACE::pathconf(FILENAME, _PC_PATH_MAX),
26*7f3c40a6SNhat Nguyen             static_cast<long>(_POSIX_PATH_MAX));
27*7f3c40a6SNhat Nguyen   LIBC_NAMESPACE::close(fd);
28*7f3c40a6SNhat Nguyen }
29*7f3c40a6SNhat Nguyen 
30*7f3c40a6SNhat Nguyen // TODO: Functionality tests
31