[libc-commits] [libc] [libc] Implement fcntl() function (PR #89507)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Apr 26 15:06:09 PDT 2024


================
@@ -0,0 +1,144 @@
+//===-- Unittest for fcntl ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/errno/libc_errno.h"
+#include "src/fcntl/fcntl.h"
+#include "src/fcntl/open.h"
+#include "src/unistd/close.h"
+#include "test/UnitTest/ErrnoSetterMatcher.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcFcntlTest, FcntlDupfd) {
+  using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
+  constexpr const char *TEST_FILE = "testdata/fcntl.test";
----------------
michaelrj-google wrote:

For these tests you should use the `libc_make_test_file_path` function to ensure that the files end up in the correct directory. Look at `test/src/unistd/read_write_test.cpp` for an example.
Also, each test should use a different filename since they may be run in parallel.

https://github.com/llvm/llvm-project/pull/89507


More information about the libc-commits mailing list