From c4cf542c575068d55368e771abf6c358bfebf5d3 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 2 Oct 2016 17:55:51 +0200 Subject: sh testsuite: create hush-redir/* and move files around Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-redir/redir1.right | 12 ++++ shell/ash_test/ash-redir/redir1.tests | 40 ++++++++++++ shell/ash_test/ash-redir/redir_script.right | 1 + shell/ash_test/ash-redir/redir_script.tests | 29 +++++++++ shell/ash_test/ash-redir/redir_space.right | 3 + shell/ash_test/ash-redir/redir_space.tests | 6 ++ shell/hush_test/hush-misc/redir1.right | 12 ---- shell/hush_test/hush-misc/redir1.tests | 40 ------------ shell/hush_test/hush-misc/redir2.right | 1 - shell/hush_test/hush-misc/redir2.tests | 2 - shell/hush_test/hush-misc/redir3.right | 14 ----- shell/hush_test/hush-misc/redir3.tests | 9 --- shell/hush_test/hush-misc/redir4.right | 18 ------ shell/hush_test/hush-misc/redir4.tests | 85 -------------------------- shell/hush_test/hush-misc/redir5.right | 4 -- shell/hush_test/hush-misc/redir5.tests | 13 ---- shell/hush_test/hush-misc/redir6.right | 4 -- shell/hush_test/hush-misc/redir6.tests | 5 -- shell/hush_test/hush-misc/redir_script.right | 1 - shell/hush_test/hush-misc/redir_script.tests | 29 --------- shell/hush_test/hush-parsing/redir_space.right | 3 - shell/hush_test/hush-parsing/redir_space.tests | 6 -- shell/hush_test/hush-redir/redir1.right | 12 ++++ shell/hush_test/hush-redir/redir1.tests | 40 ++++++++++++ shell/hush_test/hush-redir/redir2.right | 1 + shell/hush_test/hush-redir/redir2.tests | 2 + shell/hush_test/hush-redir/redir3.right | 14 +++++ shell/hush_test/hush-redir/redir3.tests | 9 +++ shell/hush_test/hush-redir/redir4.right | 18 ++++++ shell/hush_test/hush-redir/redir4.tests | 85 ++++++++++++++++++++++++++ shell/hush_test/hush-redir/redir5.right | 4 ++ shell/hush_test/hush-redir/redir5.tests | 13 ++++ shell/hush_test/hush-redir/redir6.right | 4 ++ shell/hush_test/hush-redir/redir6.tests | 5 ++ shell/hush_test/hush-redir/redir7.right | 3 + shell/hush_test/hush-redir/redir7.tests | 12 ++++ shell/hush_test/hush-redir/redir8.right | 3 + shell/hush_test/hush-redir/redir8.tests | 15 +++++ shell/hush_test/hush-redir/redir9.right | 2 + shell/hush_test/hush-redir/redir9.tests | 4 ++ shell/hush_test/hush-redir/redirA.right | 2 + shell/hush_test/hush-redir/redirA.tests | 11 ++++ shell/hush_test/hush-redir/redir_script.right | 1 + shell/hush_test/hush-redir/redir_script.tests | 29 +++++++++ shell/hush_test/hush-redir/redir_space.right | 3 + shell/hush_test/hush-redir/redir_space.tests | 6 ++ 46 files changed, 389 insertions(+), 246 deletions(-) create mode 100644 shell/ash_test/ash-redir/redir1.right create mode 100755 shell/ash_test/ash-redir/redir1.tests create mode 100644 shell/ash_test/ash-redir/redir_script.right create mode 100755 shell/ash_test/ash-redir/redir_script.tests create mode 100644 shell/ash_test/ash-redir/redir_space.right create mode 100755 shell/ash_test/ash-redir/redir_space.tests delete mode 100644 shell/hush_test/hush-misc/redir1.right delete mode 100755 shell/hush_test/hush-misc/redir1.tests delete mode 100644 shell/hush_test/hush-misc/redir2.right delete mode 100755 shell/hush_test/hush-misc/redir2.tests delete mode 100644 shell/hush_test/hush-misc/redir3.right delete mode 100755 shell/hush_test/hush-misc/redir3.tests delete mode 100644 shell/hush_test/hush-misc/redir4.right delete mode 100755 shell/hush_test/hush-misc/redir4.tests delete mode 100644 shell/hush_test/hush-misc/redir5.right delete mode 100755 shell/hush_test/hush-misc/redir5.tests delete mode 100644 shell/hush_test/hush-misc/redir6.right delete mode 100755 shell/hush_test/hush-misc/redir6.tests delete mode 100644 shell/hush_test/hush-misc/redir_script.right delete mode 100755 shell/hush_test/hush-misc/redir_script.tests delete mode 100644 shell/hush_test/hush-parsing/redir_space.right delete mode 100755 shell/hush_test/hush-parsing/redir_space.tests create mode 100644 shell/hush_test/hush-redir/redir1.right create mode 100755 shell/hush_test/hush-redir/redir1.tests create mode 100644 shell/hush_test/hush-redir/redir2.right create mode 100755 shell/hush_test/hush-redir/redir2.tests create mode 100644 shell/hush_test/hush-redir/redir3.right create mode 100755 shell/hush_test/hush-redir/redir3.tests create mode 100644 shell/hush_test/hush-redir/redir4.right create mode 100755 shell/hush_test/hush-redir/redir4.tests create mode 100644 shell/hush_test/hush-redir/redir5.right create mode 100755 shell/hush_test/hush-redir/redir5.tests create mode 100644 shell/hush_test/hush-redir/redir6.right create mode 100755 shell/hush_test/hush-redir/redir6.tests create mode 100644 shell/hush_test/hush-redir/redir7.right create mode 100755 shell/hush_test/hush-redir/redir7.tests create mode 100644 shell/hush_test/hush-redir/redir8.right create mode 100755 shell/hush_test/hush-redir/redir8.tests create mode 100644 shell/hush_test/hush-redir/redir9.right create mode 100755 shell/hush_test/hush-redir/redir9.tests create mode 100644 shell/hush_test/hush-redir/redirA.right create mode 100755 shell/hush_test/hush-redir/redirA.tests create mode 100644 shell/hush_test/hush-redir/redir_script.right create mode 100755 shell/hush_test/hush-redir/redir_script.tests create mode 100644 shell/hush_test/hush-redir/redir_space.right create mode 100755 shell/hush_test/hush-redir/redir_space.tests (limited to 'shell') diff --git a/shell/ash_test/ash-redir/redir1.right b/shell/ash_test/ash-redir/redir1.right new file mode 100644 index 0000000..15515d1 --- /dev/null +++ b/shell/ash_test/ash-redir/redir1.right @@ -0,0 +1,12 @@ +Test 0: var:ok +File created:ok +Test 1: var:ok +File created:ok +Test 2: var:ok +File created:ok +Test 3: var:ok +File created:ok +Test 4: var:ok +File created:ok +Test 5: var:ok +File created:ok diff --git a/shell/ash_test/ash-redir/redir1.tests b/shell/ash_test/ash-redir/redir1.tests new file mode 100755 index 0000000..ef2fbfb --- /dev/null +++ b/shell/ash_test/ash-redir/redir1.tests @@ -0,0 +1,40 @@ +rm shell_test_$$ 2>/dev/null +var=bad +>shell_test_$$ var=ok +echo "Test 0: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=bad +var=ok >shell_test_$$ +echo "Test 1: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +true | var=bad >shell_test_$$ +echo "Test 2: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=bad +{ var=ok >shell_test_$$; } +echo "Test 3: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +{ var=bad >shell_test_$$; } & +# cant use usleep as it isnt standard in $PATH -- +# we fail when testing busybox compiled solely as "hush" +wait +echo "Test 4: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +( var=bad >shell_test_$$ ) +echo "Test 5: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null diff --git a/shell/ash_test/ash-redir/redir_script.right b/shell/ash_test/ash-redir/redir_script.right new file mode 100644 index 0000000..6694ed3 --- /dev/null +++ b/shell/ash_test/ash-redir/redir_script.right @@ -0,0 +1 @@ +Ok: script fd is not closed diff --git a/shell/ash_test/ash-redir/redir_script.tests b/shell/ash_test/ash-redir/redir_script.tests new file mode 100755 index 0000000..ccc497d --- /dev/null +++ b/shell/ash_test/ash-redir/redir_script.tests @@ -0,0 +1,29 @@ +# Builds a " 3>&- 4>&-" string. +# Note: one of these fds is a directory opened to /proc/self/fd +# for globbing. It is unwanted, but I don't know how to filter it out. +find_fds() { + fds="" + for f in /proc/self/fd/*; do + test "$f" = "/proc/self/fd/0" && continue + test "$f" = "/proc/self/fd/1" && continue + test "$f" = "/proc/self/fd/2" && continue + fds="$fds ${f##*/}>&-" + done +} + +find_fds +fds1="$fds" + +# One of the fds is open to the script body +# Close it while executing something. +eval "find_fds $fds" + +# Shell should not lose that fd. Did it? +find_fds +test x"$fds1" = x"$fds" && { echo "Ok: script fd is not closed"; exit 0; } + +echo "Bug: script fd is closed" +echo "fds1:$fds1" +echo "fds2:$fds" +exit 1 + diff --git a/shell/ash_test/ash-redir/redir_space.right b/shell/ash_test/ash-redir/redir_space.right new file mode 100644 index 0000000..0842952 --- /dev/null +++ b/shell/ash_test/ash-redir/redir_space.right @@ -0,0 +1,3 @@ +z1.tmp: 1 +z2.tmp: 1 +"z1.tmp z2.tmp": TEST 0 diff --git a/shell/ash_test/ash-redir/redir_space.tests b/shell/ash_test/ash-redir/redir_space.tests new file mode 100755 index 0000000..c0b5430 --- /dev/null +++ b/shell/ash_test/ash-redir/redir_space.tests @@ -0,0 +1,6 @@ +v='z1.tmp z2.tmp' +echo TEST >$v +echo 'z1.tmp:' `cat 'z1.tmp' 2>/dev/null; echo $?` +echo 'z2.tmp:' `cat 'z2.tmp' 2>/dev/null; echo $?` +echo '"z1.tmp z2.tmp":' `cat 'z1.tmp z2.tmp' 2>/dev/null; echo $?` +rm z*.tmp diff --git a/shell/hush_test/hush-misc/redir1.right b/shell/hush_test/hush-misc/redir1.right deleted file mode 100644 index 15515d1..0000000 --- a/shell/hush_test/hush-misc/redir1.right +++ /dev/null @@ -1,12 +0,0 @@ -Test 0: var:ok -File created:ok -Test 1: var:ok -File created:ok -Test 2: var:ok -File created:ok -Test 3: var:ok -File created:ok -Test 4: var:ok -File created:ok -Test 5: var:ok -File created:ok diff --git a/shell/hush_test/hush-misc/redir1.tests b/shell/hush_test/hush-misc/redir1.tests deleted file mode 100755 index ef2fbfb..0000000 --- a/shell/hush_test/hush-misc/redir1.tests +++ /dev/null @@ -1,40 +0,0 @@ -rm shell_test_$$ 2>/dev/null -var=bad ->shell_test_$$ var=ok -echo "Test 0: var:$var" -test -f shell_test_$$ && echo "File created:ok" - -rm shell_test_$$ 2>/dev/null -var=bad -var=ok >shell_test_$$ -echo "Test 1: var:$var" -test -f shell_test_$$ && echo "File created:ok" - -rm shell_test_$$ 2>/dev/null -var=ok -true | var=bad >shell_test_$$ -echo "Test 2: var:$var" -test -f shell_test_$$ && echo "File created:ok" - -rm shell_test_$$ 2>/dev/null -var=bad -{ var=ok >shell_test_$$; } -echo "Test 3: var:$var" -test -f shell_test_$$ && echo "File created:ok" - -rm shell_test_$$ 2>/dev/null -var=ok -{ var=bad >shell_test_$$; } & -# cant use usleep as it isnt standard in $PATH -- -# we fail when testing busybox compiled solely as "hush" -wait -echo "Test 4: var:$var" -test -f shell_test_$$ && echo "File created:ok" - -rm shell_test_$$ 2>/dev/null -var=ok -( var=bad >shell_test_$$ ) -echo "Test 5: var:$var" -test -f shell_test_$$ && echo "File created:ok" - -rm shell_test_$$ 2>/dev/null diff --git a/shell/hush_test/hush-misc/redir2.right b/shell/hush_test/hush-misc/redir2.right deleted file mode 100644 index 7326d96..0000000 --- a/shell/hush_test/hush-misc/redir2.right +++ /dev/null @@ -1 +0,0 @@ -Ok diff --git a/shell/hush_test/hush-misc/redir2.tests b/shell/hush_test/hush-misc/redir2.tests deleted file mode 100755 index 81983ca..0000000 --- a/shell/hush_test/hush-misc/redir2.tests +++ /dev/null @@ -1,2 +0,0 @@ -echo NOT SHOWN \2>/dev/null -echo Ok diff --git a/shell/hush_test/hush-misc/redir3.right b/shell/hush_test/hush-misc/redir3.right deleted file mode 100644 index 3d20bbf..0000000 --- a/shell/hush_test/hush-misc/redir3.right +++ /dev/null @@ -1,14 +0,0 @@ -hush: can't open '/does/not/exist': No such file or directory -One:1 -hush: can't open '/cant/be/created': No such file or directory -One:1 -Ok -hush: can't open '/cant/be/created': No such file or directory -Zero:0 -hush: can't open '/cant/be/created': No such file or directory -One:1 -hush: can't open '/cant/be/created': No such file or directory -One:1 -hush: can't open '/cant/be/created': No such file or directory -Zero:0 -Done diff --git a/shell/hush_test/hush-misc/redir3.tests b/shell/hush_test/hush-misc/redir3.tests deleted file mode 100755 index 7c28e43..0000000 --- a/shell/hush_test/hush-misc/redir3.tests +++ /dev/null @@ -1,9 +0,0 @@ -echo Error >/does/not/exist; echo One:$? -t=BAD -t=Ok >>/cant/be/created; echo One:$? -echo $t -! >/cant/be/created; echo Zero:$? -exec >/cant/be/created; echo One:$? -exec /bin/true >/cant/be/created; echo One:$? -! exec /bin/true >/cant/be/created; echo Zero:$? -echo Done diff --git a/shell/hush_test/hush-misc/redir4.right b/shell/hush_test/hush-misc/redir4.right deleted file mode 100644 index ead25f6..0000000 --- a/shell/hush_test/hush-misc/redir4.right +++ /dev/null @@ -1,18 +0,0 @@ -shell_test -\shell_test -\shell_test -\shell_test -Here1 -Ok1 -Here2 -Ok2 -Here3 -Ok3 -Here4 -Ok4 -Now with variable refs -shell_test_1 -\shell_test_1 -\shell_test_1 -\shell_test_1 -Done diff --git a/shell/hush_test/hush-misc/redir4.tests b/shell/hush_test/hush-misc/redir4.tests deleted file mode 100755 index c50b8ce..0000000 --- a/shell/hush_test/hush-misc/redir4.tests +++ /dev/null @@ -1,85 +0,0 @@ -rm *shell_test* 2>/dev/null - ->\shell_test -echo *shell_test* -rm *shell_test* - ->\\shell_test -echo *shell_test* -rm *shell_test* - ->"\shell_test" -echo *shell_test* -rm *shell_test* - ->"\\shell_test" -echo *shell_test* -rm *shell_test* - - -cat <<\shell_test -Here1 -shell_test -echo Ok1 - -cat <<\\shell_test -Here2 -\shell_test -echo Ok2 - -cat <<"\shell_test" -Here3 -\shell_test -echo Ok3 - -cat <<"\\shell_test" -Here4 -\shell_test -echo Ok4 - - -echo Now with variable refs -i=1 - - ->\shell_test_$i -echo *shell_test* -rm *shell_test* - ->\\shell_test_$i -echo *shell_test* -rm *shell_test* - ->"\shell_test_$i" -echo *shell_test* -rm *shell_test* - ->"\\shell_test_$i" -echo *shell_test* -rm *shell_test* - -echo Done;exit -# UNFIXED BUG. bash apparently will expand $i even in terminating delimiter. -# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html -# does not mandate this behavior. -# This is not likely to be used much in real-world. - -cat <<\shell_test_$i -Here1 -shell_test_$i -echo Ok1 - -cat <<\\shell_test_$i -Here2 -\shell_test_$i -echo Ok2 - -cat <<"\shell_test_$i" -Here3 -\shell_test_$i -echo Ok3 - -cat <<"\\shell_test_$i" -Here4 -\shell_test_$i -echo Ok4 diff --git a/shell/hush_test/hush-misc/redir5.right b/shell/hush_test/hush-misc/redir5.right deleted file mode 100644 index 52cce4f..0000000 --- a/shell/hush_test/hush-misc/redir5.right +++ /dev/null @@ -1,4 +0,0 @@ -Backgrounded pipes shall have their stdin redirected to /dev/null -Zero:0 -Zero:0 -Done diff --git a/shell/hush_test/hush-misc/redir5.tests b/shell/hush_test/hush-misc/redir5.tests deleted file mode 100755 index 957f9c8..0000000 --- a/shell/hush_test/hush-misc/redir5.tests +++ /dev/null @@ -1,13 +0,0 @@ -echo "Backgrounded pipes shall have their stdin redirected to /dev/null" - -# 1. bash does not redirect stdin to /dev/null if it is interactive. -# hush does it always (this is allowed by standards). - -# 2. Failure will result in this script hanging - -cat & wait; echo Zero:$? - -# This does not work for bash! bash bug? -cat | cat & wait; echo Zero:$? - -echo Done diff --git a/shell/hush_test/hush-misc/redir6.right b/shell/hush_test/hush-misc/redir6.right deleted file mode 100644 index a97c4bd..0000000 --- a/shell/hush_test/hush-misc/redir6.right +++ /dev/null @@ -1,4 +0,0 @@ -Testing multiple redirections to same fd -Hello -Done1 -Done2 diff --git a/shell/hush_test/hush-misc/redir6.tests b/shell/hush_test/hush-misc/redir6.tests deleted file mode 100755 index c639ebb..0000000 --- a/shell/hush_test/hush-misc/redir6.tests +++ /dev/null @@ -1,5 +0,0 @@ -echo "Testing multiple redirections to same fd" -# bug was making us lose fd #1 after this: -echo Hello >/dev/null 1>&2 -echo Done1 -echo Done2 >&2 diff --git a/shell/hush_test/hush-misc/redir_script.right b/shell/hush_test/hush-misc/redir_script.right deleted file mode 100644 index 6694ed3..0000000 --- a/shell/hush_test/hush-misc/redir_script.right +++ /dev/null @@ -1 +0,0 @@ -Ok: script fd is not closed diff --git a/shell/hush_test/hush-misc/redir_script.tests b/shell/hush_test/hush-misc/redir_script.tests deleted file mode 100755 index ccc497d..0000000 --- a/shell/hush_test/hush-misc/redir_script.tests +++ /dev/null @@ -1,29 +0,0 @@ -# Builds a " 3>&- 4>&-" string. -# Note: one of these fds is a directory opened to /proc/self/fd -# for globbing. It is unwanted, but I don't know how to filter it out. -find_fds() { - fds="" - for f in /proc/self/fd/*; do - test "$f" = "/proc/self/fd/0" && continue - test "$f" = "/proc/self/fd/1" && continue - test "$f" = "/proc/self/fd/2" && continue - fds="$fds ${f##*/}>&-" - done -} - -find_fds -fds1="$fds" - -# One of the fds is open to the script body -# Close it while executing something. -eval "find_fds $fds" - -# Shell should not lose that fd. Did it? -find_fds -test x"$fds1" = x"$fds" && { echo "Ok: script fd is not closed"; exit 0; } - -echo "Bug: script fd is closed" -echo "fds1:$fds1" -echo "fds2:$fds" -exit 1 - diff --git a/shell/hush_test/hush-parsing/redir_space.right b/shell/hush_test/hush-parsing/redir_space.right deleted file mode 100644 index 0842952..0000000 --- a/shell/hush_test/hush-parsing/redir_space.right +++ /dev/null @@ -1,3 +0,0 @@ -z1.tmp: 1 -z2.tmp: 1 -"z1.tmp z2.tmp": TEST 0 diff --git a/shell/hush_test/hush-parsing/redir_space.tests b/shell/hush_test/hush-parsing/redir_space.tests deleted file mode 100755 index c0b5430..0000000 --- a/shell/hush_test/hush-parsing/redir_space.tests +++ /dev/null @@ -1,6 +0,0 @@ -v='z1.tmp z2.tmp' -echo TEST >$v -echo 'z1.tmp:' `cat 'z1.tmp' 2>/dev/null; echo $?` -echo 'z2.tmp:' `cat 'z2.tmp' 2>/dev/null; echo $?` -echo '"z1.tmp z2.tmp":' `cat 'z1.tmp z2.tmp' 2>/dev/null; echo $?` -rm z*.tmp diff --git a/shell/hush_test/hush-redir/redir1.right b/shell/hush_test/hush-redir/redir1.right new file mode 100644 index 0000000..15515d1 --- /dev/null +++ b/shell/hush_test/hush-redir/redir1.right @@ -0,0 +1,12 @@ +Test 0: var:ok +File created:ok +Test 1: var:ok +File created:ok +Test 2: var:ok +File created:ok +Test 3: var:ok +File created:ok +Test 4: var:ok +File created:ok +Test 5: var:ok +File created:ok diff --git a/shell/hush_test/hush-redir/redir1.tests b/shell/hush_test/hush-redir/redir1.tests new file mode 100755 index 0000000..ef2fbfb --- /dev/null +++ b/shell/hush_test/hush-redir/redir1.tests @@ -0,0 +1,40 @@ +rm shell_test_$$ 2>/dev/null +var=bad +>shell_test_$$ var=ok +echo "Test 0: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=bad +var=ok >shell_test_$$ +echo "Test 1: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +true | var=bad >shell_test_$$ +echo "Test 2: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=bad +{ var=ok >shell_test_$$; } +echo "Test 3: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +{ var=bad >shell_test_$$; } & +# cant use usleep as it isnt standard in $PATH -- +# we fail when testing busybox compiled solely as "hush" +wait +echo "Test 4: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null +var=ok +( var=bad >shell_test_$$ ) +echo "Test 5: var:$var" +test -f shell_test_$$ && echo "File created:ok" + +rm shell_test_$$ 2>/dev/null diff --git a/shell/hush_test/hush-redir/redir2.right b/shell/hush_test/hush-redir/redir2.right new file mode 100644 index 0000000..7326d96 --- /dev/null +++ b/shell/hush_test/hush-redir/redir2.right @@ -0,0 +1 @@ +Ok diff --git a/shell/hush_test/hush-redir/redir2.tests b/shell/hush_test/hush-redir/redir2.tests new file mode 100755 index 0000000..81983ca --- /dev/null +++ b/shell/hush_test/hush-redir/redir2.tests @@ -0,0 +1,2 @@ +echo NOT SHOWN \2>/dev/null +echo Ok diff --git a/shell/hush_test/hush-redir/redir3.right b/shell/hush_test/hush-redir/redir3.right new file mode 100644 index 0000000..3d20bbf --- /dev/null +++ b/shell/hush_test/hush-redir/redir3.right @@ -0,0 +1,14 @@ +hush: can't open '/does/not/exist': No such file or directory +One:1 +hush: can't open '/cant/be/created': No such file or directory +One:1 +Ok +hush: can't open '/cant/be/created': No such file or directory +Zero:0 +hush: can't open '/cant/be/created': No such file or directory +One:1 +hush: can't open '/cant/be/created': No such file or directory +One:1 +hush: can't open '/cant/be/created': No such file or directory +Zero:0 +Done diff --git a/shell/hush_test/hush-redir/redir3.tests b/shell/hush_test/hush-redir/redir3.tests new file mode 100755 index 0000000..7c28e43 --- /dev/null +++ b/shell/hush_test/hush-redir/redir3.tests @@ -0,0 +1,9 @@ +echo Error >/does/not/exist; echo One:$? +t=BAD +t=Ok >>/cant/be/created; echo One:$? +echo $t +! >/cant/be/created; echo Zero:$? +exec >/cant/be/created; echo One:$? +exec /bin/true >/cant/be/created; echo One:$? +! exec /bin/true >/cant/be/created; echo Zero:$? +echo Done diff --git a/shell/hush_test/hush-redir/redir4.right b/shell/hush_test/hush-redir/redir4.right new file mode 100644 index 0000000..ead25f6 --- /dev/null +++ b/shell/hush_test/hush-redir/redir4.right @@ -0,0 +1,18 @@ +shell_test +\shell_test +\shell_test +\shell_test +Here1 +Ok1 +Here2 +Ok2 +Here3 +Ok3 +Here4 +Ok4 +Now with variable refs +shell_test_1 +\shell_test_1 +\shell_test_1 +\shell_test_1 +Done diff --git a/shell/hush_test/hush-redir/redir4.tests b/shell/hush_test/hush-redir/redir4.tests new file mode 100755 index 0000000..c50b8ce --- /dev/null +++ b/shell/hush_test/hush-redir/redir4.tests @@ -0,0 +1,85 @@ +rm *shell_test* 2>/dev/null + +>\shell_test +echo *shell_test* +rm *shell_test* + +>\\shell_test +echo *shell_test* +rm *shell_test* + +>"\shell_test" +echo *shell_test* +rm *shell_test* + +>"\\shell_test" +echo *shell_test* +rm *shell_test* + + +cat <<\shell_test +Here1 +shell_test +echo Ok1 + +cat <<\\shell_test +Here2 +\shell_test +echo Ok2 + +cat <<"\shell_test" +Here3 +\shell_test +echo Ok3 + +cat <<"\\shell_test" +Here4 +\shell_test +echo Ok4 + + +echo Now with variable refs +i=1 + + +>\shell_test_$i +echo *shell_test* +rm *shell_test* + +>\\shell_test_$i +echo *shell_test* +rm *shell_test* + +>"\shell_test_$i" +echo *shell_test* +rm *shell_test* + +>"\\shell_test_$i" +echo *shell_test* +rm *shell_test* + +echo Done;exit +# UNFIXED BUG. bash apparently will expand $i even in terminating delimiter. +# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html +# does not mandate this behavior. +# This is not likely to be used much in real-world. + +cat <<\shell_test_$i +Here1 +shell_test_$i +echo Ok1 + +cat <<\\shell_test_$i +Here2 +\shell_test_$i +echo Ok2 + +cat <<"\shell_test_$i" +Here3 +\shell_test_$i +echo Ok3 + +cat <<"\\shell_test_$i" +Here4 +\shell_test_$i +echo Ok4 diff --git a/shell/hush_test/hush-redir/redir5.right b/shell/hush_test/hush-redir/redir5.right new file mode 100644 index 0000000..52cce4f --- /dev/null +++ b/shell/hush_test/hush-redir/redir5.right @@ -0,0 +1,4 @@ +Backgrounded pipes shall have their stdin redirected to /dev/null +Zero:0 +Zero:0 +Done diff --git a/shell/hush_test/hush-redir/redir5.tests b/shell/hush_test/hush-redir/redir5.tests new file mode 100755 index 0000000..957f9c8 --- /dev/null +++ b/shell/hush_test/hush-redir/redir5.tests @@ -0,0 +1,13 @@ +echo "Backgrounded pipes shall have their stdin redirected to /dev/null" + +# 1. bash does not redirect stdin to /dev/null if it is interactive. +# hush does it always (this is allowed by standards). + +# 2. Failure will result in this script hanging + +cat & wait; echo Zero:$? + +# This does not work for bash! bash bug? +cat | cat & wait; echo Zero:$? + +echo Done diff --git a/shell/hush_test/hush-redir/redir6.right b/shell/hush_test/hush-redir/redir6.right new file mode 100644 index 0000000..a97c4bd --- /dev/null +++ b/shell/hush_test/hush-redir/redir6.right @@ -0,0 +1,4 @@ +Testing multiple redirections to same fd +Hello +Done1 +Done2 diff --git a/shell/hush_test/hush-redir/redir6.tests b/shell/hush_test/hush-redir/redir6.tests new file mode 100755 index 0000000..c639ebb --- /dev/null +++ b/shell/hush_test/hush-redir/redir6.tests @@ -0,0 +1,5 @@ +echo "Testing multiple redirections to same fd" +# bug was making us lose fd #1 after this: +echo Hello >/dev/null 1>&2 +echo Done1 +echo Done2 >&2 diff --git a/shell/hush_test/hush-redir/redir7.right b/shell/hush_test/hush-redir/redir7.right new file mode 100644 index 0000000..6430b02 --- /dev/null +++ b/shell/hush_test/hush-redir/redir7.right @@ -0,0 +1,3 @@ +Ok +Ok +Done diff --git a/shell/hush_test/hush-redir/redir7.tests b/shell/hush_test/hush-redir/redir7.tests new file mode 100755 index 0000000..e873a46 --- /dev/null +++ b/shell/hush_test/hush-redir/redir7.tests @@ -0,0 +1,12 @@ +# Chars above 0x7f are used as special codes. +# 0x81 is CTLESC (see ash.c). +# The bug was that quoting and unquoting of them +# was out of sync for redirect filenames. + +>unicode.sh +printf 'echo Ok >uni\x81code\n' >>unicode.sh +printf 'cat uni\x81code\n' >>unicode.sh +printf 'cat uni?code\n' >>unicode.sh +. ./unicode.sh +rm uni*code* +echo Done diff --git a/shell/hush_test/hush-redir/redir8.right b/shell/hush_test/hush-redir/redir8.right new file mode 100644 index 0000000..6430b02 --- /dev/null +++ b/shell/hush_test/hush-redir/redir8.right @@ -0,0 +1,3 @@ +Ok +Ok +Done diff --git a/shell/hush_test/hush-redir/redir8.tests b/shell/hush_test/hush-redir/redir8.tests new file mode 100755 index 0000000..2bd3867 --- /dev/null +++ b/shell/hush_test/hush-redir/redir8.tests @@ -0,0 +1,15 @@ +# Chars above 0x7f are used as special codes. +# 0x81 is CTLESC (see ash.c). +# The bug was that quoting and unquoting of them +# was out of sync for redirect filenames. + +# Subcase when redirect filename is specified in a variable. + +>unicode.sh +printf 'v=uni\x81code\n' >>unicode.sh +printf 'echo Ok >"$v"\n' >>unicode.sh +printf 'cat uni\x81code\n' >>unicode.sh +printf 'cat uni?code\n' >>unicode.sh +. ./unicode.sh +rm uni*code* +echo Done diff --git a/shell/hush_test/hush-redir/redir9.right b/shell/hush_test/hush-redir/redir9.right new file mode 100644 index 0000000..34c2512 --- /dev/null +++ b/shell/hush_test/hush-redir/redir9.right @@ -0,0 +1,2 @@ +Ok +Done:0 diff --git a/shell/hush_test/hush-redir/redir9.tests b/shell/hush_test/hush-redir/redir9.tests new file mode 100755 index 0000000..8befa61 --- /dev/null +++ b/shell/hush_test/hush-redir/redir9.tests @@ -0,0 +1,4 @@ +echo Ok >file.tmp +cat 0<>file.tmp +echo Done:$? +rm file.tmp diff --git a/shell/hush_test/hush-redir/redirA.right b/shell/hush_test/hush-redir/redirA.right new file mode 100644 index 0000000..31406e3 --- /dev/null +++ b/shell/hush_test/hush-redir/redirA.right @@ -0,0 +1,2 @@ +tmp11 +tmp11 diff --git a/shell/hush_test/hush-redir/redirA.tests b/shell/hush_test/hush-redir/redirA.tests new file mode 100755 index 0000000..56833f9 --- /dev/null +++ b/shell/hush_test/hush-redir/redirA.tests @@ -0,0 +1,11 @@ +x="tmp11:tmp22" + +# Bug was incorrectly expanding variables in >redir +echo "${x%:*}" >"${x%:*}" +echo tmp1* +rm tmp1* + +# Also try unquoted +echo "${x%:*}" >${x%:*} +echo tmp1* +rm tmp1* diff --git a/shell/hush_test/hush-redir/redir_script.right b/shell/hush_test/hush-redir/redir_script.right new file mode 100644 index 0000000..6694ed3 --- /dev/null +++ b/shell/hush_test/hush-redir/redir_script.right @@ -0,0 +1 @@ +Ok: script fd is not closed diff --git a/shell/hush_test/hush-redir/redir_script.tests b/shell/hush_test/hush-redir/redir_script.tests new file mode 100755 index 0000000..ccc497d --- /dev/null +++ b/shell/hush_test/hush-redir/redir_script.tests @@ -0,0 +1,29 @@ +# Builds a " 3>&- 4>&-" string. +# Note: one of these fds is a directory opened to /proc/self/fd +# for globbing. It is unwanted, but I don't know how to filter it out. +find_fds() { + fds="" + for f in /proc/self/fd/*; do + test "$f" = "/proc/self/fd/0" && continue + test "$f" = "/proc/self/fd/1" && continue + test "$f" = "/proc/self/fd/2" && continue + fds="$fds ${f##*/}>&-" + done +} + +find_fds +fds1="$fds" + +# One of the fds is open to the script body +# Close it while executing something. +eval "find_fds $fds" + +# Shell should not lose that fd. Did it? +find_fds +test x"$fds1" = x"$fds" && { echo "Ok: script fd is not closed"; exit 0; } + +echo "Bug: script fd is closed" +echo "fds1:$fds1" +echo "fds2:$fds" +exit 1 + diff --git a/shell/hush_test/hush-redir/redir_space.right b/shell/hush_test/hush-redir/redir_space.right new file mode 100644 index 0000000..0842952 --- /dev/null +++ b/shell/hush_test/hush-redir/redir_space.right @@ -0,0 +1,3 @@ +z1.tmp: 1 +z2.tmp: 1 +"z1.tmp z2.tmp": TEST 0 diff --git a/shell/hush_test/hush-redir/redir_space.tests b/shell/hush_test/hush-redir/redir_space.tests new file mode 100755 index 0000000..c0b5430 --- /dev/null +++ b/shell/hush_test/hush-redir/redir_space.tests @@ -0,0 +1,6 @@ +v='z1.tmp z2.tmp' +echo TEST >$v +echo 'z1.tmp:' `cat 'z1.tmp' 2>/dev/null; echo $?` +echo 'z2.tmp:' `cat 'z2.tmp' 2>/dev/null; echo $?` +echo '"z1.tmp z2.tmp":' `cat 'z1.tmp z2.tmp' 2>/dev/null; echo $?` +rm z*.tmp -- cgit v1.1