summaryrefslogtreecommitdiffstats
path: root/tests.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-01-31 23:46:56 -0500
committerTavian Barnes <tavianator@tavianator.com>2019-02-01 12:50:29 -0500
commitaa5f0f5745e4e7392c078d1fe28825c941f52f7c (patch)
tree897376cebf759a6e90c4b94f7b3dd5fe3a42025a /tests.sh
parent02132c2efb6daa213aa07b805ccb0c20241ca2f7 (diff)
downloadbfs-aa5f0f5745e4e7392c078d1fe28825c941f52f7c.tar.xz
main: Fix closed standard stream handling
bfs >&- should complain about a missing file descriptor, rather than silently succeeding.
Diffstat (limited to 'tests.sh')
-rwxr-xr-xtests.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests.sh b/tests.sh
index 775a254..302a4c2 100755
--- a/tests.sh
+++ b/tests.sh
@@ -290,6 +290,11 @@ posix_tests=(
test_user_name
test_user_id
+ # Closed file descriptors
+ test_closed_stdin
+ test_closed_stdout
+ test_closed_stderr
+
# PATH_MAX handling
test_deep
@@ -385,8 +390,10 @@ bsd_tests=(
test_nouser
test_ok_stdin
+ test_ok_closed_stdin
test_okdir_stdin
+ test_okdir_closed_stdin
test_perm_000_plus
test_perm_222_plus
@@ -525,8 +532,10 @@ gnu_tests=(
test_nouser
+ test_ok_closed_stdin
test_ok_nothing
+ test_okdir_closed_stdin
test_okdir_plus_semicolon
test_perm_000_slash
@@ -1929,6 +1938,26 @@ function test_fprint_error() {
fi
}
+function test_closed_stdin() {
+ bfs_diff basic <&-
+}
+
+function test_ok_closed_stdin() {
+ bfs_diff basic -ok echo \; <&- 2>/dev/null
+}
+
+function test_okdir_closed_stdin() {
+ bfs_diff basic -okdir echo {} \; <&- 2>/dev/null
+}
+
+function test_closed_stdout() {
+ ! invoke_bfs basic >&- 2>/dev/null
+}
+
+function test_closed_stderr() {
+ ! invoke_bfs basic >&- 2>&-
+}
+
if [ -t 1 -a ! "$VERBOSE" ]; then
in_place=yes
fi