From af783db7fd3b01b4c7dc880d5df13f8d78f6cf92 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Mon, 13 Mar 2023 23:43:31 +0000 Subject: [PATCH] [libc][NFC] Switch sys/*.h tests over to libc_errno. --- libc/test/src/sys/random/linux/CMakeLists.txt | 1 - .../src/sys/random/linux/getrandom_test.cpp | 17 ++++++++++++---- .../sys/resource/getrlimit_setrlimit_test.cpp | 20 +++++++++---------- libc/test/src/sys/select/select_ui_test.cpp | 4 ++-- libc/test/src/sys/sendfile/sendfile_test.cpp | 12 +++++------ libc/test/src/sys/stat/CMakeLists.txt | 14 ++++++------- libc/test/src/sys/stat/chmod_test.cpp | 18 ++++++++--------- libc/test/src/sys/stat/fchmod_test.cpp | 20 +++++++++---------- libc/test/src/sys/stat/fchmodat_test.cpp | 18 ++++++++--------- libc/test/src/sys/stat/fstat_test.cpp | 10 +++++----- libc/test/src/sys/stat/mkdirat_test.cpp | 1 - libc/test/src/sys/stat/stat_test.cpp | 10 +++++----- 12 files changed, 76 insertions(+), 69 deletions(-) diff --git a/libc/test/src/sys/random/linux/CMakeLists.txt b/libc/test/src/sys/random/linux/CMakeLists.txt index 3dcfd8626c055..6277749087697 100644 --- a/libc/test/src/sys/random/linux/CMakeLists.txt +++ b/libc/test/src/sys/random/linux/CMakeLists.txt @@ -7,7 +7,6 @@ add_libc_unittest( SRCS getrandom_test.cpp DEPENDS - libc.include.errno libc.include.math libc.include.sys_random libc.src.errno.errno diff --git a/libc/test/src/sys/random/linux/getrandom_test.cpp b/libc/test/src/sys/random/linux/getrandom_test.cpp index 3514613020fe4..34b663627fe64 100644 --- a/libc/test/src/sys/random/linux/getrandom_test.cpp +++ b/libc/test/src/sys/random/linux/getrandom_test.cpp @@ -1,3 +1,12 @@ +//===-- Unittests for getrandom -------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/errno/libc_errno.h" #include "src/math/fabs.h" #include "src/sys/random/getrandom.h" #include "test/ErrnoSetterMatcher.h" @@ -7,17 +16,17 @@ TEST(LlvmLibcGetRandomTest, InvalidFlag) { using __llvm_libc::testing::ErrnoSetterMatcher::Fails; static constexpr size_t SIZE = 256; char data[SIZE]; - errno = 0; + libc_errno = 0; ASSERT_THAT(__llvm_libc::getrandom(data, SIZE, -1), Fails(EINVAL)); - errno = 0; + libc_errno = 0; } TEST(LlvmLibcGetRandomTest, InvalidBuffer) { using __llvm_libc::testing::ErrnoSetterMatcher::Fails; - errno = 0; + libc_errno = 0; ASSERT_THAT(__llvm_libc::getrandom(nullptr, 65536, 0), Fails(EFAULT)); - errno = 0; + libc_errno = 0; } TEST(LlvmLibcGetRandomTest, PiEstimation) { diff --git a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp index 285624af6ef07..aa7a549876aaa 100644 --- a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp +++ b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "src/__support/CPP/string_view.h" +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/resource/getrlimit.h" #include "src/sys/resource/setrlimit.h" @@ -15,7 +16,6 @@ #include "test/ErrnoSetterMatcher.h" #include "test/UnitTest/Test.h" -#include #include TEST(LlvmLibcResourceLimitsTest, SetNoFileLimit) { @@ -28,14 +28,14 @@ TEST(LlvmLibcResourceLimitsTest, SetNoFileLimit) { constexpr const char *TEST_FILE1 = "testdata/resource_limits1.test"; constexpr const char *TEST_FILE2 = "testdata/resource_limits2.test"; - errno = 0; + libc_errno = 0; int fd1 = __llvm_libc::open(TEST_FILE1, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(fd1, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); int fd2 = __llvm_libc::open(TEST_FILE2, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(fd2, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_THAT(__llvm_libc::close(fd1), Succeeds(0)); ASSERT_THAT(__llvm_libc::close(fd2), Succeeds(0)); @@ -48,22 +48,22 @@ TEST(LlvmLibcResourceLimitsTest, SetNoFileLimit) { // One can now only open one of the files successfully. fd1 = __llvm_libc::open(TEST_FILE1, O_RDONLY); ASSERT_GT(fd1, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); fd2 = __llvm_libc::open(TEST_FILE2, O_RDONLY); ASSERT_LT(fd2, 0); - ASSERT_NE(errno, 0); + ASSERT_NE(libc_errno, 0); - errno = 0; + libc_errno = 0; ASSERT_THAT(__llvm_libc::close(fd1), Succeeds(0)); fd2 = __llvm_libc::open(TEST_FILE2, O_RDONLY); ASSERT_GT(fd2, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); fd1 = __llvm_libc::open(TEST_FILE1, O_RDONLY); ASSERT_LT(fd1, 0); - ASSERT_NE(errno, 0); + ASSERT_NE(libc_errno, 0); - errno = 0; + libc_errno = 0; ASSERT_THAT(__llvm_libc::close(fd2), Succeeds(0)); ASSERT_THAT(__llvm_libc::unlink(TEST_FILE1), Succeeds(0)); diff --git a/libc/test/src/sys/select/select_ui_test.cpp b/libc/test/src/sys/select/select_ui_test.cpp index d290b18654d27..e10d1aa170960 100644 --- a/libc/test/src/sys/select/select_ui_test.cpp +++ b/libc/test/src/sys/select/select_ui_test.cpp @@ -6,11 +6,11 @@ // //===----------------------------------------------------------------------===// +#include "src/errno/libc_errno.h" #include "src/sys/select/select.h" #include "src/unistd/read.h" #include "test/UnitTest/Test.h" -#include #include #include @@ -18,7 +18,7 @@ // Instead, one has to run it manually and press a key on the keyboard // to make the test succeed. TEST(LlvmLibcSelectTest, ReadStdinAfterSelect) { - errno = 0; + libc_errno = 0; constexpr int STDIN_FD = 0; fd_set set; FD_ZERO(&set); diff --git a/libc/test/src/sys/sendfile/sendfile_test.cpp b/libc/test/src/sys/sendfile/sendfile_test.cpp index 95103aac7c103..c77965ea96409 100644 --- a/libc/test/src/sys/sendfile/sendfile_test.cpp +++ b/libc/test/src/sys/sendfile/sendfile_test.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "src/__support/CPP/string_view.h" +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/sendfile/sendfile.h" #include "src/unistd/close.h" @@ -17,7 +18,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include #include @@ -36,20 +36,20 @@ TEST(LlvmLibcSendfileTest, CreateAndTransfer) { constexpr const char *OUT_FILE = "testdata/sendfile_out.test"; const char IN_DATA[] = "sendfile test"; constexpr ssize_t IN_SIZE = ssize_t(sizeof(IN_DATA)); - errno = 0; + libc_errno = 0; int in_fd = __llvm_libc::open(IN_FILE, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(in_fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_EQ(__llvm_libc::write(in_fd, IN_DATA, IN_SIZE), IN_SIZE); ASSERT_THAT(__llvm_libc::close(in_fd), Succeeds(0)); in_fd = __llvm_libc::open(IN_FILE, O_RDONLY); ASSERT_GT(in_fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); int out_fd = __llvm_libc::open(OUT_FILE, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(out_fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ssize_t size = __llvm_libc::sendfile(in_fd, out_fd, nullptr, IN_SIZE); ASSERT_EQ(size, IN_SIZE); ASSERT_THAT(__llvm_libc::close(in_fd), Succeeds(0)); @@ -57,7 +57,7 @@ TEST(LlvmLibcSendfileTest, CreateAndTransfer) { out_fd = __llvm_libc::open(OUT_FILE, O_RDONLY); ASSERT_GT(out_fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); char buf[IN_SIZE]; ASSERT_EQ(IN_SIZE, __llvm_libc::read(out_fd, buf, IN_SIZE)); ASSERT_EQ(cpp::string_view(buf), cpp::string_view(IN_DATA)); diff --git a/libc/test/src/sys/stat/CMakeLists.txt b/libc/test/src/sys/stat/CMakeLists.txt index ef2027dc29168..f21b7a0323a0f 100644 --- a/libc/test/src/sys/stat/CMakeLists.txt +++ b/libc/test/src/sys/stat/CMakeLists.txt @@ -9,9 +9,9 @@ add_libc_unittest( SRCS chmod_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.fcntl.open libc.src.sys.stat.chmod libc.src.unistd.close @@ -25,9 +25,9 @@ add_libc_unittest( SRCS fchmodat_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.fcntl.open libc.src.sys.stat.fchmodat libc.src.unistd.close @@ -41,9 +41,9 @@ add_libc_unittest( SRCS fchmod_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.fcntl.open libc.src.sys.stat.fchmod libc.src.unistd.close @@ -57,9 +57,9 @@ add_libc_unittest( SRCS mkdirat_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.sys.stat.mkdirat libc.src.unistd.rmdir ) @@ -71,9 +71,9 @@ add_libc_unittest( SRCS stat_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.sys.stat.stat libc.src.fcntl.open libc.src.unistd.close @@ -87,9 +87,9 @@ add_libc_unittest( SRCS lstat_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.sys.stat.lstat libc.src.fcntl.open libc.src.unistd.close @@ -103,9 +103,9 @@ add_libc_unittest( SRCS fstat_test.cpp DEPENDS - libc.include.errno libc.include.fcntl libc.include.sys_stat + libc.src.errno.errno libc.src.sys.stat.fstat libc.src.fcntl.open libc.src.unistd.close diff --git a/libc/test/src/sys/stat/chmod_test.cpp b/libc/test/src/sys/stat/chmod_test.cpp index 456b867a2164a..d8da9e390301a 100644 --- a/libc/test/src/sys/stat/chmod_test.cpp +++ b/libc/test/src/sys/stat/chmod_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/stat/chmod.h" #include "src/unistd/close.h" @@ -14,7 +15,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include #include @@ -29,36 +29,36 @@ TEST(LlvmLibcChmodTest, ChangeAndOpen) { constexpr const char *TEST_FILE = "testdata/chmod.test"; const char WRITE_DATA[] = "test data"; constexpr ssize_t WRITE_SIZE = ssize_t(sizeof(WRITE_DATA)); - errno = 0; + libc_errno = 0; int fd = __llvm_libc::open(TEST_FILE, O_APPEND | O_WRONLY); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_EQ(__llvm_libc::write(fd, WRITE_DATA, sizeof(WRITE_DATA)), WRITE_SIZE); ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0)); fd = __llvm_libc::open(TEST_FILE, O_PATH); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0)); EXPECT_THAT(__llvm_libc::chmod(TEST_FILE, S_IRUSR), Succeeds(0)); // Opening for writing should fail. EXPECT_EQ(__llvm_libc::open(TEST_FILE, O_APPEND | O_WRONLY), -1); - EXPECT_NE(errno, 0); - errno = 0; + EXPECT_NE(libc_errno, 0); + libc_errno = 0; // But opening for reading should succeed. fd = __llvm_libc::open(TEST_FILE, O_APPEND | O_RDONLY); EXPECT_GT(fd, 0); - EXPECT_EQ(errno, 0); + EXPECT_EQ(libc_errno, 0); EXPECT_THAT(__llvm_libc::close(fd), Succeeds(0)); EXPECT_THAT(__llvm_libc::chmod(TEST_FILE, S_IRWXU), Succeeds(0)); } TEST(LlvmLibcChmodTest, NonExistentFile) { - errno = 0; + libc_errno = 0; using __llvm_libc::testing::ErrnoSetterMatcher::Fails; ASSERT_THAT(__llvm_libc::chmod("non-existent-file", S_IRUSR), Fails(ENOENT)); - errno = 0; + libc_errno = 0; } diff --git a/libc/test/src/sys/stat/fchmod_test.cpp b/libc/test/src/sys/stat/fchmod_test.cpp index 54d945760865f..c75688bac9d3b 100644 --- a/libc/test/src/sys/stat/fchmod_test.cpp +++ b/libc/test/src/sys/stat/fchmod_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/stat/fchmod.h" #include "src/unistd/close.h" @@ -14,7 +15,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include #include @@ -29,36 +29,36 @@ TEST(LlvmLibcChmodTest, ChangeAndOpen) { constexpr const char *TEST_FILE = "testdata/fchmod.test"; const char WRITE_DATA[] = "test data"; constexpr ssize_t WRITE_SIZE = ssize_t(sizeof(WRITE_DATA)); - errno = 0; + libc_errno = 0; int fd = __llvm_libc::open(TEST_FILE, O_APPEND | O_WRONLY); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_EQ(__llvm_libc::write(fd, WRITE_DATA, sizeof(WRITE_DATA)), WRITE_SIZE); ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0)); fd = __llvm_libc::open(TEST_FILE, O_APPEND | O_WRONLY); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); EXPECT_THAT(__llvm_libc::fchmod(fd, S_IRUSR), Succeeds(0)); ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0)); // Opening for writing should fail. EXPECT_EQ(__llvm_libc::open(TEST_FILE, O_APPEND | O_WRONLY), -1); - EXPECT_NE(errno, 0); - errno = 0; + EXPECT_NE(libc_errno, 0); + libc_errno = 0; // But opening for reading should succeed. fd = __llvm_libc::open(TEST_FILE, O_APPEND | O_RDONLY); EXPECT_GT(fd, 0); - EXPECT_EQ(errno, 0); + EXPECT_EQ(libc_errno, 0); EXPECT_THAT(__llvm_libc::fchmod(fd, S_IRWXU), Succeeds(0)); EXPECT_THAT(__llvm_libc::close(fd), Succeeds(0)); } TEST(LlvmLibcChmodTest, NonExistentFile) { - errno = 0; + libc_errno = 0; ASSERT_EQ(__llvm_libc::fchmod(-1, S_IRUSR), -1); - ASSERT_NE(errno, 0); - errno = 0; + ASSERT_NE(libc_errno, 0); + libc_errno = 0; } diff --git a/libc/test/src/sys/stat/fchmodat_test.cpp b/libc/test/src/sys/stat/fchmodat_test.cpp index 109a162b8466f..fd2a053d12336 100644 --- a/libc/test/src/sys/stat/fchmodat_test.cpp +++ b/libc/test/src/sys/stat/fchmodat_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/stat/fchmodat.h" #include "src/unistd/close.h" @@ -14,7 +15,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include #include @@ -31,29 +31,29 @@ TEST(LlvmLibcFchmodatTest, ChangeAndOpen) { constexpr const char *TEST_FILE_BASENAME = "fchmodat.test"; const char WRITE_DATA[] = "fchmodat test"; constexpr ssize_t WRITE_SIZE = ssize_t(sizeof(WRITE_DATA)); - errno = 0; + libc_errno = 0; int fd = __llvm_libc::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_EQ(__llvm_libc::write(fd, WRITE_DATA, sizeof(WRITE_DATA)), WRITE_SIZE); ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0)); int dirfd = __llvm_libc::open(TEST_DIR, O_DIRECTORY); ASSERT_GT(dirfd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); EXPECT_THAT(__llvm_libc::fchmodat(dirfd, TEST_FILE_BASENAME, S_IRUSR, 0), Succeeds(0)); // Opening for writing should fail. EXPECT_EQ(__llvm_libc::open(TEST_FILE, O_APPEND | O_WRONLY), -1); - EXPECT_NE(errno, 0); - errno = 0; + EXPECT_NE(libc_errno, 0); + libc_errno = 0; // But opening for reading should succeed. fd = __llvm_libc::open(TEST_FILE, O_APPEND | O_RDONLY); EXPECT_GT(fd, 0); - EXPECT_EQ(errno, 0); + EXPECT_EQ(libc_errno, 0); EXPECT_THAT(__llvm_libc::close(fd), Succeeds(0)); EXPECT_THAT(__llvm_libc::fchmodat(dirfd, TEST_FILE_BASENAME, S_IRWXU, 0), @@ -63,9 +63,9 @@ TEST(LlvmLibcFchmodatTest, ChangeAndOpen) { } TEST(LlvmLibcFchmodatTest, NonExistentFile) { - errno = 0; + libc_errno = 0; using __llvm_libc::testing::ErrnoSetterMatcher::Fails; ASSERT_THAT(__llvm_libc::fchmodat(AT_FDCWD, "non-existent-file", S_IRUSR, 0), Fails(ENOENT)); - errno = 0; + libc_errno = 0; } diff --git a/libc/test/src/sys/stat/fstat_test.cpp b/libc/test/src/sys/stat/fstat_test.cpp index 6db0d653fb607..66d9d3c83f908 100644 --- a/libc/test/src/sys/stat/fstat_test.cpp +++ b/libc/test/src/sys/stat/fstat_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/stat/fstat.h" #include "src/unistd/close.h" @@ -14,7 +15,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include #include @@ -27,11 +27,11 @@ TEST(LlvmLibcFStatTest, CreatAndReadMode) { // make it readonly using chmod. We test that chmod actually succeeded by // trying to open the file for writing and failing. constexpr const char *TEST_FILE = "testdata/fstat.test"; - errno = 0; + libc_errno = 0; int fd = __llvm_libc::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); struct stat statbuf; ASSERT_THAT(__llvm_libc::fstat(fd, &statbuf), Succeeds(0)); @@ -43,9 +43,9 @@ TEST(LlvmLibcFStatTest, CreatAndReadMode) { } TEST(LlvmLibcFStatTest, NonExistentFile) { - errno = 0; + libc_errno = 0; using __llvm_libc::testing::ErrnoSetterMatcher::Fails; struct stat statbuf; ASSERT_THAT(__llvm_libc::fstat(-1, &statbuf), Fails(EBADF)); - errno = 0; + libc_errno = 0; } diff --git a/libc/test/src/sys/stat/mkdirat_test.cpp b/libc/test/src/sys/stat/mkdirat_test.cpp index 2e742009a0b19..7f302a41b54b2 100644 --- a/libc/test/src/sys/stat/mkdirat_test.cpp +++ b/libc/test/src/sys/stat/mkdirat_test.cpp @@ -12,7 +12,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include TEST(LlvmLibcMkdiratTest, CreateAndRemove) { diff --git a/libc/test/src/sys/stat/stat_test.cpp b/libc/test/src/sys/stat/stat_test.cpp index ba6e302465627..0a3eb3e070a15 100644 --- a/libc/test/src/sys/stat/stat_test.cpp +++ b/libc/test/src/sys/stat/stat_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "src/errno/libc_errno.h" #include "src/fcntl/open.h" #include "src/sys/stat/stat.h" #include "src/unistd/close.h" @@ -14,7 +15,6 @@ #include "test/UnitTest/Test.h" #include "utils/testutils/FDReader.h" -#include #include #include @@ -27,11 +27,11 @@ TEST(LlvmLibcStatTest, CreatAndReadMode) { // make it readonly using chmod. We test that chmod actually succeeded by // trying to open the file for writing and failing. constexpr const char *TEST_FILE = "testdata/stat.test"; - errno = 0; + libc_errno = 0; int fd = __llvm_libc::open(TEST_FILE, O_CREAT | O_WRONLY, S_IRWXU); ASSERT_GT(fd, 0); - ASSERT_EQ(errno, 0); + ASSERT_EQ(libc_errno, 0); ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0)); struct stat statbuf; @@ -43,9 +43,9 @@ TEST(LlvmLibcStatTest, CreatAndReadMode) { } TEST(LlvmLibcStatTest, NonExistentFile) { - errno = 0; + libc_errno = 0; using __llvm_libc::testing::ErrnoSetterMatcher::Fails; struct stat statbuf; ASSERT_THAT(__llvm_libc::stat("non-existent-file", &statbuf), Fails(ENOENT)); - errno = 0; + libc_errno = 0; }