[libc-commits] [PATCH] D135627: [libc] reset errno in isatty tests

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Oct 10 15:50:04 PDT 2022


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaec239cdb885: [libc] reset errno in isatty tests (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135627/new/

https://reviews.llvm.org/D135627

Files:
  libc/test/src/unistd/isatty_test.cpp


Index: libc/test/src/unistd/isatty_test.cpp
===================================================================
--- libc/test/src/unistd/isatty_test.cpp
+++ libc/test/src/unistd/isatty_test.cpp
@@ -20,6 +20,7 @@
 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, 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, 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135627.466655.patch
Type: text/x-patch
Size: 1125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20221010/ef6bbdee/attachment.bin>


More information about the libc-commits mailing list