Skip to content

RFC: Disable pseudo TTY line mangling for pexpect.spawn using preexec_fn

Igor Ponomarev requested to merge pexpect-tty-disable-mangling into master

By default the pseudo TTY that pexpect uses will have ONLCR and ECHO modes enabled. ONLCR will expand every \n to \r\n. ECHO mode will write back every input.

Those two modes are undesirable as the log output is no longer accurate. Disable them using preexec_fn argument. This argument will execute a function before running the command. The function will disable those terminal modes using the termios Python module.

However, the problem I ran in to are the kernel messages tests. The LinuxKernelMessages.parse_failures uses the patterns that rely on \r but the files used in tests only have \n as line ends. Before because of TTY mangling every \n from the files would be expanded to \r\n thus the LinuxKernelMessages.parse_failures would work but now it will output the pure \n thus parsing kernel messages no longer work. This raises the question what would the output of a real Linux console be and are the files used in the tests accurate representation.

Merge request reports