sh/tests: Cut down builtins/read12.0 by 2 seconds

Since the test assumes a 250 ms response time, there is no need to delay
for 3 seconds. Instead, delay for the minimum possible 1 second.

Also, fix some assertions in builtins/read11.0 and builtins/read12.0. If
`set -e` is in effect, `foo` in `foo && bar` is considered tested and
therefore a failure does not cause the shell to exit.

Reviewed by:	bdrewery
Differential Revision:	https://reviews.freebsd.org/D55191
This commit is contained in:
Jilles Tjoelker
2026-05-23 21:47:15 +02:00
parent 1dbc104148
commit 1df431576f
2 changed files with 10 additions and 7 deletions
+2 -1
View File
@@ -27,6 +27,7 @@ ts=$(date +%s%3N)
read -t 0 v <&3 || r=$?
te=$(date +%s%3N)
kill -TERM "$!" || :
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = ALRM ]
[ "$r" -gt 128 ]
[ "$(kill -l "$r")" = ALRM ]
[ $((te-ts)) -lt 250 ]
[ -z "$v" ]
+8 -6
View File
@@ -1,5 +1,5 @@
# Verify that `read -t 3 v` succeeds immediately if input is available
# and times out after 3 s if not
# Verify that `read -t 1 v` succeeds immediately if input is available
# and times out after 1 s if not
set -e
@@ -15,7 +15,7 @@ exec 3<fifo1
v=original_value
r=0
ts=$(date +%s%3N)
read -t 3 v <&3 || r=$?
read -t 1 v <&3 || r=$?
te=$(date +%s%3N)
[ "$r" -eq 0 ]
[ $((te-ts)) -lt 250 ]
@@ -24,9 +24,11 @@ te=$(date +%s%3N)
v=original_value
r=0
ts=$(date +%s%3N)
read -t 3 v <&3 || r=$?
read -t 1 v <&3 || r=$?
te=$(date +%s%3N)
kill -TERM "$!" || :
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = ALRM ]
[ $((te-ts)) -gt 3000 ] && [ $((te-ts)) -lt 3250 ]
[ "$r" -gt 128 ]
[ "$(kill -l "$r")" = ALRM ]
[ $((te-ts)) -ge 1000 ]
[ $((te-ts)) -lt 1250 ]
[ -z "$v" ]