1 //===-- Unittests for mkdirat ---------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/sys/stat/mkdirat.h"
10 #include "src/unistd/rmdir.h"
11 #include "test/UnitTest/ErrnoSetterMatcher.h"
12 #include "test/UnitTest/Test.h"
14 #include "hdr/fcntl_macros.h"
16 TEST(LlvmLibcMkdiratTest
, CreateAndRemove
) {
17 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds
;
18 constexpr const char *FILENAME
= "testdata/mkdirat.testdir";
19 auto TEST_DIR
= libc_make_test_file_path(FILENAME
);
20 ASSERT_THAT(LIBC_NAMESPACE::mkdirat(AT_FDCWD
, TEST_DIR
, S_IRWXU
),
22 ASSERT_THAT(LIBC_NAMESPACE::rmdir(TEST_DIR
), Succeeds(0));
25 TEST(LlvmLibcMkdiratTest
, BadPath
) {
26 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails
;
28 LIBC_NAMESPACE::mkdirat(AT_FDCWD
, "non-existent-dir/test", S_IRWXU
),