[libc-commits] [PATCH] D135626: [libc] handle case where /dev/tty doesn't exist

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Oct 10 15:41:06 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 rG707996e486df: [libc] handle case where /dev/tty doesn't exist (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135626

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
@@ -38,10 +38,11 @@
 TEST(LlvmLibcIsATTYTest, DevTTYTest) {
   constexpr const char *TTY_FILE = "/dev/tty";
   int fd = __llvm_libc::open(TTY_FILE, O_RDONLY);
-  ASSERT_EQ(errno, 0);
-  ASSERT_GT(fd, 0);
-  EXPECT_THAT(__llvm_libc::isatty(fd), Succeeds(1));
-  ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0));
+  if (fd > 0) {
+    ASSERT_EQ(errno, 0);
+    EXPECT_THAT(__llvm_libc::isatty(fd), Succeeds(1));
+    ASSERT_THAT(__llvm_libc::close(fd), Succeeds(0));
+  }
 }
 
 TEST(LlvmLibcIsATTYTest, FileTest) {


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


More information about the libc-commits mailing list