[libc-commits] [libc] c0ad6e2 - [libc] fix unit tests (#75361)
via libc-commits
libc-commits at lists.llvm.org
Wed Dec 13 09:55:34 PST 2023
Author: Nick Desaulniers
Date: 2023-12-13T09:55:29-08:00
New Revision: c0ad6e2fa6353d06aa62b4874f48d5ba2159de56
URL: https://github.com/llvm/llvm-project/commit/c0ad6e2fa6353d06aa62b4874f48d5ba2159de56
DIFF: https://github.com/llvm/llvm-project/commit/c0ad6e2fa6353d06aa62b4874f48d5ba2159de56.diff
LOG: [libc] fix unit tests (#75361)
Fixes #75261
Added:
Modified:
libc/test/src/fcntl/creat_test.cpp
libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
libc/test/src/unistd/access_test.cpp
libc/test/src/unistd/dup2_test.cpp
libc/test/src/unistd/dup3_test.cpp
libc/test/src/unistd/dup_test.cpp
libc/test/src/unistd/ftruncate_test.cpp
libc/test/src/unistd/isatty_test.cpp
libc/test/src/unistd/link_test.cpp
libc/test/src/unistd/linkat_test.cpp
libc/test/src/unistd/pread_pwrite_test.cpp
libc/test/src/unistd/read_write_test.cpp
libc/test/src/unistd/symlink_test.cpp
libc/test/src/unistd/symlinkat_test.cpp
libc/test/src/unistd/syscall_test.cpp
libc/test/src/unistd/truncate_test.cpp
libc/test/src/unistd/unlink_test.cpp
libc/test/src/unistd/unlinkat_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp
index ca926b30e62faf..ef30d8862c45f2 100644
--- a/libc/test/src/fcntl/creat_test.cpp
+++ b/libc/test/src/fcntl/creat_test.cpp
@@ -13,6 +13,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcCreatTest, CreatAndOpen) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/creat.test";
diff --git a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
index 7e6bb0aaca9251..0870deeeb5d801 100644
--- a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
+++ b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
@@ -17,6 +17,7 @@
#include "test/UnitTest/Test.h"
#include <sys/resource.h>
+#include <sys/stat.h>
TEST(LlvmLibcResourceLimitsTest, SetNoFileLimit) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
diff --git a/libc/test/src/unistd/access_test.cpp b/libc/test/src/unistd/access_test.cpp
index ed1fe96f4f4a16..7d4b3be443fed4 100644
--- a/libc/test/src/unistd/access_test.cpp
+++ b/libc/test/src/unistd/access_test.cpp
@@ -14,6 +14,7 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
#include <unistd.h>
TEST(LlvmLibcAccessTest, CreateAndTest) {
diff --git a/libc/test/src/unistd/dup2_test.cpp b/libc/test/src/unistd/dup2_test.cpp
index ff870db0334c93..d46c4b919ce72c 100644
--- a/libc/test/src/unistd/dup2_test.cpp
+++ b/libc/test/src/unistd/dup2_test.cpp
@@ -16,6 +16,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
constexpr int DUPFD = 0xD0;
libc_errno = 0;
diff --git a/libc/test/src/unistd/dup3_test.cpp b/libc/test/src/unistd/dup3_test.cpp
index 279cfbfea1b144..d2d544d5d9a12f 100644
--- a/libc/test/src/unistd/dup3_test.cpp
+++ b/libc/test/src/unistd/dup3_test.cpp
@@ -16,6 +16,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
// The tests here are exactly the same as those of dup2. We only test the
// plumbing of the dup3 syscall and not the dup3 functionality itself as it is
// a simple syscall wrapper. Testing dup3 functionality is beyond the scope of
diff --git a/libc/test/src/unistd/dup_test.cpp b/libc/test/src/unistd/dup_test.cpp
index 38c439125db3d7..856b004fbe65d5 100644
--- a/libc/test/src/unistd/dup_test.cpp
+++ b/libc/test/src/unistd/dup_test.cpp
@@ -16,6 +16,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
libc_errno = 0;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
diff --git a/libc/test/src/unistd/ftruncate_test.cpp b/libc/test/src/unistd/ftruncate_test.cpp
index ae743b385e220d..fc68348e32ec66 100644
--- a/libc/test/src/unistd/ftruncate_test.cpp
+++ b/libc/test/src/unistd/ftruncate_test.cpp
@@ -17,6 +17,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
namespace cpp = LIBC_NAMESPACE::cpp;
TEST(LlvmLibcFtruncateTest, CreateAndTruncate) {
diff --git a/libc/test/src/unistd/isatty_test.cpp b/libc/test/src/unistd/isatty_test.cpp
index fce4a3e5f5062a..7bf8dd708bfa6f 100644
--- a/libc/test/src/unistd/isatty_test.cpp
+++ b/libc/test/src/unistd/isatty_test.cpp
@@ -13,6 +13,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
diff --git a/libc/test/src/unistd/link_test.cpp b/libc/test/src/unistd/link_test.cpp
index b1b9383cb62ee0..2d5aa7588b08b9 100644
--- a/libc/test/src/unistd/link_test.cpp
+++ b/libc/test/src/unistd/link_test.cpp
@@ -14,6 +14,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcLinkTest, CreateAndUnlink) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/link.test";
diff --git a/libc/test/src/unistd/linkat_test.cpp b/libc/test/src/unistd/linkat_test.cpp
index 2ef41cd4e75f6a..d1ffe37d63b48c 100644
--- a/libc/test/src/unistd/linkat_test.cpp
+++ b/libc/test/src/unistd/linkat_test.cpp
@@ -14,6 +14,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcLinkatTest, CreateAndUnlink) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_DIR = "testdata";
diff --git a/libc/test/src/unistd/pread_pwrite_test.cpp b/libc/test/src/unistd/pread_pwrite_test.cpp
index 6819f559424f3e..f90d1341c20108 100644
--- a/libc/test/src/unistd/pread_pwrite_test.cpp
+++ b/libc/test/src/unistd/pread_pwrite_test.cpp
@@ -17,6 +17,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcUniStd, PWriteAndPReadBackTest) {
// The strategy here is that we first create a file and write to it. Next,
// we open that file again and write at an offset. Finally, we open the
diff --git a/libc/test/src/unistd/read_write_test.cpp b/libc/test/src/unistd/read_write_test.cpp
index 20b51bb8082b12..3007d4c3871157 100644
--- a/libc/test/src/unistd/read_write_test.cpp
+++ b/libc/test/src/unistd/read_write_test.cpp
@@ -15,6 +15,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcUniStd, WriteAndReadBackTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "__unistd_read_write.test";
diff --git a/libc/test/src/unistd/symlink_test.cpp b/libc/test/src/unistd/symlink_test.cpp
index 84d963b7a207ce..b25cfa4f857699 100644
--- a/libc/test/src/unistd/symlink_test.cpp
+++ b/libc/test/src/unistd/symlink_test.cpp
@@ -14,6 +14,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcSymlinkTest, CreateAndUnlink) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE_BASE = "symlink.test";
diff --git a/libc/test/src/unistd/symlinkat_test.cpp b/libc/test/src/unistd/symlinkat_test.cpp
index b0308787f2052a..8aba2daee8cf38 100644
--- a/libc/test/src/unistd/symlinkat_test.cpp
+++ b/libc/test/src/unistd/symlinkat_test.cpp
@@ -14,6 +14,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcSymlinkatTest, CreateAndUnlink) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_DIR = "testdata";
diff --git a/libc/test/src/unistd/syscall_test.cpp b/libc/test/src/unistd/syscall_test.cpp
index 211b27c3188c4d..6a5ca47f8d494a 100644
--- a/libc/test/src/unistd/syscall_test.cpp
+++ b/libc/test/src/unistd/syscall_test.cpp
@@ -12,6 +12,7 @@
#include "test/UnitTest/Test.h"
#include <fcntl.h>
+#include <sys/stat.h> // For S_* flags.
#include <sys/syscall.h> // For syscall numbers.
#include <unistd.h>
diff --git a/libc/test/src/unistd/truncate_test.cpp b/libc/test/src/unistd/truncate_test.cpp
index 15940321e5ad45..6d8a3b8e53f728 100644
--- a/libc/test/src/unistd/truncate_test.cpp
+++ b/libc/test/src/unistd/truncate_test.cpp
@@ -17,6 +17,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
namespace cpp = LIBC_NAMESPACE::cpp;
TEST(LlvmLibcTruncateTest, CreateAndTruncate) {
diff --git a/libc/test/src/unistd/unlink_test.cpp b/libc/test/src/unistd/unlink_test.cpp
index 8a64f88ee6f26d..77f65b5ecc6a1a 100644
--- a/libc/test/src/unistd/unlink_test.cpp
+++ b/libc/test/src/unistd/unlink_test.cpp
@@ -13,6 +13,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcUnlinkTest, CreateAndUnlink) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/unlink.test";
diff --git a/libc/test/src/unistd/unlinkat_test.cpp b/libc/test/src/unistd/unlinkat_test.cpp
index 5953085bf12b66..22a20bc6ad07bc 100644
--- a/libc/test/src/unistd/unlinkat_test.cpp
+++ b/libc/test/src/unistd/unlinkat_test.cpp
@@ -14,6 +14,8 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
+#include <sys/stat.h>
+
TEST(LlvmLibcUnlinkatTest, CreateAndDeleteTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_DIR = "testdata";
More information about the libc-commits
mailing list