1 source [file dirname [info script]]/testing.tcl
5 testConstraint try [expr {[info commands try] ne ""}]
7 test signal-1.1 "catch/throw" {
10 set rc [catch -signal {
15 list [info returncode $rc] $result $x
18 test signal-1.2 "catch/kill" {
21 set rc [catch -signal {
26 list [info returncode $rc] $result $x
29 test signal-1.3 "catch/alarm" {
32 set rc [catch -signal {
38 list [info returncode $rc] $result $x
41 test signal-1.4 "multiple signals before catch" {
42 signal handle ALRM INT
47 set rc [catch -signal {
48 # Doesn't not execute because signals already active
51 signal default ALRM INT
52 list [info returncode $rc] [lsort $result] $x
53 } {signal {SIGALRM SIGINT} 1}
55 test signal-1.5 "ignored signals" {
61 # Send an ignored signal
68 signal default INT TERM
69 list [lsort $result] $x
72 test signal-1.6 "check ignored signals" {
73 list [signal check SIGINT] [signal check]
76 test signal-1.7 "clearing ignored signals" {
81 test signal-1.8 "try/signal" try {
85 foreach i [range 10] {
95 list [expr {$i in {2 3 4}}] $msg
98 test signal-1.9 {throw an ignored signal} {
101 signal check -clear SIGTERM
104 test signal-1.10 {throw with no signal} try {
105 # With no arg, signal throw means signal throw SIGINT
113 test signal-2.1 {bad signal} -body {
114 signal handle NONEXISTENT
115 } -returnCodes error -result {unknown signal NONEXISTENT}
117 test signal-2.2 {bad signal} -body {
119 } -returnCodes error -result {unknown signal 999999}
121 test signal-2.3 {signal by number} {
126 test signal-2.4 {signal block} {
129 signal default SIGINT
132 test signal-2.5 {signal check invalid} -body {
133 signal check NONEXISTENT
134 } -returnCodes error -result {unknown signal NONEXISTENT}
136 test signal-2.6 {signal check invalid num} -body {
138 } -returnCodes error -result {unknown signal 999999}
140 test signal-2.7 {signal throw invalid} -body {
141 signal throw NONEXISTENT
142 } -returnCodes error -result {unknown signal NONEXISTENT}
144 test signal-2.8 {signal throw invalid num} -body {
146 } -returnCodes error -result {unknown signal 999999}
148 test signal-2.9 {signal list} {
149 expr {"SIGINT" in [signal default]}
152 test alarm-1.1 {alarm usage} -body {
154 } -returnCodes error -result {wrong # args: should be "alarm seconds"}
156 test alarm-1.2 {alarm usage} -body {
158 } -returnCodes error -result {wrong # args: should be "alarm seconds"}
160 test alarm-1.3 {alarm usage} -body {
162 } -returnCodes error -result {expected floating-point number but got "badnum"}
164 test alarm-1.4 {alarm seconds} {
169 test sleep-1.1 {sleep usage} -body {
171 } -returnCodes error -result {wrong # args: should be "sleep seconds"}
173 test sleep-1.2 {sleep usage} -body {
175 } -returnCodes error -result {wrong # args: should be "sleep seconds"}
177 test sleep-1.3 {sleep usage} -body {
179 } -returnCodes error -result {expected floating-point number but got "badnum"}
181 test kill-1.1 {kill usage} -body {
183 } -returnCodes error -result {wrong # args: should be "kill ?SIG|-0? pid"}
185 test kill-1.2 {kill usage} -body {
187 } -returnCodes error -result {wrong # args: should be "kill ?SIG|-0? pid"}
189 test kill-1.3 {kill bad signal} -body {
190 kill NONEXISTENT [pid]
191 } -returnCodes error -result {unknown signal NONEXISTENT}
193 test kill-1.4 {kill -0} {
197 test kill-1.5 {kill 0 pid} {
201 test kill-1.6 {kill to invalid process} -body {
203 } -returnCodes error -result {kill: Failed to deliver signal}