Documentation
¶
Overview ¶
Package ptytest opens a pseudo-terminal for tests, with the standard library alone: /dev/ptmx and the platform's grant and unlock requests, no module (spc-2610030911534855, B6). It is a test helper: no production package imports it. The answer loop's restore tests run a child on the terminal end and read its attributes before and after; guided connect's hidden key read (spc-2610031241482088, TestHiddenKeyRestoresTerminalOnInterrupt) reuses it.
Both ends are opened blocking and outside the runtime's poller, so a child handed the terminal end inherits an ordinary blocking descriptor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Same ¶
Same reports whether two sets of terminal attributes are the same, the kernel's PENDIN bit aside: a BSD kernel sets it whenever canonical mode is entered again, to mark input for retyping, so a terminal restored exactly can read back with it set.
Types ¶
type Pty ¶
Pty is one pseudo-terminal: Master is the controlling end a test types into and reads the child's output from, Terminal the end a child takes as its stdin, stdout and stderr.
func Open ¶
Open opens a pseudo-terminal, sizes it cols by rows, and starts draining the master end into a buffer Output and WaitFor read, so a child never blocks on a full terminal. Both ends are closed when the test ends.
func (*Pty) Close ¶
func (p *Pty) Close()
Close closes the terminal end, then the master end, which ends the drain.
func (*Pty) Settled ¶
Settled is the output once it has settled: the kernel holds no byte for the master end the drain has not read (unread), and neither that nor the output has changed for quiet, watched from the call on. A check that something did NOT reach the terminal reads this, never Output, since a read taken before the drain has read the child's last bytes passes falsely. The quiet window also covers a chunk the drain has read and not yet appended, and bytes the kernel has not yet queued for the master end. It fails the test when the output has not settled within settleDeadline. A check that something DID reach the terminal waits for it with WaitFor instead.