5 atf_set
"descr" "Basic tests on pwait(1) utility"
23 timeout
--preserve-status 15 pwait
$p1 $p5 $p10
27 -e inline
:"kill: $p1: No such process\n" \
33 -e inline
:"kill: $p5: No such process\n" \
39 -e inline
:"kill: $p10: No such process\n" \
47 kill $p1 $p5 $p10 >/dev
/null
2>&1
48 wait $p1 $p5 $p10 >/dev
/null
2>&1
51 atf_test_case time_unit
54 atf_set
"descr" "Test parsing the timeout unit and value"
63 -e inline
:"pwait: timeout unit\n" \
65 timeout
--preserve-status 2 pwait
-t 1d
$init
69 -e inline
:"pwait: timeout unit\n" \
71 timeout
--preserve-status 2 pwait
-t 1d
$init
75 -e inline
:"pwait: timeout value\n" \
77 timeout
--preserve-status 2 pwait
-t -1 $init
81 -e inline
:"pwait: timeout value\n" \
83 timeout
--preserve-status 2 pwait
-t 100000001 $init
85 # These long duration cases are expected to timeout from the
86 # timeout utility rather than pwait -t.
91 timeout
--preserve-status 2 pwait
-t 100000000 $init
97 timeout
--preserve-status 2 pwait
-t 1h
$init
103 timeout
--preserve-status 2 pwait
-t 1.5h
$init
109 timeout
--preserve-status 2 pwait
-t 1m
$init
115 timeout
--preserve-status 2 pwait
-t 1.5m
$init
121 timeout
--preserve-status 2 pwait
-t 0 $init
123 # The rest are fast enough that pwait -t is expected to trigger
129 timeout
--preserve-status 2 pwait
-t 1s
$init
135 timeout
--preserve-status 2 pwait
-t 1.5s
$init
141 timeout
--preserve-status 2 pwait
-t 1 $init
147 timeout
--preserve-status 2 pwait
-t 1.5 $init
153 timeout
--preserve-status 2 pwait
-t 0.5 $init
156 atf_test_case timeout_trigger_timeout
157 timeout_trigger_timeout_head
()
159 atf_set
"descr" "Test that exceeding the timeout is detected"
162 timeout_trigger_timeout_body
()
171 timeout
--preserve-status 6.5 pwait
-t 5 $p10
174 timeout_trigger_timeout_cleanup
()
176 kill $p10 >/dev
/null
2>&1
177 wait $p10 >/dev
/null
2>&1
180 atf_test_case timeout_no_timeout
181 timeout_no_timeout_head
()
183 atf_set
"descr" "Test that not exceeding the timeout continues to wait"
186 timeout_no_timeout_body
()
195 timeout
--preserve-status 11.5 pwait
-t 12 $p10
198 timeout_no_timeout_cleanup
()
200 kill $p10 >/dev
/null
2>&1
201 wait $p10 >/dev
/null
2>&1
204 atf_test_case timeout_many
207 atf_set
"descr" "Test timeout on many processes"
225 timeout
--preserve-status 7.5 pwait
-t 6 $p1 $p5 $p10
228 timeout_many_cleanup
()
230 kill $p1 $p5 $p10 >/dev
/null
2>&1
231 wait $p1 $p5 $p10 >/dev
/null
2>&1
234 atf_test_case or_flag
237 atf_set
"descr" "Test OR flag"
252 -o inline
:"$p2: exited with status 0.\n" \
255 timeout
--preserve-status 15 pwait
-o -v $p2 $p4 $p6
259 -e inline
:"pwait: $p2: No such process\n" \
261 timeout
--preserve-status 15 pwait
-o $p2 $p4 $p6
267 timeout
--preserve-status 15 pwait
-o $p4 $p6
271 -e inline
:"pwait: $p4: No such process\n" \
273 timeout
--preserve-status 15 pwait
-o $p4 $p6
276 -o inline
:"$p6: exited with status 0.\n" \
279 timeout
--preserve-status 15 pwait
-o -v $p6
283 -e inline
:"pwait: $p6: No such process\n" \
285 timeout
--preserve-status 15 pwait
-o $p6
289 -e inline
:"kill: $p2: No such process\n" \
295 -e inline
:"kill: $p4: No such process\n" \
301 -e inline
:"kill: $p6: No such process\n" \
309 kill $p2 $p4 $p6 >/dev
/null
2>&1
310 wait $p2 $p4 $p6 >/dev
/null
2>&1
313 atf_init_test_cases
()
315 atf_add_test_case basic
316 atf_add_test_case time_unit
317 atf_add_test_case timeout_trigger_timeout
318 atf_add_test_case timeout_no_timeout
319 atf_add_test_case timeout_many
320 atf_add_test_case or_flag