aboutsummaryrefslogtreecommitdiff
path: root/bin/sh/tests
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2020-05-23 17:01:45 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2021-09-24 18:34:54 +0000
commite31fb97148f7a392aaf6cc84579a232f2969b9d1 (patch)
tree2730eede96b044c794007a751b77c08eca66f31a /bin/sh/tests
parent0389e9be63c5e24ecedbb366c5682ddc2ff4de60 (diff)
downloadsrc-e31fb97148f7a392aaf6cc84579a232f2969b9d1.tar.gz
src-e31fb97148f7a392aaf6cc84579a232f2969b9d1.zip
read builtin: Empty variables on timeout
This matches how a non-timeout error is handled. Reviewed by: jilles MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31876
Diffstat (limited to 'bin/sh/tests')
-rw-r--r--bin/sh/tests/builtins/Makefile2
-rw-r--r--bin/sh/tests/builtins/read10.08
-rw-r--r--bin/sh/tests/builtins/read11.017
3 files changed, 27 insertions, 0 deletions
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
index 197d735920e6..f9b464a6da4b 100644
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -141,6 +141,8 @@ ${PACKAGE}FILES+= read6.0
${PACKAGE}FILES+= read7.0
${PACKAGE}FILES+= read8.0
${PACKAGE}FILES+= read9.0
+${PACKAGE}FILES+= read10.0
+${PACKAGE}FILES+= read11.0
${PACKAGE}FILES+= return1.0
${PACKAGE}FILES+= return2.1
${PACKAGE}FILES+= return3.1
diff --git a/bin/sh/tests/builtins/read10.0 b/bin/sh/tests/builtins/read10.0
new file mode 100644
index 000000000000..5fc19896390a
--- /dev/null
+++ b/bin/sh/tests/builtins/read10.0
@@ -0,0 +1,8 @@
+
+set -e
+
+v=original_value
+r=0
+read v < /dev/null || r=$?
+[ "$r" -eq 1 ]
+[ -z "$v" ]
diff --git a/bin/sh/tests/builtins/read11.0 b/bin/sh/tests/builtins/read11.0
new file mode 100644
index 000000000000..c75ed9c92a83
--- /dev/null
+++ b/bin/sh/tests/builtins/read11.0
@@ -0,0 +1,17 @@
+
+set -e
+
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
+trap 'rm -rf "$T"' 0
+cd $T
+mkfifo fifo1
+# Open fifo1 for writing and then read block on a dummy fifo
+{ mkfifo fifo2; read dummy <fifo2; } >fifo1 &
+# Wait for the child to open fifo1 for writing
+exec 3<fifo1
+v=original_value
+r=0
+read -t 0 v <&3 || r=$?
+kill -TERM "$!" || :
+{ [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = ALRM ]; } || exit
+[ -z "$v" ]