test(aio,socket,tty): match musl error messages
[jimtcl.git] / tests / tty.test
blob53bea2cb6f1eca0c11f70b60f5cb99b563193e84
1 source [file dirname [info script]]/testing.tcl
3 set havetty 0
4 catch {
5     set havetty [expr {"tty" in [stdout -commands]}]
7 if {!$havetty} {
8     skiptest "  (aio tty)"
11 test tty-1.1 {tty status} {
12     set dict [stdout tty]
13     dict exists $dict output
14 } 1
16 test tty-1.2 {tty bad param} -body {
17     stdout tty bad value
18 } -returnCodes error -result {bad setting "bad": must be baud, data, echo, handshake, input, output, parity, stop, vmin, or vtime}
20 test tty-1.3 {tty bad baud} -body {
21     stdout tty baud 12345
22 } -returnCodes error -result {bad value for baud: 12345}
24 test tty-1.4 {tty bad fd} -body {
25     set f [open [file tempfile] w]
26     $f tty
27 } -returnCodes error -match regexp -result {^(Inappropriate ioctl for device|Not a tty)$} -cleanup {
28     $f close
32 set n 0
33 foreach {param value} {
34     output raw
35     input raw
36     handshake rtscts
37 } {
38     test tty-1.[incr n] "tty setting $param" -setup {
39         set savetty [stdout tty]
40     } -body "stdout tty $param $value; dict get \[stdout tty\] $param" \
41         -result $value -cleanup {
42         stdout tty $savetty
43     }
46 set n 0
47 foreach param {output input handshake baud stop data vmin vtime} {
48     test tty-2.[incr n] "tty bad setting $param" -setup {
49         set savetty [stdout tty]
50     } -body "stdout tty $param bad" \
51     -returnCodes error -result "bad value for $param: bad" -cleanup {
52         stdout tty $savetty
53     }
56 testreport