[libc-commits] [libc] [libc][NFC] Use specific EXPECT/ASSERT macros to test errno (PR #79573)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Fri Jan 26 02:35:21 PST 2024
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/79573
None
>From e563717951007b048475b807c6c62ed81b69d7fb Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Fri, 26 Jan 2024 10:34:51 +0000
Subject: [PATCH] [libc][NFC] Use specific EXPECT/ASSERT macros to test errno
---
libc/test/IntegrationTest/test.h | 16 +++
libc/test/UnitTest/LibcTest.h | 9 ++
.../src/pthread/pthread_create_test.cpp | 52 ++++-----
.../src/pthread/pthread_join_test.cpp | 4 +-
.../integration/src/unistd/getcwd_test.cpp | 2 +-
libc/test/src/dirent/dirent_test.cpp | 6 +-
libc/test/src/fcntl/creat_test.cpp | 4 +-
libc/test/src/fcntl/openat_test.cpp | 4 +-
libc/test/src/sched/get_priority_test.cpp | 28 ++---
.../src/sched/param_and_scheduler_test.cpp | 34 +++---
.../src/sched/sched_rr_get_interval_test.cpp | 14 +--
libc/test/src/sched/yield_test.cpp | 2 +-
libc/test/src/stdio/fgets_test.cpp | 6 +-
libc/test/src/stdio/fileop_test.cpp | 6 +-
libc/test/src/stdio/fopencookie_test.cpp | 6 +-
libc/test/src/stdio/remove_test.cpp | 2 +-
libc/test/src/stdio/setvbuf_test.cpp | 2 +-
libc/test/src/stdio/unlocked_fileop_test.cpp | 4 +-
libc/test/src/stdlib/StrtolTest.h | 106 +++++++++---------
libc/test/src/stdlib/strtof_test.cpp | 2 +-
libc/test/src/stdlib/strtold_test.cpp | 2 +-
libc/test/src/string/strdup_test.cpp | 6 +-
libc/test/src/sys/prctl/linux/prctl_test.cpp | 2 +-
.../sys/resource/getrlimit_setrlimit_test.cpp | 12 +-
libc/test/src/sys/sendfile/sendfile_test.cpp | 8 +-
libc/test/src/sys/socket/linux/bind_test.cpp | 4 +-
.../test/src/sys/socket/linux/socket_test.cpp | 2 +-
libc/test/src/sys/stat/chmod_test.cpp | 8 +-
libc/test/src/sys/stat/fchmod_test.cpp | 10 +-
libc/test/src/sys/stat/fchmodat_test.cpp | 8 +-
libc/test/src/sys/stat/fstat_test.cpp | 2 +-
libc/test/src/sys/stat/lstat_test.cpp | 2 +-
libc/test/src/sys/stat/stat_test.cpp | 2 +-
libc/test/src/termios/termios_test.cpp | 4 +-
libc/test/src/time/gmtime_test.cpp | 4 +-
libc/test/src/time/nanosleep_test.cpp | 2 +-
libc/test/src/unistd/access_test.cpp | 16 +--
libc/test/src/unistd/chdir_test.cpp | 4 +-
libc/test/src/unistd/dup2_test.cpp | 8 +-
libc/test/src/unistd/dup3_test.cpp | 8 +-
libc/test/src/unistd/dup_test.cpp | 8 +-
libc/test/src/unistd/fchdir_test.cpp | 8 +-
libc/test/src/unistd/ftruncate_test.cpp | 8 +-
libc/test/src/unistd/isatty_test.cpp | 4 +-
libc/test/src/unistd/link_test.cpp | 4 +-
libc/test/src/unistd/linkat_test.cpp | 4 +-
libc/test/src/unistd/lseek_test.cpp | 4 +-
libc/test/src/unistd/pread_pwrite_test.cpp | 6 +-
libc/test/src/unistd/read_write_test.cpp | 4 +-
libc/test/src/unistd/readlink_test.cpp | 2 +-
libc/test/src/unistd/readlinkat_test.cpp | 2 +-
libc/test/src/unistd/symlink_test.cpp | 4 +-
libc/test/src/unistd/symlinkat_test.cpp | 4 +-
libc/test/src/unistd/syscall_test.cpp | 32 +++---
libc/test/src/unistd/truncate_test.cpp | 6 +-
libc/test/src/unistd/unlink_test.cpp | 2 +-
libc/test/src/unistd/unlinkat_test.cpp | 6 +-
57 files changed, 278 insertions(+), 253 deletions(-)
diff --git a/libc/test/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index 1e5ad1cfef0d7b5..f1c2e8f9ec72e3c 100644
--- a/libc/test/IntegrationTest/test.h
+++ b/libc/test/IntegrationTest/test.h
@@ -45,10 +45,17 @@
LIBC_NAMESPACE::quick_exit(127); \
}
+////////////////////////////////////////////////////////////////////////////////
+// Boolean checks are handled as comparison to the true / false values.
+
#define EXPECT_TRUE(val) __CHECK_TRUE(__FILE__, __LINE__, val, false)
#define ASSERT_TRUE(val) __CHECK_TRUE(__FILE__, __LINE__, val, true)
#define EXPECT_FALSE(val) __CHECK_FALSE(__FILE__, __LINE__, val, false)
#define ASSERT_FALSE(val) __CHECK_FALSE(__FILE__, __LINE__, val, true)
+
+////////////////////////////////////////////////////////////////////////////////
+// Binary equality / inequality.
+
#define EXPECT_EQ(val1, val2) \
__CHECK_EQ(__FILE__, __LINE__, (val1), (val2), false)
#define ASSERT_EQ(val1, val2) \
@@ -58,6 +65,15 @@
#define ASSERT_NE(val1, val2) \
__CHECK_NE(__FILE__, __LINE__, (val1), (val2), true)
+////////////////////////////////////////////////////////////////////////////////
+// Errno checks.
+
+#define EXPECT_ERRNO_EQ(VAL) EXPECT_EQ(VAL, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
+
+#define EXPECT_ERRNO() EXPECT_NE(static_cast<int>(libc_errno), 0)
+#define ASSERT_ERRNO() ASSERT_NE(static_cast<int>(libc_errno), 0)
+
// Integration tests are compiled with -ffreestanding which stops treating
// the main function as a non-overloadable special function. Hence, we use a
// convenience macro which declares it 'extern "C"'.
diff --git a/libc/test/UnitTest/LibcTest.h b/libc/test/UnitTest/LibcTest.h
index 68fd5f28f3e0bd7..cfea23a679755ea 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -443,6 +443,15 @@ CString libc_make_test_file_path_func(const char *file_name);
#define EXPECT_STRNE(LHS, RHS) LIBC_TEST_STR_(testStrNe, LHS, RHS, )
#define ASSERT_STRNE(LHS, RHS) LIBC_TEST_STR_(testStrNe, LHS, RHS, return)
+////////////////////////////////////////////////////////////////////////////////
+// Errno checks.
+
+#define EXPECT_ERRNO_EQ(VAL) EXPECT_EQ(VAL, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
+
+#define EXPECT_ERRNO() EXPECT_NE(static_cast<int>(libc_errno), 0)
+#define ASSERT_ERRNO() ASSERT_NE(static_cast<int>(libc_errno), 0)
+
////////////////////////////////////////////////////////////////////////////////
// Subprocess checks.
diff --git a/libc/test/integration/src/pthread/pthread_create_test.cpp b/libc/test/integration/src/pthread/pthread_create_test.cpp
index 6a9b44cc1422cc5..bce380fbec2fc81 100644
--- a/libc/test/integration/src/pthread/pthread_create_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_create_test.cpp
@@ -47,7 +47,7 @@ static void *successThread(void *Arg) {
pthread_t th = LIBC_NAMESPACE::pthread_self();
auto *thread = reinterpret_cast<LIBC_NAMESPACE::Thread *>(&th);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_TRUE(thread);
ASSERT_TRUE(thread->attrib);
@@ -62,22 +62,22 @@ static void *successThread(void *Arg) {
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_getstack(expec_attrs, &expec_stack,
&expec_stacksize),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(
LIBC_NAMESPACE::pthread_attr_getstacksize(expec_attrs, &expec_stacksize2),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(
LIBC_NAMESPACE::pthread_attr_getguardsize(expec_attrs, &expec_guardsize),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(
LIBC_NAMESPACE::pthread_attr_getdetachstate(expec_attrs, &expec_detached),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(expec_stacksize, expec_stacksize2);
@@ -125,7 +125,7 @@ static void *successThread(void *Arg) {
// permissions. Maybe we can read from /proc/{self}/map?
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_destroy(expec_attrs), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// Arg is malloced, so free.
delete th_arg;
@@ -140,13 +140,13 @@ static void run_success_config(int detachstate, size_t guardsize,
pthread_attr_t *attr = &(th_arg->attrs);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setdetachstate(attr, detachstate), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setguardsize(attr, guardsize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
void *Stack = nullptr;
if (customstack) {
@@ -154,20 +154,20 @@ static void run_success_config(int detachstate, size_t guardsize,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
ASSERT_NE(Stack, MAP_FAILED);
ASSERT_NE(Stack, static_cast<void *>(nullptr));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setstack(attr, Stack, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else {
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setstacksize(attr, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
void *expec_ret = nullptr;
if (detachstate == PTHREAD_CREATE_JOINABLE) {
ASSERT_EQ(LIBC_NAMESPACE::getrandom(&expec_ret, sizeof(expec_ret), 0),
static_cast<ssize_t>(sizeof(expec_ret)));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
th_arg->ret = expec_ret;
@@ -178,17 +178,17 @@ static void run_success_config(int detachstate, size_t guardsize,
ASSERT_EQ(LIBC_NAMESPACE::pthread_create(&tid, attr, successThread,
reinterpret_cast<void *>(th_arg)),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
if (detachstate == PTHREAD_CREATE_JOINABLE) {
void *th_ret;
ASSERT_EQ(LIBC_NAMESPACE::pthread_join(tid, &th_ret), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(th_ret, expec_ret);
if (customstack) {
ASSERT_EQ(LIBC_NAMESPACE::munmap(Stack, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
} else {
ASSERT_FALSE(customstack);
@@ -260,23 +260,23 @@ static void create_and_check_failure_thread(pthread_attr_t *attr) {
// was just really larger we failed mmap.
ASSERT_TRUE(result == EINVAL || result == EAGAIN);
// pthread_create should NOT set errno on error
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_destroy(attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
static void run_failure_config(size_t guardsize, size_t stacksize) {
pthread_attr_t attr;
guardsize &= -EXEC_PAGESIZE;
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(&attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setguardsize(&attr, guardsize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setstacksize(&attr, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
create_and_check_failure_thread(&attr);
}
@@ -301,32 +301,32 @@ static void run_failure_tests() {
// Stacksize too small.
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(&attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
attr.__stacksize = PTHREAD_STACK_MIN - 16;
create_and_check_failure_thread(&attr);
// Stack misaligned.
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(&attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
attr.__stack = reinterpret_cast<void *>(1);
create_and_check_failure_thread(&attr);
// Stack + stacksize misaligned.
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(&attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
attr.__stacksize = PTHREAD_STACK_MIN + 1;
attr.__stack = reinterpret_cast<void *>(16);
create_and_check_failure_thread(&attr);
// Guardsize misaligned.
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(&attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
attr.__guardsize = EXEC_PAGESIZE / 2;
create_and_check_failure_thread(&attr);
// Detachstate is unknown.
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_init(&attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
attr.__detachstate = -1;
create_and_check_failure_thread(&attr);
}
diff --git a/libc/test/integration/src/pthread/pthread_join_test.cpp b/libc/test/integration/src/pthread/pthread_join_test.cpp
index f4126357a0579dc..b441917a4cac29f 100644
--- a/libc/test/integration/src/pthread/pthread_join_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_join_test.cpp
@@ -19,9 +19,9 @@ static void nullJoinTest() {
pthread_t Tid;
ASSERT_EQ(LIBC_NAMESPACE::pthread_create(&Tid, nullptr, simpleFunc, nullptr),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::pthread_join(Tid, nullptr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
TEST_MAIN() {
diff --git a/libc/test/integration/src/unistd/getcwd_test.cpp b/libc/test/integration/src/unistd/getcwd_test.cpp
index 3d8f5821a69efcb..87687d09b9e7aff 100644
--- a/libc/test/integration/src/unistd/getcwd_test.cpp
+++ b/libc/test/integration/src/unistd/getcwd_test.cpp
@@ -30,7 +30,7 @@ TEST_MAIN(int argc, char **argv, char **envp) {
// Bad size
cwd = LIBC_NAMESPACE::getcwd(buffer, 0);
ASSERT_TRUE(cwd == nullptr);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
// Insufficient size
diff --git a/libc/test/src/dirent/dirent_test.cpp b/libc/test/src/dirent/dirent_test.cpp
index ff1a30a2639fe25..63778ddc01483d9 100644
--- a/libc/test/src/dirent/dirent_test.cpp
+++ b/libc/test/src/dirent/dirent_test.cpp
@@ -44,7 +44,7 @@ TEST(LlvmLibcDirentTest, SimpleOpenAndRead) {
}
// Verify that we don't break out of the above loop in error.
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_TRUE(file1 != nullptr);
ASSERT_TRUE(file2 != nullptr);
@@ -58,7 +58,7 @@ TEST(LlvmLibcDirentTest, OpenNonExistentDir) {
libc_errno = 0;
::DIR *dir = LIBC_NAMESPACE::opendir("___xyz123__.non_existent__");
ASSERT_TRUE(dir == nullptr);
- ASSERT_EQ(libc_errno, ENOENT);
+ ASSERT_ERRNO_EQ(ENOENT);
libc_errno = 0;
}
@@ -66,6 +66,6 @@ TEST(LlvmLibcDirentTest, OpenFile) {
libc_errno = 0;
::DIR *dir = LIBC_NAMESPACE::opendir("testdata/file1.txt");
ASSERT_TRUE(dir == nullptr);
- ASSERT_EQ(libc_errno, ENOTDIR);
+ ASSERT_ERRNO_EQ(ENOTDIR);
libc_errno = 0;
}
diff --git a/libc/test/src/fcntl/creat_test.cpp b/libc/test/src/fcntl/creat_test.cpp
index ef30d8862c45f26..9f5a1394dbfcd14 100644
--- a/libc/test/src/fcntl/creat_test.cpp
+++ b/libc/test/src/fcntl/creat_test.cpp
@@ -19,12 +19,12 @@ TEST(LlvmLibcCreatTest, CreatAndOpen) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/creat.test";
int fd = LIBC_NAMESPACE::creat(TEST_FILE, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
diff --git a/libc/test/src/fcntl/openat_test.cpp b/libc/test/src/fcntl/openat_test.cpp
index b95f3f212720116..a6302973b8e2f35 100644
--- a/libc/test/src/fcntl/openat_test.cpp
+++ b/libc/test/src/fcntl/openat_test.cpp
@@ -21,13 +21,13 @@ TEST(LlvmLibcUniStd, OpenAndReadTest) {
constexpr const char *TEST_DIR = "testdata";
constexpr const char *TEST_FILE = "openat.test";
int dir_fd = LIBC_NAMESPACE::open(TEST_DIR, O_DIRECTORY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(dir_fd, 0);
constexpr const char TEST_MSG[] = "openat test";
constexpr int TEST_MSG_SIZE = sizeof(TEST_MSG) - 1;
int read_fd = LIBC_NAMESPACE::openat(dir_fd, TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(read_fd, 0);
char read_buf[TEST_MSG_SIZE];
ASSERT_THAT(LIBC_NAMESPACE::read(read_fd, read_buf, TEST_MSG_SIZE),
diff --git a/libc/test/src/sched/get_priority_test.cpp b/libc/test/src/sched/get_priority_test.cpp
index 3a79a67802cf3e9..6d62391ee2cb1b5 100644
--- a/libc/test/src/sched/get_priority_test.cpp
+++ b/libc/test/src/sched/get_priority_test.cpp
@@ -20,40 +20,40 @@ TEST(LlvmLibcSchedGetPriorityTest, HandleBadPolicyTest) {
int policy = -1;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_EQ(max_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_EQ(min_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
}
{
int policy = 30;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_EQ(max_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_EQ(min_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
}
{
int policy = 80;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_EQ(max_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_EQ(min_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
}
{
int policy = 110;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_EQ(max_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_EQ(min_priority, -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
}
}
@@ -68,10 +68,10 @@ TEST(LlvmLibcSchedGetPriorityTest, SmokeTest) {
int policy = SCHED_OTHER;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_GE(max_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_LE(max_priority, 99);
ASSERT_GE(min_priority, 0);
@@ -82,10 +82,10 @@ TEST(LlvmLibcSchedGetPriorityTest, SmokeTest) {
int policy = SCHED_FIFO;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_GE(max_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_LE(max_priority, 99);
ASSERT_GE(min_priority, 0);
@@ -96,10 +96,10 @@ TEST(LlvmLibcSchedGetPriorityTest, SmokeTest) {
int policy = SCHED_RR;
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_GE(max_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_LE(max_priority, 99);
ASSERT_GE(min_priority, 0);
diff --git a/libc/test/src/sched/param_and_scheduler_test.cpp b/libc/test/src/sched/param_and_scheduler_test.cpp
index 8c6485f07897125..196db53eb33be3b 100644
--- a/libc/test/src/sched/param_and_scheduler_test.cpp
+++ b/libc/test/src/sched/param_and_scheduler_test.cpp
@@ -41,35 +41,35 @@ class SchedTest : public LIBC_NAMESPACE::testing::Test {
int init_policy = LIBC_NAMESPACE::sched_getscheduler(0);
ASSERT_GE(init_policy, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_GE(max_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
struct sched_param param = {min_priority};
// Negative pid
ASSERT_EQ(LIBC_NAMESPACE::sched_setscheduler(-1, policy, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::sched_getscheduler(-1), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
// Invalid Policy
ASSERT_EQ(LIBC_NAMESPACE::sched_setscheduler(0, policy | 128, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
// Out of bounds priority
param.sched_priority = min_priority - 1;
ASSERT_EQ(LIBC_NAMESPACE::sched_setscheduler(0, policy, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
param.sched_priority = max_priority + 1;
@@ -90,33 +90,33 @@ class SchedTest : public LIBC_NAMESPACE::testing::Test {
ASSERT_EQ(LIBC_NAMESPACE::sched_getscheduler(0),
can_set ? policy : init_policy);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// Out of bounds priority
param.sched_priority = -1;
ASSERT_EQ(LIBC_NAMESPACE::sched_setparam(0, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
param.sched_priority = max_priority + 1;
ASSERT_EQ(LIBC_NAMESPACE::sched_setparam(0, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
for (int priority = min_priority; priority <= max_priority; ++priority) {
ASSERT_EQ(LIBC_NAMESPACE::sched_getparam(0, ¶m), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int init_priority = param.sched_priority;
param.sched_priority = priority;
// Negative pid
ASSERT_EQ(LIBC_NAMESPACE::sched_setparam(-1, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::sched_getparam(-1, ¶m), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
// Success / missing permissions
@@ -126,14 +126,14 @@ class SchedTest : public LIBC_NAMESPACE::testing::Test {
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::sched_getparam(0, ¶m), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(param.sched_priority, can_set ? priority : init_priority);
}
// Null test
ASSERT_EQ(LIBC_NAMESPACE::sched_setscheduler(0, policy, nullptr), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
}
};
@@ -155,10 +155,10 @@ TEST(LlvmLibcSchedParamAndSchedulerTest, NullParamTest) {
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::sched_setparam(0, nullptr), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::sched_getparam(0, nullptr), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
}
diff --git a/libc/test/src/sched/sched_rr_get_interval_test.cpp b/libc/test/src/sched/sched_rr_get_interval_test.cpp
index 100100079504165..85a9dbd29bfb6fa 100644
--- a/libc/test/src/sched/sched_rr_get_interval_test.cpp
+++ b/libc/test/src/sched/sched_rr_get_interval_test.cpp
@@ -21,11 +21,11 @@ TEST(LlvmLibcSchedRRGetIntervalTest, SmokeTest) {
auto SetSched = [&](int policy) {
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
struct sched_param param;
param.sched_priority = min_priority;
ASSERT_EQ(LIBC_NAMESPACE::sched_setscheduler(0, policy, ¶m), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
};
auto TimespecToNs = [](struct timespec t) {
@@ -41,13 +41,13 @@ TEST(LlvmLibcSchedRRGetIntervalTest, SmokeTest) {
int cur_policy = LIBC_NAMESPACE::sched_getscheduler(0);
ASSERT_GE(cur_policy, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// We can actually run meaningful tests.
if (cur_policy == SCHED_RR) {
// Success
ASSERT_EQ(LIBC_NAMESPACE::sched_rr_get_interval(0, &ts), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// Check that numbers make sense (liberal bound of 10ns - 30sec)
constexpr uint64_t tenNs = 10UL;
@@ -57,19 +57,19 @@ TEST(LlvmLibcSchedRRGetIntervalTest, SmokeTest) {
// Null timespec
ASSERT_EQ(LIBC_NAMESPACE::sched_rr_get_interval(0, nullptr), -1);
- ASSERT_EQ(libc_errno, EFAULT);
+ ASSERT_ERRNO_EQ(EFAULT);
libc_errno = 0;
// Negative pid
ASSERT_EQ(LIBC_NAMESPACE::sched_rr_get_interval(-1, &ts), -1);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
}
// Negative tests don't have SCHED_RR set
SetSched(SCHED_OTHER);
ASSERT_EQ(LIBC_NAMESPACE::sched_rr_get_interval(0, &ts), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
libc_errno = 0;
// TODO: Missing unkown pid -> ESRCH. This is read only so safe to try a few
diff --git a/libc/test/src/sched/yield_test.cpp b/libc/test/src/sched/yield_test.cpp
index 45b7a7d2d81e47a..6f42f4878548d22 100644
--- a/libc/test/src/sched/yield_test.cpp
+++ b/libc/test/src/sched/yield_test.cpp
@@ -15,5 +15,5 @@ TEST(LlvmLibcSchedYieldTest, SmokeTest) {
// sched_yield() always succeeds, just do a basic test that errno/ret are
// properly 0.
ASSERT_EQ(LIBC_NAMESPACE::sched_yield(), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
diff --git a/libc/test/src/stdio/fgets_test.cpp b/libc/test/src/stdio/fgets_test.cpp
index 9f9841c901f4edc..50936ab112a88d2 100644
--- a/libc/test/src/stdio/fgets_test.cpp
+++ b/libc/test/src/stdio/fgets_test.cpp
@@ -48,7 +48,7 @@ TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
output = LIBC_NAMESPACE::fgets(buff, 1, file);
ASSERT_TRUE(output == buff);
ASSERT_EQ(buff[0], '\0');
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// If we request less than 1 byte, it should do nothing and return nullptr.
// This is also implementation defined.
@@ -76,13 +76,13 @@ TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
// fails to read anything.
ASSERT_NE(LIBC_NAMESPACE::feof(file), 0);
ASSERT_EQ(LIBC_NAMESPACE::ferror(file), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// Reading more should be an EOF, but not an error.
output = LIBC_NAMESPACE::fgets(buff, 8, file);
ASSERT_TRUE(output == nullptr);
ASSERT_NE(LIBC_NAMESPACE::feof(file), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));
}
diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index d5478e58eecbf93..f90e5f2a84ad3ee 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -121,16 +121,16 @@ TEST(LlvmLibcFILETest, SimpleFileOperations) {
// libc_errno = 0;
// ASSERT_NE(LIBC_NAMESPACE::fseek(file, 0, SEEK_SET), 0);
- // EXPECT_NE(libc_errno, 0);
+ // EXPECT_ERRNO();
// libc_errno = 0;
// ASSERT_NE(LIBC_NAMESPACE::fclose(file), 0);
- // EXPECT_NE(libc_errno, 0);
+ // EXPECT_ERRNO();
// libc_errno = 0;
// ASSERT_EQ(LIBC_NAMESPACE::fopen("INVALID FILE NAME", "r"),
// static_cast<FILE *>(nullptr));
- // EXPECT_NE(libc_errno, 0);
+ // EXPECT_ERRNO();
}
TEST(LlvmLibcFILETest, FFlush) {
diff --git a/libc/test/src/stdio/fopencookie_test.cpp b/libc/test/src/stdio/fopencookie_test.cpp
index 6f3c2910cfd8235..0e6c50cbf496a55 100644
--- a/libc/test/src/stdio/fopencookie_test.cpp
+++ b/libc/test/src/stdio/fopencookie_test.cpp
@@ -114,7 +114,7 @@ TEST(LlvmLibcFOpenCookie, ReadOnlyCookieTest) {
// Should be an error to write.
ASSERT_EQ(size_t(0), LIBC_NAMESPACE::fwrite(CONTENT, 1, sizeof(CONTENT), f));
ASSERT_NE(LIBC_NAMESPACE::ferror(f), 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
LIBC_NAMESPACE::clearerr(f);
@@ -148,7 +148,7 @@ TEST(LlvmLibcFOpenCookie, WriteOnlyCookieTest) {
ASSERT_EQ(size_t(0),
LIBC_NAMESPACE::fread(read_data, 1, sizeof(WRITE_DATA), f));
ASSERT_NE(LIBC_NAMESPACE::ferror(f), 0);
- ASSERT_EQ(libc_errno, EBADF);
+ ASSERT_ERRNO_EQ(EBADF);
libc_errno = 0;
LIBC_NAMESPACE::clearerr(f);
@@ -177,7 +177,7 @@ TEST(LlvmLibcFOpenCookie, AppendOnlyCookieTest) {
// This is not a readable file.
ASSERT_EQ(LIBC_NAMESPACE::fread(read_data, 1, READ_SIZE, f), size_t(0));
ASSERT_NE(LIBC_NAMESPACE::ferror(f), 0);
- EXPECT_NE(libc_errno, 0);
+ EXPECT_ERRNO();
libc_errno = 0;
LIBC_NAMESPACE::clearerr(f);
diff --git a/libc/test/src/stdio/remove_test.cpp b/libc/test/src/stdio/remove_test.cpp
index ce4a1352d1cc1a5..e4e2ed61715ff01 100644
--- a/libc/test/src/stdio/remove_test.cpp
+++ b/libc/test/src/stdio/remove_test.cpp
@@ -25,7 +25,7 @@ TEST(LlvmLibcRemoveTest, CreateAndRemoveFile) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/remove.test.file";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
diff --git a/libc/test/src/stdio/setvbuf_test.cpp b/libc/test/src/stdio/setvbuf_test.cpp
index 2faa01a15ec108f..725694bb8ae1c13 100644
--- a/libc/test/src/stdio/setvbuf_test.cpp
+++ b/libc/test/src/stdio/setvbuf_test.cpp
@@ -100,7 +100,7 @@ TEST(LlvmLibcSetbufTest, InvalidBufferMode) {
char buf[BUFSIZ];
ASSERT_NE(LIBC_NAMESPACE::setvbuf(f, buf, _IOFBF + _IOLBF + _IONBF, BUFSIZ),
0);
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
libc_errno = 0;
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(f));
diff --git a/libc/test/src/stdio/unlocked_fileop_test.cpp b/libc/test/src/stdio/unlocked_fileop_test.cpp
index cf51e8caa6a550d..5335b1d53bc7f56 100644
--- a/libc/test/src/stdio/unlocked_fileop_test.cpp
+++ b/libc/test/src/stdio/unlocked_fileop_test.cpp
@@ -36,7 +36,7 @@ TEST(LlvmLibcFILETest, UnlockedReadAndWrite) {
ASSERT_EQ(size_t(0),
LIBC_NAMESPACE::fread_unlocked(data, 1, sizeof(READ_SIZE), f));
ASSERT_NE(LIBC_NAMESPACE::ferror_unlocked(f), 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
LIBC_NAMESPACE::clearerr_unlocked(f);
@@ -57,7 +57,7 @@ TEST(LlvmLibcFILETest, UnlockedReadAndWrite) {
ASSERT_EQ(size_t(0),
LIBC_NAMESPACE::fwrite_unlocked(CONTENT, 1, sizeof(CONTENT), f));
ASSERT_NE(LIBC_NAMESPACE::ferror_unlocked(f), 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
LIBC_NAMESPACE::clearerr_unlocked(f);
diff --git a/libc/test/src/stdlib/StrtolTest.h b/libc/test/src/stdlib/StrtolTest.h
index 6aee049aa066a04..ab304ca08e06ba4 100644
--- a/libc/test/src/stdlib/StrtolTest.h
+++ b/libc/test/src/stdlib/StrtolTest.h
@@ -37,7 +37,7 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *ten = "10";
libc_errno = 0;
ASSERT_EQ(func(ten, nullptr, -1), ReturnT(0));
- ASSERT_EQ(libc_errno, EINVAL);
+ ASSERT_ERRNO_EQ(EINVAL);
}
void CleanBaseTenDecode(FunctionT func) {
@@ -47,23 +47,23 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *ten = "10";
libc_errno = 0;
ASSERT_EQ(func(ten, &str_end, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - ten, ptrdiff_t(2));
libc_errno = 0;
ASSERT_EQ(func(ten, nullptr, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
const char *hundred = "100";
libc_errno = 0;
ASSERT_EQ(func(hundred, &str_end, 10), ReturnT(100));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - hundred, ptrdiff_t(3));
const char *big_number = "1234567890";
libc_errno = 0;
ASSERT_EQ(func(big_number, &str_end, 10), ReturnT(1234567890));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - big_number, ptrdiff_t(10));
// This number is larger than 2^32, meaning that if long is only 32 bits
@@ -72,24 +72,24 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
libc_errno = 0;
if constexpr (sizeof(ReturnT) < 8) {
ASSERT_EQ(func(bigger_number, &str_end, 10), T_MAX);
- ASSERT_EQ(libc_errno, ERANGE);
+ ASSERT_ERRNO_EQ(ERANGE);
} else {
ASSERT_EQ(func(bigger_number, &str_end, 10), ReturnT(12345678900));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
EXPECT_EQ(str_end - bigger_number, ptrdiff_t(11));
const char *too_big_number = "123456789012345678901";
libc_errno = 0;
ASSERT_EQ(func(too_big_number, &str_end, 10), T_MAX);
- ASSERT_EQ(libc_errno, ERANGE);
+ ASSERT_ERRNO_EQ(ERANGE);
EXPECT_EQ(str_end - too_big_number, ptrdiff_t(21));
const char *long_number_range_test =
"10000000000000000000000000000000000000000000000000";
libc_errno = 0;
ASSERT_EQ(func(long_number_range_test, &str_end, 10), T_MAX);
- ASSERT_EQ(libc_errno, ERANGE);
+ ASSERT_ERRNO_EQ(ERANGE);
EXPECT_EQ(str_end - long_number_range_test, ptrdiff_t(50));
// For most negative numbers, the unsigned functions treat it the same as
@@ -97,13 +97,13 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *negative = "-100";
libc_errno = 0;
ASSERT_EQ(func(negative, &str_end, 10), ReturnT(-100));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - negative, ptrdiff_t(4));
const char *big_negative_number = "-1234567890";
libc_errno = 0;
ASSERT_EQ(func(big_negative_number, &str_end, 10), ReturnT(-1234567890));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - big_negative_number, ptrdiff_t(11));
const char *too_big_negative_number = "-123456789012345678901";
@@ -117,7 +117,7 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
// Note that 0 is not on that list.
ASSERT_EQ(func(too_big_negative_number, &str_end, 10),
(is_signed_v<ReturnT> ? T_MIN : T_MAX));
- ASSERT_EQ(libc_errno, ERANGE);
+ ASSERT_ERRNO_EQ(ERANGE);
EXPECT_EQ(str_end - too_big_negative_number, ptrdiff_t(22));
}
@@ -127,73 +127,73 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *spaces_before = " 10";
libc_errno = 0;
ASSERT_EQ(func(spaces_before, &str_end, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - spaces_before, ptrdiff_t(7));
const char *spaces_after = "10 ";
libc_errno = 0;
ASSERT_EQ(func(spaces_after, &str_end, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - spaces_after, ptrdiff_t(2));
const char *word_before = "word10";
libc_errno = 0;
ASSERT_EQ(func(word_before, &str_end, 10), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - word_before, ptrdiff_t(0));
const char *word_after = "10word";
libc_errno = 0;
ASSERT_EQ(func(word_after, &str_end, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - word_after, ptrdiff_t(2));
const char *two_numbers = "10 999";
libc_errno = 0;
ASSERT_EQ(func(two_numbers, &str_end, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - two_numbers, ptrdiff_t(2));
const char *two_signs = "--10 999";
libc_errno = 0;
ASSERT_EQ(func(two_signs, &str_end, 10), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - two_signs, ptrdiff_t(0));
const char *sign_before = "+2=4";
libc_errno = 0;
ASSERT_EQ(func(sign_before, &str_end, 10), ReturnT(2));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - sign_before, ptrdiff_t(2));
const char *sign_after = "2+2=4";
libc_errno = 0;
ASSERT_EQ(func(sign_after, &str_end, 10), ReturnT(2));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - sign_after, ptrdiff_t(1));
const char *tab_before = "\t10";
libc_errno = 0;
ASSERT_EQ(func(tab_before, &str_end, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - tab_before, ptrdiff_t(3));
const char *all_together = "\t -12345and+67890";
libc_errno = 0;
ASSERT_EQ(func(all_together, &str_end, 10), ReturnT(-12345));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - all_together, ptrdiff_t(9));
const char *just_spaces = " ";
libc_errno = 0;
ASSERT_EQ(func(just_spaces, &str_end, 10), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_spaces, ptrdiff_t(0));
const char *just_space_and_sign = " +";
libc_errno = 0;
ASSERT_EQ(func(just_space_and_sign, &str_end, 10), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_space_and_sign, ptrdiff_t(0));
}
@@ -212,11 +212,11 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
}
}
@@ -231,16 +231,16 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
ASSERT_EQ(
func(small_string, nullptr, base),
static_cast<ReturnT>(second_digit + (first_digit * base)));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else if (first_digit < base) {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
}
}
@@ -261,13 +261,13 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
static_cast<ReturnT>(third_digit +
(second_digit * base) +
(first_digit * base * base)));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else if (first_digit < base && second_digit < base) {
libc_errno = 0;
ASSERT_EQ(
func(small_string, nullptr, base),
static_cast<ReturnT>(second_digit + (first_digit * base)));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else if (first_digit < base) {
// if the base is 16 there is a special case for the prefix 0X.
// The number is treated as a one digit hexadecimal.
@@ -276,22 +276,22 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(third_digit));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
}
}
@@ -305,19 +305,19 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *no_prefix = "123abc";
libc_errno = 0;
ASSERT_EQ(func(no_prefix, &str_end, 16), ReturnT(0x123abc));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - no_prefix, ptrdiff_t(6));
const char *yes_prefix = "0x456def";
libc_errno = 0;
ASSERT_EQ(func(yes_prefix, &str_end, 16), ReturnT(0x456def));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - yes_prefix, ptrdiff_t(8));
const char *letter_after_prefix = "0xabc123";
libc_errno = 0;
ASSERT_EQ(func(letter_after_prefix, &str_end, 16), ReturnT(0xabc123));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - letter_after_prefix, ptrdiff_t(8));
// These tests check what happens when the number passed is exactly the max
@@ -350,14 +350,14 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *max_31_bit_value = "0x7FFFFFFF";
libc_errno = 0;
ASSERT_EQ(func(max_31_bit_value, &str_end, 0), ReturnT(0x7FFFFFFF));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - max_31_bit_value, ptrdiff_t(10));
const char *negative_max_31_bit_value = "-0x7FFFFFFF";
libc_errno = 0;
ASSERT_EQ(func(negative_max_31_bit_value, &str_end, 0),
-ReturnT(0x7FFFFFFF));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - negative_max_31_bit_value, ptrdiff_t(11));
// Max size for unsigned 64 bit numbers
@@ -391,7 +391,7 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
libc_errno = 0;
ASSERT_EQ(func(max_63_bit_value, &str_end, 0),
(sizeof(ReturnT) < 8 ? T_MAX : ReturnT(0x7FFFFFFFFFFFFFFF)));
- ASSERT_EQ(libc_errno, sizeof(ReturnT) < 8 ? ERANGE : 0);
+ ASSERT_ERRNO_EQ(sizeof(ReturnT) < 8 ? ERANGE : 0);
EXPECT_EQ(str_end - max_63_bit_value, ptrdiff_t(18));
const char *negative_max_63_bit_value = "-0x7FFFFFFFFFFFFFFF";
@@ -399,7 +399,7 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
ASSERT_EQ(func(negative_max_63_bit_value, &str_end, 0),
(sizeof(ReturnT) >= 8 ? -ReturnT(0x7FFFFFFFFFFFFFFF)
: (is_signed_v<ReturnT> ? T_MIN : T_MAX)));
- ASSERT_EQ(libc_errno, sizeof(ReturnT) < 8 ? ERANGE : 0);
+ ASSERT_ERRNO_EQ(sizeof(ReturnT) < 8 ? ERANGE : 0);
EXPECT_EQ(str_end - negative_max_63_bit_value, ptrdiff_t(19));
}
@@ -409,23 +409,23 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *just_prefix = "0x";
libc_errno = 0;
ASSERT_EQ(func(just_prefix, &str_end, 16), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_prefix, ptrdiff_t(1));
libc_errno = 0;
ASSERT_EQ(func(just_prefix, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_prefix, ptrdiff_t(1));
const char *prefix_with_x_after = "0xx";
libc_errno = 0;
ASSERT_EQ(func(prefix_with_x_after, &str_end, 16), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - prefix_with_x_after, ptrdiff_t(1));
libc_errno = 0;
ASSERT_EQ(func(prefix_with_x_after, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - prefix_with_x_after, ptrdiff_t(1));
}
@@ -435,43 +435,43 @@ struct StrtoTest : public LIBC_NAMESPACE::testing::Test {
const char *base_ten = "12345";
libc_errno = 0;
ASSERT_EQ(func(base_ten, &str_end, 0), ReturnT(12345));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - base_ten, ptrdiff_t(5));
const char *base_sixteen_no_prefix = "123abc";
libc_errno = 0;
ASSERT_EQ(func(base_sixteen_no_prefix, &str_end, 0), ReturnT(123));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - base_sixteen_no_prefix, ptrdiff_t(3));
const char *base_sixteen_with_prefix = "0x456def";
libc_errno = 0;
ASSERT_EQ(func(base_sixteen_with_prefix, &str_end, 0), ReturnT(0x456def));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - base_sixteen_with_prefix, ptrdiff_t(8));
const char *base_eight_with_prefix = "012345";
libc_errno = 0;
ASSERT_EQ(func(base_eight_with_prefix, &str_end, 0), ReturnT(012345));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - base_eight_with_prefix, ptrdiff_t(6));
const char *just_zero = "0";
libc_errno = 0;
ASSERT_EQ(func(just_zero, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_zero, ptrdiff_t(1));
const char *just_zero_x = "0x";
libc_errno = 0;
ASSERT_EQ(func(just_zero_x, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_zero_x, ptrdiff_t(1));
const char *just_zero_eight = "08";
libc_errno = 0;
ASSERT_EQ(func(just_zero_eight, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_EQ(str_end - just_zero_eight, ptrdiff_t(1));
}
};
diff --git a/libc/test/src/stdlib/strtof_test.cpp b/libc/test/src/stdlib/strtof_test.cpp
index f30c588c611b390..f60e1653c85ab94 100644
--- a/libc/test/src/stdlib/strtof_test.cpp
+++ b/libc/test/src/stdlib/strtof_test.cpp
@@ -48,7 +48,7 @@ class LlvmLibcStrToFTest : public LIBC_NAMESPACE::testing::Test,
EXPECT_EQ(str_end - inputString, expectedStrLen);
EXPECT_FP_EQ(result, expected_fp.get_val());
- EXPECT_EQ(libc_errno, expectedErrno);
+ EXPECT_ERRNO_EQ(expectedErrno);
}
};
diff --git a/libc/test/src/stdlib/strtold_test.cpp b/libc/test/src/stdlib/strtold_test.cpp
index b7942ab66460b65..ba4a749a1c0dfdc 100644
--- a/libc/test/src/stdlib/strtold_test.cpp
+++ b/libc/test/src/stdlib/strtold_test.cpp
@@ -90,7 +90,7 @@ class LlvmLibcStrToLDTest : public LIBC_NAMESPACE::testing::Test {
EXPECT_EQ(actual_fp.is_neg(), expected_fp.is_neg());
EXPECT_EQ(actual_fp.get_exponent(), expected_fp.get_exponent());
EXPECT_EQ(actual_fp.get_mantissa(), expected_fp.get_mantissa());
- EXPECT_EQ(libc_errno, expected_errno);
+ EXPECT_ERRNO_EQ(expected_errno);
}
};
diff --git a/libc/test/src/string/strdup_test.cpp b/libc/test/src/string/strdup_test.cpp
index b1d4df31603c4b2..8a84997f455e193 100644
--- a/libc/test/src/string/strdup_test.cpp
+++ b/libc/test/src/string/strdup_test.cpp
@@ -17,7 +17,7 @@ TEST(LlvmLibcStrDupTest, EmptyString) {
libc_errno = 0;
char *result = LIBC_NAMESPACE::strdup(empty);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_NE(result, static_cast<char *>(nullptr));
ASSERT_NE(empty, const_cast<const char *>(result));
@@ -30,7 +30,7 @@ TEST(LlvmLibcStrDupTest, AnyString) {
libc_errno = 0;
char *result = LIBC_NAMESPACE::strdup(abc);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_NE(result, static_cast<char *>(nullptr));
ASSERT_NE(abc, const_cast<const char *>(result));
@@ -41,7 +41,7 @@ TEST(LlvmLibcStrDupTest, AnyString) {
TEST(LlvmLibcStrDupTest, NullPtr) {
libc_errno = 0;
char *result = LIBC_NAMESPACE::strdup(nullptr);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(result, static_cast<char *>(nullptr));
}
diff --git a/libc/test/src/sys/prctl/linux/prctl_test.cpp b/libc/test/src/sys/prctl/linux/prctl_test.cpp
index 643c9513b36eb94..404cdd78826a87a 100644
--- a/libc/test/src/sys/prctl/linux/prctl_test.cpp
+++ b/libc/test/src/sys/prctl/linux/prctl_test.cpp
@@ -36,7 +36,7 @@ TEST(LlvmLibcSysPrctlTest, GetTHPDisable) {
// covered in ErrnoSetterMatcher.
libc_errno = 0;
int ret = LIBC_NAMESPACE::prctl(PR_GET_THP_DISABLE, 0, 0, 0, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
// PR_GET_THP_DISABLE return (as the function result) the current
// setting of the "THP disable" flag for the calling thread, which
// is either 1, if the flag is set; or 0, if it is not.
diff --git a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
index 0870deeeb5d8010..7a2173be02ce731 100644
--- a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
+++ b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
@@ -33,10 +33,10 @@ TEST(LlvmLibcResourceLimitsTest, SetNoFileLimit) {
int fd1 = LIBC_NAMESPACE::open(TEST_FILE1, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd1, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int fd2 = LIBC_NAMESPACE::open(TEST_FILE2, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd2, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd1), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::close(fd2), Succeeds(0));
@@ -49,20 +49,20 @@ TEST(LlvmLibcResourceLimitsTest, SetNoFileLimit) {
// One can now only open one of the files successfully.
fd1 = LIBC_NAMESPACE::open(TEST_FILE1, O_RDONLY);
ASSERT_GT(fd1, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
fd2 = LIBC_NAMESPACE::open(TEST_FILE2, O_RDONLY);
ASSERT_LT(fd2, 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
ASSERT_THAT(LIBC_NAMESPACE::close(fd1), Succeeds(0));
fd2 = LIBC_NAMESPACE::open(TEST_FILE2, O_RDONLY);
ASSERT_GT(fd2, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
fd1 = LIBC_NAMESPACE::open(TEST_FILE1, O_RDONLY);
ASSERT_LT(fd1, 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
ASSERT_THAT(LIBC_NAMESPACE::close(fd2), Succeeds(0));
diff --git a/libc/test/src/sys/sendfile/sendfile_test.cpp b/libc/test/src/sys/sendfile/sendfile_test.cpp
index 6e4665a1bb96b10..e673416b2c08bd9 100644
--- a/libc/test/src/sys/sendfile/sendfile_test.cpp
+++ b/libc/test/src/sys/sendfile/sendfile_test.cpp
@@ -39,16 +39,16 @@ TEST(LlvmLibcSendfileTest, CreateAndTransfer) {
int in_fd = LIBC_NAMESPACE::open(IN_FILE, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(in_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::write(in_fd, IN_DATA, IN_SIZE), IN_SIZE);
ASSERT_THAT(LIBC_NAMESPACE::close(in_fd), Succeeds(0));
in_fd = LIBC_NAMESPACE::open(IN_FILE, O_RDONLY);
ASSERT_GT(in_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int out_fd = LIBC_NAMESPACE::open(OUT_FILE, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(out_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ssize_t size = LIBC_NAMESPACE::sendfile(in_fd, out_fd, nullptr, IN_SIZE);
ASSERT_EQ(size, IN_SIZE);
ASSERT_THAT(LIBC_NAMESPACE::close(in_fd), Succeeds(0));
@@ -56,7 +56,7 @@ TEST(LlvmLibcSendfileTest, CreateAndTransfer) {
out_fd = LIBC_NAMESPACE::open(OUT_FILE, O_RDONLY);
ASSERT_GT(out_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
char buf[IN_SIZE];
ASSERT_EQ(IN_SIZE, LIBC_NAMESPACE::read(out_fd, buf, IN_SIZE));
ASSERT_EQ(cpp::string_view(buf), cpp::string_view(IN_DATA));
diff --git a/libc/test/src/sys/socket/linux/bind_test.cpp b/libc/test/src/sys/socket/linux/bind_test.cpp
index 5a3a1c227c9b58e..b942d0c6954d1d8 100644
--- a/libc/test/src/sys/socket/linux/bind_test.cpp
+++ b/libc/test/src/sys/socket/linux/bind_test.cpp
@@ -25,7 +25,7 @@ TEST(LlvmLibcSocketTest, BindLocalSocket) {
int sock = LIBC_NAMESPACE::socket(AF_UNIX, SOCK_DGRAM, 0);
ASSERT_GE(sock, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
struct sockaddr_un my_addr;
@@ -47,7 +47,7 @@ TEST(LlvmLibcSocketTest, BindLocalSocket) {
sizeof(struct sockaddr_un));
ASSERT_EQ(result, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
LIBC_NAMESPACE::close(sock);
diff --git a/libc/test/src/sys/socket/linux/socket_test.cpp b/libc/test/src/sys/socket/linux/socket_test.cpp
index 9d5bfacde0a4099..c9b0cba71695fa8 100644
--- a/libc/test/src/sys/socket/linux/socket_test.cpp
+++ b/libc/test/src/sys/socket/linux/socket_test.cpp
@@ -18,7 +18,7 @@
TEST(LlvmLibcSocketTest, LocalSocket) {
int sock = LIBC_NAMESPACE::socket(AF_UNIX, SOCK_DGRAM, 0);
ASSERT_GE(sock, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
LIBC_NAMESPACE::close(sock);
}
diff --git a/libc/test/src/sys/stat/chmod_test.cpp b/libc/test/src/sys/stat/chmod_test.cpp
index c476b92b5e4379f..c665ad4c475949f 100644
--- a/libc/test/src/sys/stat/chmod_test.cpp
+++ b/libc/test/src/sys/stat/chmod_test.cpp
@@ -32,25 +32,25 @@ TEST(LlvmLibcChmodTest, ChangeAndOpen) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_WRONLY);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::write(fd, WRITE_DATA, sizeof(WRITE_DATA)),
WRITE_SIZE);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_PATH);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
EXPECT_THAT(LIBC_NAMESPACE::chmod(TEST_FILE, S_IRUSR), Succeeds(0));
// Opening for writing should fail.
EXPECT_EQ(LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_WRONLY), -1);
- EXPECT_NE(libc_errno, 0);
+ EXPECT_ERRNO();
libc_errno = 0;
// But opening for reading should succeed.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_RDONLY);
EXPECT_GT(fd, 0);
- EXPECT_EQ(libc_errno, 0);
+ EXPECT_ERRNO_EQ(0);
EXPECT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
EXPECT_THAT(LIBC_NAMESPACE::chmod(TEST_FILE, S_IRWXU), Succeeds(0));
diff --git a/libc/test/src/sys/stat/fchmod_test.cpp b/libc/test/src/sys/stat/fchmod_test.cpp
index 5a32b5c973db9b6..1e9b9bef9e9206c 100644
--- a/libc/test/src/sys/stat/fchmod_test.cpp
+++ b/libc/test/src/sys/stat/fchmod_test.cpp
@@ -32,25 +32,25 @@ TEST(LlvmLibcChmodTest, ChangeAndOpen) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_WRONLY);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::write(fd, WRITE_DATA, sizeof(WRITE_DATA)),
WRITE_SIZE);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_WRONLY);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_THAT(LIBC_NAMESPACE::fchmod(fd, S_IRUSR), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
// Opening for writing should fail.
EXPECT_EQ(LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_WRONLY), -1);
- EXPECT_NE(libc_errno, 0);
+ EXPECT_ERRNO();
libc_errno = 0;
// But opening for reading should succeed.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_RDONLY);
EXPECT_GT(fd, 0);
- EXPECT_EQ(libc_errno, 0);
+ EXPECT_ERRNO_EQ(0);
EXPECT_THAT(LIBC_NAMESPACE::fchmod(fd, S_IRWXU), Succeeds(0));
EXPECT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
@@ -59,6 +59,6 @@ TEST(LlvmLibcChmodTest, ChangeAndOpen) {
TEST(LlvmLibcChmodTest, NonExistentFile) {
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::fchmod(-1, S_IRUSR), -1);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
}
diff --git a/libc/test/src/sys/stat/fchmodat_test.cpp b/libc/test/src/sys/stat/fchmodat_test.cpp
index 077d21df15af3ce..5be385a42675bc2 100644
--- a/libc/test/src/sys/stat/fchmodat_test.cpp
+++ b/libc/test/src/sys/stat/fchmodat_test.cpp
@@ -34,26 +34,26 @@ TEST(LlvmLibcFchmodatTest, ChangeAndOpen) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::write(fd, WRITE_DATA, sizeof(WRITE_DATA)),
WRITE_SIZE);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
int dirfd = LIBC_NAMESPACE::open(TEST_DIR, O_DIRECTORY);
ASSERT_GT(dirfd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_THAT(LIBC_NAMESPACE::fchmodat(dirfd, TEST_FILE_BASENAME, S_IRUSR, 0),
Succeeds(0));
// Opening for writing should fail.
EXPECT_EQ(LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_WRONLY), -1);
- EXPECT_NE(libc_errno, 0);
+ EXPECT_ERRNO();
libc_errno = 0;
// But opening for reading should succeed.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_APPEND | O_RDONLY);
EXPECT_GT(fd, 0);
- EXPECT_EQ(libc_errno, 0);
+ EXPECT_ERRNO_EQ(0);
EXPECT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
EXPECT_THAT(LIBC_NAMESPACE::fchmodat(dirfd, TEST_FILE_BASENAME, S_IRWXU, 0),
diff --git a/libc/test/src/sys/stat/fstat_test.cpp b/libc/test/src/sys/stat/fstat_test.cpp
index 22e407f6d791b8d..4de92746c524975 100644
--- a/libc/test/src/sys/stat/fstat_test.cpp
+++ b/libc/test/src/sys/stat/fstat_test.cpp
@@ -30,7 +30,7 @@ TEST(LlvmLibcFStatTest, CreatAndReadMode) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
struct stat statbuf;
ASSERT_THAT(LIBC_NAMESPACE::fstat(fd, &statbuf), Succeeds(0));
diff --git a/libc/test/src/sys/stat/lstat_test.cpp b/libc/test/src/sys/stat/lstat_test.cpp
index 6eae08daeb1cff8..31b33e7399fd132 100644
--- a/libc/test/src/sys/stat/lstat_test.cpp
+++ b/libc/test/src/sys/stat/lstat_test.cpp
@@ -30,7 +30,7 @@ TEST(LlvmLibcLStatTest, CreatAndReadMode) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
struct stat statbuf;
diff --git a/libc/test/src/sys/stat/stat_test.cpp b/libc/test/src/sys/stat/stat_test.cpp
index 1711c860df269d2..054686c5d7a529d 100644
--- a/libc/test/src/sys/stat/stat_test.cpp
+++ b/libc/test/src/sys/stat/stat_test.cpp
@@ -30,7 +30,7 @@ TEST(LlvmLibcStatTest, CreatAndReadMode) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
struct stat statbuf;
diff --git a/libc/test/src/termios/termios_test.cpp b/libc/test/src/termios/termios_test.cpp
index 3048f9cda1e0596..bb0ece4174635e0 100644
--- a/libc/test/src/termios/termios_test.cpp
+++ b/libc/test/src/termios/termios_test.cpp
@@ -48,7 +48,7 @@ TEST(LlvmLibcTermiosTest, GetAttrSmokeTest) {
int fd = LIBC_NAMESPACE::open("/dev/tty", O_RDONLY);
if (fd < 0)
return; // When /dev/tty is not available, no point continuing.
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::tcgetattr(fd, &t), Succeeds(0));
ASSERT_EQ(LIBC_NAMESPACE::close(fd), 0);
}
@@ -58,7 +58,7 @@ TEST(LlvmLibcTermiosTest, TcGetSidSmokeTest) {
int fd = LIBC_NAMESPACE::open("/dev/tty", O_RDONLY);
if (fd < 0)
return; // When /dev/tty is not available, no point continuing.
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(LIBC_NAMESPACE::tcgetsid(fd), pid_t(0));
ASSERT_EQ(LIBC_NAMESPACE::close(fd), 0);
}
diff --git a/libc/test/src/time/gmtime_test.cpp b/libc/test/src/time/gmtime_test.cpp
index e59daf012d9b6ca..9851fb3fabe4ea2 100644
--- a/libc/test/src/time/gmtime_test.cpp
+++ b/libc/test/src/time/gmtime_test.cpp
@@ -26,7 +26,7 @@ TEST(LlvmLibcGmTime, OutOfRange) {
TimeConstants::NUMBER_OF_SECONDS_IN_LEAP_YEAR);
struct tm *tm_data = LIBC_NAMESPACE::gmtime(&seconds);
EXPECT_TRUE(tm_data == nullptr);
- EXPECT_EQ(libc_errno, EOVERFLOW);
+ EXPECT_ERRNO_EQ(EOVERFLOW);
libc_errno = 0;
seconds = INT_MIN * static_cast<int64_t>(
@@ -34,7 +34,7 @@ TEST(LlvmLibcGmTime, OutOfRange) {
1;
tm_data = LIBC_NAMESPACE::gmtime(&seconds);
EXPECT_TRUE(tm_data == nullptr);
- EXPECT_EQ(libc_errno, EOVERFLOW);
+ EXPECT_ERRNO_EQ(EOVERFLOW);
}
TEST(LlvmLibcGmTime, InvalidSeconds) {
diff --git a/libc/test/src/time/nanosleep_test.cpp b/libc/test/src/time/nanosleep_test.cpp
index 2826ed14dfedaba..af95df5a0479ca4 100644
--- a/libc/test/src/time/nanosleep_test.cpp
+++ b/libc/test/src/time/nanosleep_test.cpp
@@ -23,6 +23,6 @@ TEST(LlvmLibcNanosleep, SmokeTest) {
struct timespec tim = {1, 500};
struct timespec tim2 = {0, 0};
int ret = LIBC_NAMESPACE::nanosleep(&tim, &tim2);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(ret, 0);
}
diff --git a/libc/test/src/unistd/access_test.cpp b/libc/test/src/unistd/access_test.cpp
index 7d4b3be443fed49..0c22fb1dce05c01 100644
--- a/libc/test/src/unistd/access_test.cpp
+++ b/libc/test/src/unistd/access_test.cpp
@@ -24,29 +24,29 @@ TEST(LlvmLibcAccessTest, CreateAndTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/access.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, F_OK), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, X_OK | W_OK | R_OK), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::unlink(TEST_FILE), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IXUSR);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, F_OK), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, X_OK), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, R_OK), -1);
- ASSERT_EQ(libc_errno, EACCES);
+ ASSERT_ERRNO_EQ(EACCES);
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, W_OK), -1);
- ASSERT_EQ(libc_errno, EACCES);
+ ASSERT_ERRNO_EQ(EACCES);
libc_errno = 0;
ASSERT_THAT(LIBC_NAMESPACE::unlink(TEST_FILE), Succeeds(0));
}
diff --git a/libc/test/src/unistd/chdir_test.cpp b/libc/test/src/unistd/chdir_test.cpp
index dfdeacdc8e42afc..4e15ffff92bdbe6 100644
--- a/libc/test/src/unistd/chdir_test.cpp
+++ b/libc/test/src/unistd/chdir_test.cpp
@@ -28,13 +28,13 @@ TEST(LlvmLibcChdirTest, ChangeAndOpen) {
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_PATH);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::chdir(TEST_DIR), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE_BASE, O_PATH);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
}
diff --git a/libc/test/src/unistd/dup2_test.cpp b/libc/test/src/unistd/dup2_test.cpp
index d46c4b919ce72cb..cb3184344034c18 100644
--- a/libc/test/src/unistd/dup2_test.cpp
+++ b/libc/test/src/unistd/dup2_test.cpp
@@ -24,10 +24,10 @@ TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/dup2.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
int dupfd = LIBC_NAMESPACE::dup2(fd, DUPFD);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(dupfd, DUPFD);
// Write something via the dup
@@ -39,10 +39,10 @@ TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
// Reopen the file for reading and create a dup.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
dupfd = LIBC_NAMESPACE::dup2(fd, DUPFD);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(dupfd, DUPFD);
// Read the file content via the dup.
diff --git a/libc/test/src/unistd/dup3_test.cpp b/libc/test/src/unistd/dup3_test.cpp
index d2d544d5d9a12f8..3759ea43efcc5a3 100644
--- a/libc/test/src/unistd/dup3_test.cpp
+++ b/libc/test/src/unistd/dup3_test.cpp
@@ -30,10 +30,10 @@ TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/dup3.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
int dupfd = LIBC_NAMESPACE::dup3(fd, DUPFD, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(dupfd, DUPFD);
// Write something via the dup
@@ -45,10 +45,10 @@ TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
// Reopen the file for reading and create a dup.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
dupfd = LIBC_NAMESPACE::dup3(fd, DUPFD, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(dupfd, DUPFD);
// Read the file content via the dup.
diff --git a/libc/test/src/unistd/dup_test.cpp b/libc/test/src/unistd/dup_test.cpp
index 856b004fbe65d58..aa2236794a41bce 100644
--- a/libc/test/src/unistd/dup_test.cpp
+++ b/libc/test/src/unistd/dup_test.cpp
@@ -23,10 +23,10 @@ TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/dup.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
int dupfd = LIBC_NAMESPACE::dup(fd);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(dupfd, 0);
// Write something via the dup
@@ -38,10 +38,10 @@ TEST(LlvmLibcdupTest, ReadAndWriteViaDup) {
// Reopen the file for reading and create a dup.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
dupfd = LIBC_NAMESPACE::dup(fd);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(dupfd, 0);
// Read the file content via the dup.
diff --git a/libc/test/src/unistd/fchdir_test.cpp b/libc/test/src/unistd/fchdir_test.cpp
index 27d4489f6447ea0..59f6f574714df01 100644
--- a/libc/test/src/unistd/fchdir_test.cpp
+++ b/libc/test/src/unistd/fchdir_test.cpp
@@ -28,16 +28,16 @@ TEST(LlvmLibcChdirTest, ChangeAndOpen) {
int dir_fd = LIBC_NAMESPACE::open(TEST_DIR, O_DIRECTORY);
ASSERT_GT(dir_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
int file_fd = LIBC_NAMESPACE::open(TEST_FILE, O_PATH);
ASSERT_GT(file_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(file_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::fchdir(dir_fd), Succeeds(0));
file_fd = LIBC_NAMESPACE::open(TEST_FILE_BASE, O_PATH);
ASSERT_GT(file_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(file_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::close(dir_fd), Succeeds(0));
}
@@ -46,6 +46,6 @@ TEST(LlvmLibcChdirTest, ChangeToNonExistentDir) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
libc_errno = 0;
ASSERT_EQ(LIBC_NAMESPACE::fchdir(0), -1);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO();
libc_errno = 0;
}
diff --git a/libc/test/src/unistd/ftruncate_test.cpp b/libc/test/src/unistd/ftruncate_test.cpp
index fc68348e32ec667..ca563e1d1b7caf9 100644
--- a/libc/test/src/unistd/ftruncate_test.cpp
+++ b/libc/test/src/unistd/ftruncate_test.cpp
@@ -35,14 +35,14 @@ TEST(LlvmLibcFtruncateTest, CreateAndTruncate) {
// 4. Try to read more than 1 byte and fail.
libc_errno = 0;
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_EQ(ssize_t(WRITE_SIZE),
LIBC_NAMESPACE::write(fd, WRITE_DATA, WRITE_SIZE));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_EQ(ssize_t(WRITE_SIZE), LIBC_NAMESPACE::read(fd, buf, WRITE_SIZE));
ASSERT_EQ(cpp::string_view(buf), cpp::string_view(WRITE_DATA));
@@ -52,12 +52,12 @@ TEST(LlvmLibcFtruncateTest, CreateAndTruncate) {
// writing.
fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY);
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::ftruncate(fd, off_t(1)), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_EQ(ssize_t(1), LIBC_NAMESPACE::read(fd, buf, WRITE_SIZE));
ASSERT_EQ(buf[0], WRITE_DATA[0]);
diff --git a/libc/test/src/unistd/isatty_test.cpp b/libc/test/src/unistd/isatty_test.cpp
index 7bf8dd708bfa6f3..c9c57d921d0bf01 100644
--- a/libc/test/src/unistd/isatty_test.cpp
+++ b/libc/test/src/unistd/isatty_test.cpp
@@ -43,7 +43,7 @@ TEST(LlvmLibcIsATTYTest, DevTTYTest) {
libc_errno = 0;
int fd = LIBC_NAMESPACE::open(TTY_FILE, O_RDONLY);
if (fd > 0) {
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
EXPECT_THAT(LIBC_NAMESPACE::isatty(fd), Succeeds(1));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
}
@@ -53,7 +53,7 @@ TEST(LlvmLibcIsATTYTest, FileTest) {
constexpr const char *TEST_FILE = "testdata/isatty.test";
libc_errno = 0;
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
EXPECT_THAT(LIBC_NAMESPACE::isatty(fd), Fails(ENOTTY, 0));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
diff --git a/libc/test/src/unistd/link_test.cpp b/libc/test/src/unistd/link_test.cpp
index 2d5aa7588b08b90..f89bbcfc76838c6 100644
--- a/libc/test/src/unistd/link_test.cpp
+++ b/libc/test/src/unistd/link_test.cpp
@@ -28,14 +28,14 @@ TEST(LlvmLibcLinkTest, CreateAndUnlink) {
// 4. Cleanup the file and its link.
libc_errno = 0;
int write_fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::link(TEST_FILE, TEST_FILE_LINK), Succeeds(0));
int link_fd = LIBC_NAMESPACE::open(TEST_FILE_LINK, O_PATH);
ASSERT_GT(link_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(link_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::unlink(TEST_FILE), Succeeds(0));
diff --git a/libc/test/src/unistd/linkat_test.cpp b/libc/test/src/unistd/linkat_test.cpp
index d1ffe37d63b48c7..23ad21280958cdb 100644
--- a/libc/test/src/unistd/linkat_test.cpp
+++ b/libc/test/src/unistd/linkat_test.cpp
@@ -32,7 +32,7 @@ TEST(LlvmLibcLinkatTest, CreateAndUnlink) {
libc_errno = 0;
int write_fd =
LIBC_NAMESPACE::open(TEST_FILE_PATH, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
@@ -43,7 +43,7 @@ TEST(LlvmLibcLinkatTest, CreateAndUnlink) {
int link_fd = LIBC_NAMESPACE::open(TEST_FILE_LINK_PATH, O_PATH);
ASSERT_GT(link_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(link_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::unlink(TEST_FILE_PATH), Succeeds(0));
diff --git a/libc/test/src/unistd/lseek_test.cpp b/libc/test/src/unistd/lseek_test.cpp
index 1a13d54dbc2328c..b827adea8d5e10e 100644
--- a/libc/test/src/unistd/lseek_test.cpp
+++ b/libc/test/src/unistd/lseek_test.cpp
@@ -20,7 +20,7 @@ TEST(LlvmLibcUniStd, LseekTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/lseek.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
constexpr const char LSEEK_TEST[] = "lseek test";
constexpr int LSEEK_TEST_SIZE = sizeof(LSEEK_TEST) - 1;
@@ -54,7 +54,7 @@ TEST(LlvmLibcUniStd, LseekFailsTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/lseek.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
EXPECT_THAT(LIBC_NAMESPACE::lseek(fd, -1, SEEK_CUR), Fails(EINVAL));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
diff --git a/libc/test/src/unistd/pread_pwrite_test.cpp b/libc/test/src/unistd/pread_pwrite_test.cpp
index f90d1341c20108a..865d1d2e77be993 100644
--- a/libc/test/src/unistd/pread_pwrite_test.cpp
+++ b/libc/test/src/unistd/pread_pwrite_test.cpp
@@ -34,7 +34,7 @@ TEST(LlvmLibcUniStd, PWriteAndPReadBackTest) {
constexpr const char *TEST_FILE = "testdata/pread_pwrite.test";
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::write(fd, HELLO, HELLO_SIZE),
Succeeds(HELLO_SIZE));
@@ -42,7 +42,7 @@ TEST(LlvmLibcUniStd, PWriteAndPReadBackTest) {
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::pwrite(fd, HELLO, HELLO_SIZE, OFFSET),
Succeeds(HELLO_SIZE));
@@ -50,7 +50,7 @@ TEST(LlvmLibcUniStd, PWriteAndPReadBackTest) {
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
char read_buf[OFFSET_TEXT_SIZE];
ASSERT_THAT(LIBC_NAMESPACE::pread(fd, read_buf, HELLO_SIZE, OFFSET),
diff --git a/libc/test/src/unistd/read_write_test.cpp b/libc/test/src/unistd/read_write_test.cpp
index 3007d4c38711579..50016114085d21d 100644
--- a/libc/test/src/unistd/read_write_test.cpp
+++ b/libc/test/src/unistd/read_write_test.cpp
@@ -21,7 +21,7 @@ TEST(LlvmLibcUniStd, WriteAndReadBackTest) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "__unistd_read_write.test";
int write_fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
constexpr const char HELLO[] = "hello";
constexpr int HELLO_SIZE = sizeof(HELLO);
@@ -31,7 +31,7 @@ TEST(LlvmLibcUniStd, WriteAndReadBackTest) {
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
int read_fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(read_fd, 0);
char read_buf[10];
ASSERT_THAT(LIBC_NAMESPACE::read(read_fd, read_buf, HELLO_SIZE),
diff --git a/libc/test/src/unistd/readlink_test.cpp b/libc/test/src/unistd/readlink_test.cpp
index b2d018a50ec7931..747169fa394b8da 100644
--- a/libc/test/src/unistd/readlink_test.cpp
+++ b/libc/test/src/unistd/readlink_test.cpp
@@ -30,7 +30,7 @@ TEST(LlvmLibcReadlinkTest, CreateAndUnlink) {
char buf[sizeof(LINK_VAL)];
ssize_t len = LIBC_NAMESPACE::readlink(LINK, buf, sizeof(buf));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(cpp::string_view(buf, len), cpp::string_view(LINK_VAL));
ASSERT_THAT(LIBC_NAMESPACE::unlink(LINK), Succeeds(0));
diff --git a/libc/test/src/unistd/readlinkat_test.cpp b/libc/test/src/unistd/readlinkat_test.cpp
index 19f0ceec3cf7c59..e21375aea333f8a 100644
--- a/libc/test/src/unistd/readlinkat_test.cpp
+++ b/libc/test/src/unistd/readlinkat_test.cpp
@@ -32,7 +32,7 @@ TEST(LlvmLibcReadlinkatTest, CreateAndUnlink) {
char buf[sizeof(LINK_VAL)];
ssize_t len = LIBC_NAMESPACE::readlinkat(AT_FDCWD, LINK, buf, sizeof(buf));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_EQ(cpp::string_view(buf, len), cpp::string_view(LINK_VAL));
ASSERT_THAT(LIBC_NAMESPACE::unlink(LINK), Succeeds(0));
diff --git a/libc/test/src/unistd/symlink_test.cpp b/libc/test/src/unistd/symlink_test.cpp
index b25cfa4f8576995..700a3ff8aa3d168 100644
--- a/libc/test/src/unistd/symlink_test.cpp
+++ b/libc/test/src/unistd/symlink_test.cpp
@@ -29,7 +29,7 @@ TEST(LlvmLibcSymlinkTest, CreateAndUnlink) {
// 4. Cleanup the file and its symlink.
libc_errno = 0;
int write_fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
@@ -38,7 +38,7 @@ TEST(LlvmLibcSymlinkTest, CreateAndUnlink) {
int symlink_fd = LIBC_NAMESPACE::open(TEST_FILE_LINK, O_PATH);
ASSERT_GT(symlink_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(symlink_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::unlink(TEST_FILE), Succeeds(0));
diff --git a/libc/test/src/unistd/symlinkat_test.cpp b/libc/test/src/unistd/symlinkat_test.cpp
index 8aba2daee8cf383..ce96868889b7a07 100644
--- a/libc/test/src/unistd/symlinkat_test.cpp
+++ b/libc/test/src/unistd/symlinkat_test.cpp
@@ -32,7 +32,7 @@ TEST(LlvmLibcSymlinkatTest, CreateAndUnlink) {
libc_errno = 0;
int write_fd =
LIBC_NAMESPACE::open(TEST_FILE_PATH, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
@@ -42,7 +42,7 @@ TEST(LlvmLibcSymlinkatTest, CreateAndUnlink) {
int link_fd = LIBC_NAMESPACE::open(TEST_FILE_LINK_PATH, O_PATH);
ASSERT_GT(link_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_THAT(LIBC_NAMESPACE::close(link_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::close(dir_fd), Succeeds(0));
diff --git a/libc/test/src/unistd/syscall_test.cpp b/libc/test/src/unistd/syscall_test.cpp
index 6a5ca47f8d494a8..8c3a92c76ff81cc 100644
--- a/libc/test/src/unistd/syscall_test.cpp
+++ b/libc/test/src/unistd/syscall_test.cpp
@@ -30,7 +30,7 @@ TEST(LlvmLibcSyscallTest, TrivialCall) {
libc_errno = 0;
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_gettid), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
TEST(LlvmLibcSyscallTest, SymlinkCreateDestroy) {
@@ -45,7 +45,7 @@ TEST(LlvmLibcSyscallTest, SymlinkCreateDestroy) {
#else
#error "symlink and symlinkat syscalls not available."
#endif
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
char buf[sizeof(LINK_VAL)];
@@ -56,7 +56,7 @@ TEST(LlvmLibcSyscallTest, SymlinkCreateDestroy) {
LIBC_NAMESPACE::syscall(SYS_readlinkat, AT_FDCWD, LINK, buf, sizeof(buf)),
0l);
#endif
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
#ifdef SYS_unlink
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_unlink, LINK), 0l);
@@ -65,7 +65,7 @@ TEST(LlvmLibcSyscallTest, SymlinkCreateDestroy) {
#else
#error "unlink and unlinkat syscalls not available."
#endif
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
TEST(LlvmLibcSyscallTest, FileReadWrite) {
@@ -84,17 +84,17 @@ TEST(LlvmLibcSyscallTest, FileReadWrite) {
#error "open and openat syscalls not available."
#endif
ASSERT_GT(fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_pwrite64, fd, HELLO, HELLO_SIZE, 0),
0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_fsync, fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_close, fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
@@ -121,10 +121,10 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
#error "open and openat syscalls not available."
#endif
ASSERT_GT(write_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_close, write_fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
#ifdef SYS_open
int dir_fd = LIBC_NAMESPACE::syscall(SYS_open, TEST_DIR, O_DIRECTORY, 0);
@@ -135,12 +135,12 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
#error "open and openat syscalls not available."
#endif
ASSERT_GT(dir_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_linkat, dir_fd, TEST_FILE, dir_fd,
TEST_FILE_LINK, 0),
0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
#ifdef SYS_open
int link_fd =
LIBC_NAMESPACE::syscall(SYS_open, TEST_FILE_LINK_PATH, O_PATH, 0);
@@ -151,7 +151,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
#error "open and openat syscalls not available."
#endif
ASSERT_GT(link_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
#ifdef SYS_unlink
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_unlink, TEST_FILE_PATH), 0l);
@@ -161,7 +161,7 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
#else
#error "unlink and unlinkat syscalls not available."
#endif
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
#ifdef SYS_unlink
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_unlink, TEST_FILE_LINK_PATH), 0l);
@@ -172,8 +172,8 @@ TEST(LlvmLibcSyscallTest, FileLinkCreateDestroy) {
#else
#error "unlink and unlinkat syscalls not available."
#endif
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_close, dir_fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
}
diff --git a/libc/test/src/unistd/truncate_test.cpp b/libc/test/src/unistd/truncate_test.cpp
index 6d8a3b8e53f7281..bf86a6a6f79eafe 100644
--- a/libc/test/src/unistd/truncate_test.cpp
+++ b/libc/test/src/unistd/truncate_test.cpp
@@ -35,14 +35,14 @@ TEST(LlvmLibcTruncateTest, CreateAndTruncate) {
// 4. Try to read more than 1 byte and fail.
libc_errno = 0;
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_EQ(ssize_t(WRITE_SIZE),
LIBC_NAMESPACE::write(fd, WRITE_DATA, WRITE_SIZE));
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_EQ(ssize_t(WRITE_SIZE), LIBC_NAMESPACE::read(fd, buf, WRITE_SIZE));
ASSERT_EQ(cpp::string_view(buf), cpp::string_view(WRITE_DATA));
@@ -51,7 +51,7 @@ TEST(LlvmLibcTruncateTest, CreateAndTruncate) {
ASSERT_THAT(LIBC_NAMESPACE::truncate(TEST_FILE, off_t(1)), Succeeds(0));
fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(fd, 0);
ASSERT_EQ(ssize_t(1), LIBC_NAMESPACE::read(fd, buf, WRITE_SIZE));
ASSERT_EQ(buf[0], WRITE_DATA[0]);
diff --git a/libc/test/src/unistd/unlink_test.cpp b/libc/test/src/unistd/unlink_test.cpp
index 77f65b5ecc6a1a1..17498be0b51b6af 100644
--- a/libc/test/src/unistd/unlink_test.cpp
+++ b/libc/test/src/unistd/unlink_test.cpp
@@ -19,7 +19,7 @@ TEST(LlvmLibcUnlinkTest, CreateAndUnlink) {
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
constexpr const char *TEST_FILE = "testdata/unlink.test";
int write_fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::unlink(TEST_FILE), Succeeds(0));
diff --git a/libc/test/src/unistd/unlinkat_test.cpp b/libc/test/src/unistd/unlinkat_test.cpp
index 22a20bc6ad07bce..327618a2aac1fcf 100644
--- a/libc/test/src/unistd/unlinkat_test.cpp
+++ b/libc/test/src/unistd/unlinkat_test.cpp
@@ -21,11 +21,11 @@ TEST(LlvmLibcUnlinkatTest, CreateAndDeleteTest) {
constexpr const char *TEST_DIR = "testdata";
constexpr const char *TEST_FILE = "openat.test";
int dir_fd = LIBC_NAMESPACE::open(TEST_DIR, O_DIRECTORY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(dir_fd, 0);
int write_fd =
LIBC_NAMESPACE::openat(dir_fd, TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(write_fd, 0);
ASSERT_THAT(LIBC_NAMESPACE::close(write_fd), Succeeds(0));
ASSERT_THAT(LIBC_NAMESPACE::unlinkat(dir_fd, TEST_FILE, 0), Succeeds(0));
@@ -35,7 +35,7 @@ TEST(LlvmLibcUnlinkatTest, CreateAndDeleteTest) {
TEST(LlvmLibcUnlinkatTest, UnlinkatNonExistentFile) {
constexpr const char *TEST_DIR = "testdata";
int dir_fd = LIBC_NAMESPACE::open(TEST_DIR, O_DIRECTORY);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_EQ(0);
ASSERT_GT(dir_fd, 0);
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
More information about the libc-commits
mailing list