Skip to content

Commit 1df4315

Browse files
committed
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
1 parent 1dbc104 commit 1df4315

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

bin/sh/tests/builtins/read11.0

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ts=$(date +%s%3N)
2727
read -t 0 v <&3 || r=$?
2828
te=$(date +%s%3N)
2929
kill -TERM "$!" || :
30-
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = ALRM ]
30+
[ "$r" -gt 128 ]
31+
[ "$(kill -l "$r")" = ALRM ]
3132
[ $((te-ts)) -lt 250 ]
3233
[ -z "$v" ]

bin/sh/tests/builtins/read12.0

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Verify that `read -t 3 v` succeeds immediately if input is available
2-
# and times out after 3 s if not
1+
# Verify that `read -t 1 v` succeeds immediately if input is available
2+
# and times out after 1 s if not
33

44
set -e
55

@@ -15,7 +15,7 @@ exec 3<fifo1
1515
v=original_value
1616
r=0
1717
ts=$(date +%s%3N)
18-
read -t 3 v <&3 || r=$?
18+
read -t 1 v <&3 || r=$?
1919
te=$(date +%s%3N)
2020
[ "$r" -eq 0 ]
2121
[ $((te-ts)) -lt 250 ]
@@ -24,9 +24,11 @@ te=$(date +%s%3N)
2424
v=original_value
2525
r=0
2626
ts=$(date +%s%3N)
27-
read -t 3 v <&3 || r=$?
27+
read -t 1 v <&3 || r=$?
2828
te=$(date +%s%3N)
2929
kill -TERM "$!" || :
30-
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = ALRM ]
31-
[ $((te-ts)) -gt 3000 ] && [ $((te-ts)) -lt 3250 ]
30+
[ "$r" -gt 128 ]
31+
[ "$(kill -l "$r")" = ALRM ]
32+
[ $((te-ts)) -ge 1000 ]
33+
[ $((te-ts)) -lt 1250 ]
3234
[ -z "$v" ]

0 commit comments

Comments
 (0)