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/ErrnoSetterMatcher.h"
12 #include "test/UnitTest/Test.h"
13 #include "utils/testutils/FDReader.h"
18 TEST(LlvmLibcMkdiratTest
, CreateAndRemove
) {
19 using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds
;
20 constexpr const char *TEST_DIR
= "testdata/mkdirat.testdir";
21 ASSERT_THAT(__llvm_libc::mkdirat(AT_FDCWD
, TEST_DIR
, S_IRWXU
), Succeeds(0));
22 ASSERT_THAT(__llvm_libc::rmdir(TEST_DIR
), Succeeds(0));
25 TEST(LlvmLibcMkdiratTest
, BadPath
) {
26 using __llvm_libc::testing::ErrnoSetterMatcher::Fails
;
27 ASSERT_THAT(__llvm_libc::mkdirat(AT_FDCWD
, "non-existent-dir/test", S_IRWXU
),