[libc-commits] [libc] 73874f7 - [libc][NFC] Use specific ASSERT macros to test errno (#79573)
via libc-commits
libc-commits at lists.llvm.org
Fri Jan 26 06:18:26 PST 2024
Author: Guillaume Chatelet
Date: 2024-01-26T15:18:22+01:00
New Revision: 73874f7a39df74eacf1682b3961da2d8cb675f33
URL: https://github.com/llvm/llvm-project/commit/73874f7a39df74eacf1682b3961da2d8cb675f33
DIFF: https://github.com/llvm/llvm-project/commit/73874f7a39df74eacf1682b3961da2d8cb675f33.diff
LOG: [libc][NFC] Use specific ASSERT macros to test errno (#79573)
This patch provides specific test macros to deal with `errno`.
This will help abstract away the differences between unit test and integration/hermetic tests in #79319.
In one case we use `libc_errno` which is a struct, in the other case we deal directly with `errno`.
Added:
Modified:
libc/test/IntegrationTest/test.h
libc/test/UnitTest/LibcTest.h
libc/test/integration/src/pthread/pthread_create_test.cpp
libc/test/integration/src/pthread/pthread_join_test.cpp
libc/test/integration/src/unistd/getcwd_test.cpp
libc/test/src/dirent/dirent_test.cpp
libc/test/src/fcntl/creat_test.cpp
libc/test/src/fcntl/openat_test.cpp
libc/test/src/sched/get_priority_test.cpp
libc/test/src/sched/param_and_scheduler_test.cpp
libc/test/src/sched/sched_rr_get_interval_test.cpp
libc/test/src/sched/yield_test.cpp
libc/test/src/stdio/fgets_test.cpp
libc/test/src/stdio/fileop_test.cpp
libc/test/src/stdio/fopencookie_test.cpp
libc/test/src/stdio/remove_test.cpp
libc/test/src/stdio/setvbuf_test.cpp
libc/test/src/stdio/unlocked_fileop_test.cpp
libc/test/src/stdlib/StrtolTest.h
libc/test/src/stdlib/strtof_test.cpp
libc/test/src/stdlib/strtold_test.cpp
libc/test/src/string/strdup_test.cpp
libc/test/src/sys/prctl/linux/prctl_test.cpp
libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
libc/test/src/sys/sendfile/sendfile_test.cpp
libc/test/src/sys/socket/linux/bind_test.cpp
libc/test/src/sys/socket/linux/socket_test.cpp
libc/test/src/sys/stat/chmod_test.cpp
libc/test/src/sys/stat/fchmod_test.cpp
libc/test/src/sys/stat/fchmodat_test.cpp
libc/test/src/sys/stat/fstat_test.cpp
libc/test/src/sys/stat/lstat_test.cpp
libc/test/src/sys/stat/stat_test.cpp
libc/test/src/termios/termios_test.cpp
libc/test/src/time/gmtime_test.cpp
libc/test/src/time/nanosleep_test.cpp
libc/test/src/unistd/access_test.cpp
libc/test/src/unistd/chdir_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/fchdir_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/lseek_test.cpp
libc/test/src/unistd/pread_pwrite_test.cpp
libc/test/src/unistd/read_write_test.cpp
libc/test/src/unistd/readlink_test.cpp
libc/test/src/unistd/readlinkat_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/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index 1e5ad1cfef0d7b5..c015bb44586ff13 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,13 @@
#define ASSERT_NE(val1, val2) \
__CHECK_NE(__FILE__, __LINE__, (val1), (val2), true)
+////////////////////////////////////////////////////////////////////////////////
+// Errno checks.
+
+#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(libc_errno))
+
// 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..1a90d10d7ec01b7 100644
--- a/libc/test/UnitTest/LibcTest.h
+++ b/libc/test/UnitTest/LibcTest.h
@@ -443,6 +443,13 @@ 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 ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
+#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(libc_errno))
+
////////////////////////////////////////////////////////////////////////////////
// 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..5da91c6ec9a7d2a 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_SUCCESS();
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_SUCCESS();
ASSERT_EQ(
LIBC_NAMESPACE::pthread_attr_getstacksize(expec_attrs, &expec_stacksize2),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
ASSERT_EQ(
LIBC_NAMESPACE::pthread_attr_getguardsize(expec_attrs, &expec_guardsize),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
ASSERT_EQ(
LIBC_NAMESPACE::pthread_attr_getdetachstate(expec_attrs, &expec_detached),
0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
// 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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setdetachstate(attr, detachstate), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setguardsize(attr, guardsize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setstack(attr, Stack, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
} else {
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setstacksize(attr, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
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_SUCCESS();
}
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_SUCCESS();
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_SUCCESS();
ASSERT_EQ(th_ret, expec_ret);
if (customstack) {
ASSERT_EQ(LIBC_NAMESPACE::munmap(Stack, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
} 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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_destroy(attr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setguardsize(&attr, guardsize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_attr_setstacksize(&attr, stacksize), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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..da1a968aa47d384 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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::pthread_join(Tid, nullptr), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
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..e2e0399673be66d 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_SUCCESS();
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..4c9d2cbc33f4760 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_SUCCESS();
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_SUCCESS();
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..9dafd125224a406 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_SUCCESS();
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_SUCCESS();
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..4ff7890c4f404c9 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_SUCCESS();
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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..7fcb667a31a9d41 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_SUCCESS();
int max_priority = LIBC_NAMESPACE::sched_get_priority_max(policy);
ASSERT_GE(max_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
int min_priority = LIBC_NAMESPACE::sched_get_priority_min(policy);
ASSERT_GE(min_priority, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
// 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_SUCCESS();
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_SUCCESS();
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..5e024f07ced1231 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_SUCCESS();
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_SUCCESS();
};
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_SUCCESS();
// 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_SUCCESS();
// 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_SUCCESS();
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..5e4e07bc199b666 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_SUCCESS();
}
diff --git a/libc/test/src/stdio/fgets_test.cpp b/libc/test/src/stdio/fgets_test.cpp
index 9f9841c901f4edc..aab8bae3d97e990 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_SUCCESS();
// 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_SUCCESS();
// 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_SUCCESS();
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..d620aa076ef0dcb 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);
+ // ASSERT_ERRNO_FAILURE();
// libc_errno = 0;
// ASSERT_NE(LIBC_NAMESPACE::fclose(file), 0);
- // EXPECT_NE(libc_errno, 0);
+ // ASSERT_ERRNO_FAILURE();
// libc_errno = 0;
// ASSERT_EQ(LIBC_NAMESPACE::fopen("INVALID FILE NAME", "r"),
// static_cast<FILE *>(nullptr));
- // EXPECT_NE(libc_errno, 0);
+ // ASSERT_ERRNO_FAILURE();
}
TEST(LlvmLibcFILETest, FFlush) {
diff --git a/libc/test/src/stdio/fopencookie_test.cpp b/libc/test/src/stdio/fopencookie_test.cpp
index 6f3c2910cfd8235..2edfc7e210d7e44 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_FAILURE();
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);
+ ASSERT_ERRNO_FAILURE();
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..67bff906ef2a359 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_SUCCESS();
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..cf20701ca0e3b7a 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_FAILURE();
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_FAILURE();
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..8f1723b0386120c 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_SUCCESS();
EXPECT_EQ(str_end - ten, ptr
diff _t(2));
libc_errno = 0;
ASSERT_EQ(func(ten, nullptr, 10), ReturnT(10));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
const char *hundred = "100";
libc_errno = 0;
ASSERT_EQ(func(hundred, &str_end, 10), ReturnT(100));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
EXPECT_EQ(str_end - hundred, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - big_number, ptr
diff _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_SUCCESS();
}
EXPECT_EQ(str_end - bigger_number, ptr
diff _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, ptr
diff _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, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - negative, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - big_negative_number, ptr
diff _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, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - spaces_before, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - spaces_after, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - word_before, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - word_after, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - two_numbers, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - two_signs, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - sign_before, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - sign_after, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - tab_before, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - all_together, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - just_spaces, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - just_space_and_sign, ptr
diff _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_SUCCESS();
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
}
}
@@ -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_SUCCESS();
} 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_SUCCESS();
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
}
}
@@ -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_SUCCESS();
} 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_SUCCESS();
} 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_SUCCESS();
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base),
static_cast<ReturnT>(first_digit));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
} else {
libc_errno = 0;
ASSERT_EQ(func(small_string, nullptr, base), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
}
}
@@ -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_SUCCESS();
EXPECT_EQ(str_end - no_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - yes_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - letter_after_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - max_31_bit_value, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - negative_max_31_bit_value, ptr
diff _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, ptr
diff _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, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - just_prefix, ptr
diff _t(1));
libc_errno = 0;
ASSERT_EQ(func(just_prefix, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
EXPECT_EQ(str_end - just_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - prefix_with_x_after, ptr
diff _t(1));
libc_errno = 0;
ASSERT_EQ(func(prefix_with_x_after, &str_end, 0), ReturnT(0));
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
EXPECT_EQ(str_end - prefix_with_x_after, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - base_ten, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - base_sixteen_no_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - base_sixteen_with_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - base_eight_with_prefix, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - just_zero, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - just_zero_x, ptr
diff _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_SUCCESS();
EXPECT_EQ(str_end - just_zero_eight, ptr
diff _t(1));
}
};
diff --git a/libc/test/src/stdlib/strtof_test.cpp b/libc/test/src/stdlib/strtof_test.cpp
index f30c588c611b390..b43c32f9026164d 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);
+ ASSERT_ERRNO_EQ(expectedErrno);
}
};
diff --git a/libc/test/src/stdlib/strtold_test.cpp b/libc/test/src/stdlib/strtold_test.cpp
index b7942ab66460b65..cbe0a47b9b710b8 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);
+ ASSERT_ERRNO_EQ(expected_errno);
}
};
diff --git a/libc/test/src/string/strdup_test.cpp b/libc/test/src/string/strdup_test.cpp
index b1d4df31603c4b2..caf8c2e61c0e2a5 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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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..6278dcec588af74 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_SUCCESS();
// 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..1a0d79f4e7527dd 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_SUCCESS();
int fd2 = LIBC_NAMESPACE::open(TEST_FILE2, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd2, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
fd2 = LIBC_NAMESPACE::open(TEST_FILE2, O_RDONLY);
ASSERT_LT(fd2, 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO_FAILURE();
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_SUCCESS();
fd1 = LIBC_NAMESPACE::open(TEST_FILE1, O_RDONLY);
ASSERT_LT(fd1, 0);
- ASSERT_NE(libc_errno, 0);
+ ASSERT_ERRNO_FAILURE();
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..5ea9ca8d05c5abe 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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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..305e4889f394e1b 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_SUCCESS();
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_SUCCESS();
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..d1197fa3ef7c615 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_SUCCESS();
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..6fd056b2bd6cc31 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_SUCCESS();
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_SUCCESS();
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);
+ ASSERT_ERRNO_FAILURE();
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);
+ ASSERT_ERRNO_SUCCESS();
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..a0a93b03d22ed91 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_SUCCESS();
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_SUCCESS();
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);
+ ASSERT_ERRNO_FAILURE();
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);
+ ASSERT_ERRNO_SUCCESS();
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_FAILURE();
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..e2cf170728ec1e3 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_SUCCESS();
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_SUCCESS();
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);
+ ASSERT_ERRNO_FAILURE();
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);
+ ASSERT_ERRNO_SUCCESS();
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..33769ea1f05af77 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_SUCCESS();
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..a3b3c2cb0c1df28 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_SUCCESS();
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..1286e12fd6110c1 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_SUCCESS();
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..790c010c5b7eb80 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_SUCCESS();
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_SUCCESS();
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..d4bcc7d5831e95a 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);
+ ASSERT_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);
+ ASSERT_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..8baaa29df478500 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_SUCCESS();
ASSERT_EQ(ret, 0);
}
diff --git a/libc/test/src/unistd/access_test.cpp b/libc/test/src/unistd/access_test.cpp
index 7d4b3be443fed49..6718005846026a8 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_SUCCESS();
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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, X_OK | W_OK | R_OK), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
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_SUCCESS();
ASSERT_EQ(LIBC_NAMESPACE::access(TEST_FILE, X_OK), 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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..6676b71eed732b5 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_SUCCESS();
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_SUCCESS();
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..70ea1a72bc8e451 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_SUCCESS();
ASSERT_GT(fd, 0);
int dupfd = LIBC_NAMESPACE::dup2(fd, DUPFD);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
ASSERT_GT(fd, 0);
dupfd = LIBC_NAMESPACE::dup2(fd, DUPFD);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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..9c13de47f0be4c5 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_SUCCESS();
ASSERT_GT(fd, 0);
int dupfd = LIBC_NAMESPACE::dup3(fd, DUPFD, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
ASSERT_GT(fd, 0);
dupfd = LIBC_NAMESPACE::dup3(fd, DUPFD, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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..23abf5969fc28cd 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_SUCCESS();
ASSERT_GT(fd, 0);
int dupfd = LIBC_NAMESPACE::dup(fd);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
ASSERT_GT(fd, 0);
dupfd = LIBC_NAMESPACE::dup(fd);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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..0d870e35f51c5ef 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_SUCCESS();
int file_fd = LIBC_NAMESPACE::open(TEST_FILE, O_PATH);
ASSERT_GT(file_fd, 0);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
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_SUCCESS();
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_FAILURE();
libc_errno = 0;
}
diff --git a/libc/test/src/unistd/ftruncate_test.cpp b/libc/test/src/unistd/ftruncate_test.cpp
index fc68348e32ec667..50a3508e0a87267 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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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..c0e14c344b436a0 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_SUCCESS();
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_SUCCESS();
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..bf6962b397b2cec 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_SUCCESS();
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_SUCCESS();
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..62fbaacac08e4ff 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_SUCCESS();
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_SUCCESS();
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..fd73bccf0cb8ff6 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_SUCCESS();
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_SUCCESS();
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..1d17778e550f88c 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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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..133057358220926 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_SUCCESS();
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_SUCCESS();
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..19b339ec2b37422 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_SUCCESS();
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..85cbca084778d79 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_SUCCESS();
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..e0c5979a608762d 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_SUCCESS();
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_SUCCESS();
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..1ab4dc8417d6cdd 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_SUCCESS();
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_SUCCESS();
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..aabbffc20d1ba36 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_SUCCESS();
}
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_SUCCESS();
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_SUCCESS();
#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_SUCCESS();
}
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_SUCCESS();
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_pwrite64, fd, HELLO, HELLO_SIZE, 0),
0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_fsync, fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_close, fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
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_SUCCESS();
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_close, write_fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
#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_SUCCESS();
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_SUCCESS();
#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_SUCCESS();
#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_SUCCESS();
#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_SUCCESS();
ASSERT_GE(LIBC_NAMESPACE::syscall(SYS_close, dir_fd), 0l);
- ASSERT_EQ(libc_errno, 0);
+ ASSERT_ERRNO_SUCCESS();
}
diff --git a/libc/test/src/unistd/truncate_test.cpp b/libc/test/src/unistd/truncate_test.cpp
index 6d8a3b8e53f7281..4d316ed1b16fee3 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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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..c2828df65a18052 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_SUCCESS();
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..ac32ed4895d6b05 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_SUCCESS();
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_SUCCESS();
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_SUCCESS();
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