2 Test that 'stty -a' displays the same output before and after running the lldb command.
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
13 class TestSTTYBeforeAndAfter(TestBase
):
15 def classCleanup(cls
):
16 """Cleanup the test byproducts."""
17 cls
.RemoveTempFile("child_send1.txt")
18 cls
.RemoveTempFile("child_read1.txt")
19 cls
.RemoveTempFile("child_send2.txt")
20 cls
.RemoveTempFile("child_read2.txt")
23 hostoslist
=["windows"],
24 bugnumber
="llvm.org/pr22274: need a pexpect replacement for windows",
27 def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self
):
28 """Test that 'stty -a' displays the same output before and after running the lldb command."""
31 if not which("expect"):
32 self
.skipTest("The 'expect' program cannot be located, skip the test")
35 expect_prompt
= "expect[0-9.]+> "
36 # The default lldb prompt.
37 lldb_prompt
= "(lldb) "
39 # So that the child gets torn down after the test.
40 self
.child
= pexpect
.spawnu("expect")
43 child
.expect(expect_prompt
)
46 child
.logfile
= sys
.stdout
48 if self
.platformIsDarwin():
49 child
.sendline("set env(TERM) xterm")
51 child
.sendline("set env(TERM) vt100")
52 child
.expect(expect_prompt
)
53 child
.sendline("puts $env(TERM)")
54 child
.expect(expect_prompt
)
56 # Turn on loggings for input/output to/from the child.
57 child
.logfile_send
= child_send1
= io
.StringIO()
58 child
.logfile_read
= child_read1
= io
.StringIO()
59 child
.sendline("stty -a")
60 child
.expect(expect_prompt
)
62 # Now that the stage1 logging is done, restore logfile to None to
63 # stop further logging.
64 child
.logfile_send
= None
65 child
.logfile_read
= None
67 # Invoke the lldb command.
68 child
.sendline(lldbtest_config
.lldbExec
)
69 child
.expect_exact(lldb_prompt
)
72 child
.sendline("quit")
73 child
.expect(expect_prompt
)
75 child
.logfile_send
= child_send2
= io
.StringIO()
76 child
.logfile_read
= child_read2
= io
.StringIO()
77 child
.sendline("stty -a")
78 child
.expect(expect_prompt
)
80 child
.sendline("exit")
82 # Now that the stage2 logging is done, restore logfile to None to
83 # stop further logging.
84 child
.logfile_send
= None
85 child
.logfile_read
= None
88 print("\n\nContents of child_send1:")
89 print(child_send1
.getvalue())
90 print("\n\nContents of child_read1:")
91 print(child_read1
.getvalue())
92 print("\n\nContents of child_send2:")
93 print(child_send2
.getvalue())
94 print("\n\nContents of child_read2:")
95 print(child_read2
.getvalue())
97 stty_output1_lines
= child_read1
.getvalue().splitlines()
98 stty_output2_lines
= child_read2
.getvalue().splitlines()
99 zipped
= list(zip(stty_output1_lines
, stty_output2_lines
))
102 print("tuple->%s" % str(tuple))
103 # Every line should compare equal until the first blank line.
104 if len(tuple[0]) == 0:
106 self
.assertEqual(tuple[0], tuple[1])