summaryrefslogtreecommitdiff
path: root/shell/ash_test/ash-redir
diff options
context:
space:
mode:
authorDenys Vlasenko2016-10-02 17:55:51 +0200
committerDenys Vlasenko2016-10-02 17:55:51 +0200
commitc4cf542c575068d55368e771abf6c358bfebf5d3 (patch)
treeb916ff4bea0671437b80257fa82283ad8e09faab /shell/ash_test/ash-redir
parent1b73f8471a3694d2e6b035bb7f04e1f4df943f03 (diff)
downloadbusybox-c4cf542c575068d55368e771abf6c358bfebf5d3.zip
busybox-c4cf542c575068d55368e771abf6c358bfebf5d3.tar.gz
sh testsuite: create hush-redir/* and move files around
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test/ash-redir')
-rw-r--r--shell/ash_test/ash-redir/redir1.right12
-rwxr-xr-xshell/ash_test/ash-redir/redir1.tests40
-rw-r--r--shell/ash_test/ash-redir/redir_script.right1
-rwxr-xr-xshell/ash_test/ash-redir/redir_script.tests29
-rw-r--r--shell/ash_test/ash-redir/redir_space.right3
-rwxr-xr-xshell/ash_test/ash-redir/redir_space.tests6
6 files changed, 91 insertions, 0 deletions
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