[libc][Obvious] Skip some termios tests when there no is /dev/tty.
authorSiva Chandra Reddy <sivachandra@google.com>
Tue, 18 Oct 2022 20:58:08 +0000 (20:58 +0000)
committerSiva Chandra Reddy <sivachandra@google.com>
Tue, 18 Oct 2022 20:58:50 +0000 (20:58 +0000)
libc/test/src/termios/termios_test.cpp

index beec5ce..19f5f86 100644 (file)
@@ -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);
 }