Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / test / src / unistd / rmdir_test.cpp
blob69228ce98c82244e14645582a21d1672314ae1a5
1 //===-- Unittests for rmdir -----------------------------------------------===//
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 //===----------------------------------------------------------------------===//
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 <fcntl.h>
17 TEST(LlvmLibcRmdirTest, CreateAndRemove) {
18 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
19 constexpr const char *TEST_DIR = "testdata/rmdir.testdir";
20 ASSERT_THAT(LIBC_NAMESPACE::mkdir(TEST_DIR, S_IRWXU), Succeeds(0));
21 ASSERT_THAT(LIBC_NAMESPACE::rmdir(TEST_DIR), Succeeds(0));
24 TEST(LlvmLibcRmdirTest, RemoveNonExistentDir) {
25 using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
26 ASSERT_THAT(LIBC_NAMESPACE::rmdir("testdata/non-existent-dir"),
27 Fails(ENOENT));