aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 17:55:51 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 17:55:51 +0200
commitc4cf542c575068d55368e771abf6c358bfebf5d3 (patch)
treeb916ff4bea0671437b80257fa82283ad8e09faab /shell/ash_test
parent1b73f8471a3694d2e6b035bb7f04e1f4df943f03 (diff)
downloadbusybox-w32-c4cf542c575068d55368e771abf6c358bfebf5d3.tar.gz
busybox-w32-c4cf542c575068d55368e771abf6c358bfebf5d3.tar.bz2
busybox-w32-c4cf542c575068d55368e771abf6c358bfebf5d3.zip
sh testsuite: create hush-redir/* and move files around
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test')
-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 000000000..15515d1af
--- /dev/null
+++ b/shell/ash_test/ash-redir/redir1.right
@@ -0,0 +1,12 @@
1Test 0: var:ok
2File created:ok
3Test 1: var:ok
4File created:ok
5Test 2: var:ok
6File created:ok
7Test 3: var:ok
8File created:ok
9Test 4: var:ok
10File created:ok
11Test 5: var:ok
12File 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 000000000..ef2fbfb77
--- /dev/null
+++ b/shell/ash_test/ash-redir/redir1.tests
@@ -0,0 +1,40 @@
1rm shell_test_$$ 2>/dev/null
2var=bad
3>shell_test_$$ var=ok
4echo "Test 0: var:$var"
5test -f shell_test_$$ && echo "File created:ok"
6
7rm shell_test_$$ 2>/dev/null
8var=bad
9var=ok >shell_test_$$
10echo "Test 1: var:$var"
11test -f shell_test_$$ && echo "File created:ok"
12
13rm shell_test_$$ 2>/dev/null
14var=ok
15true | var=bad >shell_test_$$
16echo "Test 2: var:$var"
17test -f shell_test_$$ && echo "File created:ok"
18
19rm shell_test_$$ 2>/dev/null
20var=bad
21{ var=ok >shell_test_$$; }
22echo "Test 3: var:$var"
23test -f shell_test_$$ && echo "File created:ok"
24
25rm shell_test_$$ 2>/dev/null
26var=ok
27{ var=bad >shell_test_$$; } &
28# cant use usleep as it isnt standard in $PATH --
29# we fail when testing busybox compiled solely as "hush"
30wait
31echo "Test 4: var:$var"
32test -f shell_test_$$ && echo "File created:ok"
33
34rm shell_test_$$ 2>/dev/null
35var=ok
36( var=bad >shell_test_$$ )
37echo "Test 5: var:$var"
38test -f shell_test_$$ && echo "File created:ok"
39
40rm 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 000000000..6694ed334
--- /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 000000000..ccc497d7b
--- /dev/null
+++ b/shell/ash_test/ash-redir/redir_script.tests
@@ -0,0 +1,29 @@
1# Builds a " 3>&- 4>&-" string.
2# Note: one of these fds is a directory opened to /proc/self/fd
3# for globbing. It is unwanted, but I don't know how to filter it out.
4find_fds() {
5 fds=""
6 for f in /proc/self/fd/*; do
7 test "$f" = "/proc/self/fd/0" && continue
8 test "$f" = "/proc/self/fd/1" && continue
9 test "$f" = "/proc/self/fd/2" && continue
10 fds="$fds ${f##*/}>&-"
11 done
12}
13
14find_fds
15fds1="$fds"
16
17# One of the fds is open to the script body
18# Close it while executing something.
19eval "find_fds $fds"
20
21# Shell should not lose that fd. Did it?
22find_fds
23test x"$fds1" = x"$fds" && { echo "Ok: script fd is not closed"; exit 0; }
24
25echo "Bug: script fd is closed"
26echo "fds1:$fds1"
27echo "fds2:$fds"
28exit 1
29
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 000000000..084295204
--- /dev/null
+++ b/shell/ash_test/ash-redir/redir_space.right
@@ -0,0 +1,3 @@
1z1.tmp: 1
2z2.tmp: 1
3"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 000000000..c0b543098
--- /dev/null
+++ b/shell/ash_test/ash-redir/redir_space.tests
@@ -0,0 +1,6 @@
1v='z1.tmp z2.tmp'
2echo TEST >$v
3echo 'z1.tmp:' `cat 'z1.tmp' 2>/dev/null; echo $?`
4echo 'z2.tmp:' `cat 'z2.tmp' 2>/dev/null; echo $?`
5echo '"z1.tmp z2.tmp":' `cat 'z1.tmp z2.tmp' 2>/dev/null; echo $?`
6rm z*.tmp