aboutsummaryrefslogtreecommitdiff
path: root/tests/tty.test
blob: 5199e6a5e21f88b6abde507c890beff25ec40e0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
source [file dirname [info script]]/testing.tcl

needs cmd {stdout tty}
if {![stdout isatty]} {
    skiptest "  (aio tty)"
}

test tty-1.1 {tty status} {
    set dict [stdout tty]
    dict exists $dict output
} 1

test tty-1.2 {tty bad param} -body {
    stdout tty bad value
} -returnCodes error -result {bad setting "bad": must be baud, data, echo, handshake, input, output, parity, stop, vmin, or vtime}

test tty-1.3 {tty bad baud} -body {
    stdout tty baud 12345
} -returnCodes error -result {bad value for baud: 12345}

test tty-1.4 {tty bad fd} -body {
    set f [open [file tempfile] w]
    $f tty
} -returnCodes error -match regexp -result {^(Inappropriate ioctl for device|Not a tty)$} -cleanup {
    $f close
}


set n 0
foreach {param value} {
    output raw
    input raw
    handshake rtscts
} {
    test tty-1.[incr n] "tty setting $param" -setup {
        set savetty [stdout tty]
    } -body "stdout tty $param $value; dict get \[stdout tty\] $param" \
        -result $value -cleanup {
        stdout tty $savetty
    }
}

set n 0
foreach param {output input handshake baud stop data vmin vtime} {
    test tty-2.[incr n] "tty bad setting $param" -setup {
        set savetty [stdout tty]
    } -body "stdout tty $param bad" \
    -returnCodes error -result "bad value for $param: bad" -cleanup {
        stdout tty $savetty
    }
}

testreport