Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorMichael Jones <michaelrj@google.com>2022-10-11 01:48:18 +0300
committerMichael Jones <michaelrj@google.com>2022-10-11 01:49:48 +0300
commitaec239cdb885feb98a5bbd7240df0c8b4aac8245 (patch)
tree720d3ddedfdc81ccdb81cac18471966ebe2d8c9a /libc
parentd325d2b407fcb7f37230b86fb291ef777497137d (diff)
[libc] reset errno in isatty tests
Errno wasn't getting reset between tests, causing cascading failures. Differential Revision: https://reviews.llvm.org/D135627
Diffstat (limited to 'libc')
-rw-r--r--libc/test/src/unistd/isatty_test.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libc/test/src/unistd/isatty_test.cpp b/libc/test/src/unistd/isatty_test.cpp
index 79e0e0eb1467..77680ad55110 100644
--- a/libc/test/src/unistd/isatty_test.cpp
+++ b/libc/test/src/unistd/isatty_test.cpp
@@ -20,6 +20,7 @@ using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
TEST(LlvmLibcIsATTYTest, StdInOutTests) {
// If stdin is connected to a terminal, assume that all of the standard i/o
// fds are.
+ errno = 0;
if (__llvm_libc::isatty(0)) {
EXPECT_THAT(__llvm_libc::isatty(0), Succeeds(1)); // stdin
EXPECT_THAT(__llvm_libc::isatty(1), Succeeds(1)); // stdout
@@ -32,11 +33,13 @@ TEST(LlvmLibcIsATTYTest, StdInOutTests) {
}
TEST(LlvmLibcIsATTYTest, BadFdTest) {
+ errno = 0;
EXPECT_THAT(__llvm_libc::isatty(-1), Fails(EBADF, 0)); // invalid fd
}
TEST(LlvmLibcIsATTYTest, DevTTYTest) {
constexpr const char *TTY_FILE = "/dev/tty";
+ errno = 0;
int fd = __llvm_libc::open(TTY_FILE, O_RDONLY);
if (fd > 0) {
ASSERT_EQ(errno, 0);
@@ -47,6 +50,7 @@ TEST(LlvmLibcIsATTYTest, DevTTYTest) {
TEST(LlvmLibcIsATTYTest, FileTest) {
constexpr const char *TEST_FILE = "testdata/isatty.test";
+ errno = 0;
int fd = __llvm_libc::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);
ASSERT_EQ(errno, 0);
ASSERT_GT(fd, 0);