[libc-commits] [libc] 18daa82 - [libc][Obvious] Skip some termios tests when there no is /dev/tty.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Tue Oct 18 14:00:11 PDT 2022


Author: Siva Chandra Reddy
Date: 2022-10-18T20:58:50Z
New Revision: 18daa8255a1598cc2707b492a7a5559be6aba84e

URL: https://github.com/llvm/llvm-project/commit/18daa8255a1598cc2707b492a7a5559be6aba84e
DIFF: https://github.com/llvm/llvm-project/commit/18daa8255a1598cc2707b492a7a5559be6aba84e.diff

LOG: [libc][Obvious] Skip some termios tests when there no is /dev/tty.

Added: 
    

Modified: 
    libc/test/src/termios/termios_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/termios/termios_test.cpp b/libc/test/src/termios/termios_test.cpp
index beec5cedd2356..19f5f86c4b062 100644
--- a/libc/test/src/termios/termios_test.cpp
+++ b/libc/test/src/termios/termios_test.cpp
@@ -46,16 +46,19 @@ TEST(LlvmLibcTermiosTest, GetAttrSmokeTest) {
   struct termios t;
   errno = 0;
   int fd = __llvm_libc::open("/dev/tty", O_RDONLY);
+  if (fd < 0)
+    return; // When /dev/tty is not available, no point continuing.
   ASSERT_EQ(errno, 0);
-  ASSERT_GT(fd, 0);
   ASSERT_THAT(__llvm_libc::tcgetattr(fd, &t), Succeeds(0));
   ASSERT_EQ(__llvm_libc::close(fd), 0);
 }
 
 TEST(LlvmLibcTermiosTest, TcGetSidSmokeTest) {
+  errno = 0;
   int fd = __llvm_libc::open("/dev/tty", O_RDONLY);
+  if (fd < 0)
+    return; // When /dev/tty is not available, no point continuing.
   ASSERT_EQ(errno, 0);
-  ASSERT_GT(fd, 0);
   ASSERT_GT(__llvm_libc::tcgetsid(fd), pid_t(0));
   ASSERT_EQ(__llvm_libc::close(fd), 0);
 }


        


More information about the libc-commits mailing list