[Lldb-commits] [lldb] 79bf032 - [lldb testing] Avoid subtle terminfo behavioral differences

David Zarzycki via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 5 07:29:07 PDT 2021


Author: David Zarzycki
Date: 2021-10-05T10:28:02-04:00
New Revision: 79bf032fe103333546fd1d6e14c5ac8905f25c2b

URL: https://github.com/llvm/llvm-project/commit/79bf032fe103333546fd1d6e14c5ac8905f25c2b
DIFF: https://github.com/llvm/llvm-project/commit/79bf032fe103333546fd1d6e14c5ac8905f25c2b.diff

LOG: [lldb testing] Avoid subtle terminfo behavioral differences

The original "arbitrary" changes were causing EINVAL on a Fedora 34 box.

Added: 
    

Modified: 
    lldb/unittests/Host/posix/TerminalTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Host/posix/TerminalTest.cpp b/lldb/unittests/Host/posix/TerminalTest.cpp
index ecdb548021643..37b6b3cf60bff 100644
--- a/lldb/unittests/Host/posix/TerminalTest.cpp
+++ b/lldb/unittests/Host/posix/TerminalTest.cpp
@@ -79,15 +79,9 @@ TEST_F(TerminalTest, SaveRestoreRAII) {
     TerminalState term_state{term};
     terminfo = orig_terminfo;
 
-    // make some arbitrary changes
-    terminfo.c_iflag ^= IGNPAR | INLCR;
-    terminfo.c_oflag ^= OPOST | OCRNL;
-    terminfo.c_cflag ^= PARENB | PARODD;
-    terminfo.c_lflag ^= ICANON | ECHO;
-    terminfo.c_cc[VEOF] ^= 8;
-    terminfo.c_cc[VEOL] ^= 4;
-    cfsetispeed(&terminfo, B9600);
-    cfsetospeed(&terminfo, B9600);
+    // make an arbitrary change
+    cfsetispeed(&terminfo,cfgetispeed(&orig_terminfo) == B9600 ? B4800 : B9600);
+    cfsetospeed(&terminfo,cfgetospeed(&orig_terminfo) == B9600 ? B4800 : B9600);
 
     ASSERT_EQ(tcsetattr(m_pty.GetPrimaryFileDescriptor(), TCSANOW, &terminfo),
               0);
@@ -108,15 +102,9 @@ TEST_F(TerminalTest, SaveRestore) {
   term_state.Save(term, false);
   terminfo = orig_terminfo;
 
-  // make some arbitrary changes
-  terminfo.c_iflag ^= IGNPAR | INLCR;
-  terminfo.c_oflag ^= OPOST | OCRNL;
-  terminfo.c_cflag ^= PARENB | PARODD;
-  terminfo.c_lflag ^= ICANON | ECHO;
-  terminfo.c_cc[VEOF] ^= 8;
-  terminfo.c_cc[VEOL] ^= 4;
-  cfsetispeed(&terminfo, B9600);
-  cfsetospeed(&terminfo, B9600);
+  // make an arbitrary change
+  cfsetispeed(&terminfo, cfgetispeed(&orig_terminfo) == B9600 ? B4800 : B9600);
+  cfsetospeed(&terminfo, cfgetospeed(&orig_terminfo) == B9600 ? B4800 : B9600);
 
   ASSERT_EQ(tcsetattr(m_pty.GetPrimaryFileDescriptor(), TCSANOW, &terminfo), 0);
 


        


More information about the lldb-commits mailing list