1 //===-- Unittests for rmdir -----------------------------------------------===//
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/errno/libc_errno.h"
10 #include "src/sys/stat/mkdir.h"
11 #include "src/unistd/rmdir.h"
12 #include "test/UnitTest/ErrnoSetterMatcher.h"
13 #include "test/UnitTest/Test.h"
15 #include "hdr/fcntl_macros.h"
17 TEST(LlvmLibcRmdirTest
, CreateAndRemove
) {
18 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds
;
19 constexpr const char *FILENAME
= "rmdir.testdir";
20 auto TEST_DIR
= libc_make_test_file_path(FILENAME
);
21 ASSERT_THAT(LIBC_NAMESPACE::mkdir(TEST_DIR
, S_IRWXU
), Succeeds(0));
22 ASSERT_THAT(LIBC_NAMESPACE::rmdir(TEST_DIR
), Succeeds(0));
25 TEST(LlvmLibcRmdirTest
, RemoveNonExistentDir
) {
26 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails
;
27 ASSERT_THAT(LIBC_NAMESPACE::rmdir("non-existent-dir"), Fails(ENOENT
));