aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 17:39:31 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 17:39:31 +0200
commit5d6b8729ed7335c702022f4f3176573f4cf2cf5a (patch)
treebef985dae4fb3ea41e1a478a848d19039b0e5d8f
parent888527cceec2f58f1eae3acceddee928b5cb647a (diff)
downloadbusybox-w32-5d6b8729ed7335c702022f4f3176573f4cf2cf5a.tar.gz
busybox-w32-5d6b8729ed7335c702022f4f3176573f4cf2cf5a.tar.bz2
busybox-w32-5d6b8729ed7335c702022f4f3176573f4cf2cf5a.zip
hush testsuite: add many tests from ash testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xshell/ash_test/ash-quoting/dollar_repl_slash_bash1.tests2
-rw-r--r--shell/hush_test/hush-invert/invert.right10
-rwxr-xr-xshell/hush_test/hush-invert/invert.tests19
-rw-r--r--shell/hush_test/hush-misc/heredoc4.right1
-rwxr-xr-xshell/hush_test/hush-misc/heredoc4.tests3
-rw-r--r--shell/hush_test/hush-misc/last_amp.right2
-rwxr-xr-xshell/hush_test/hush-misc/last_amp.tests8
-rw-r--r--shell/hush_test/hush-misc/local1.right4
-rwxr-xr-xshell/hush_test/hush-misc/local1.tests11
-rw-r--r--shell/hush_test/hush-misc/nulltick1.right3
-rwxr-xr-xshell/hush_test/hush-misc/nulltick1.tests3
-rw-r--r--shell/hush_test/hush-quoting/dollar_repl_slash_bash1.right10
-rwxr-xr-xshell/hush_test/hush-quoting/dollar_repl_slash_bash1.tests21
-rwxr-xr-xshell/hush_test/hush-read/read_r.tests6
-rw-r--r--shell/hush_test/hush-signals/reap1.right1
-rwxr-xr-xshell/hush_test/hush-signals/reap1.tests14
-rw-r--r--shell/hush_test/hush-signals/sigint1.right1
-rwxr-xr-xshell/hush_test/hush-signals/sigint1.tests41
-rw-r--r--shell/hush_test/hush-signals/signal2.right3
-rwxr-xr-xshell/hush_test/hush-signals/signal2.tests18
-rw-r--r--shell/hush_test/hush-signals/signal3.right4
-rwxr-xr-xshell/hush_test/hush-signals/signal3.tests17
-rw-r--r--shell/hush_test/hush-signals/signal5.right12
-rwxr-xr-xshell/hush_test/hush-signals/signal5.tests14
-rw-r--r--shell/hush_test/hush-signals/signal6.right2
-rwxr-xr-xshell/hush_test/hush-signals/signal6.tests2
-rw-r--r--shell/hush_test/hush-signals/sigquit_exec.right2
-rwxr-xr-xshell/hush_test/hush-signals/sigquit_exec.tests4
-rw-r--r--shell/hush_test/hush-standalone/noexec_gets_no_env.right4
-rwxr-xr-xshell/hush_test/hush-standalone/noexec_gets_no_env.tests5
-rw-r--r--shell/hush_test/hush-standalone/nofork_trashes_getopt.right1
-rwxr-xr-xshell/hush_test/hush-standalone/nofork_trashes_getopt.tests6
-rw-r--r--shell/hush_test/hush-standalone/var_standalone1.right1
-rwxr-xr-xshell/hush_test/hush-standalone/var_standalone1.tests2
34 files changed, 254 insertions, 3 deletions
diff --git a/shell/ash_test/ash-quoting/dollar_repl_slash_bash1.tests b/shell/ash_test/ash-quoting/dollar_repl_slash_bash1.tests
index 3fa2f186d..74dca1cc0 100755
--- a/shell/ash_test/ash-quoting/dollar_repl_slash_bash1.tests
+++ b/shell/ash_test/ash-quoting/dollar_repl_slash_bash1.tests
@@ -1,5 +1,5 @@
1# The bug here was triggered by: 1# The bug here was triggered by:
2# * performin pathname expansion because we see [ 2# * performing pathname expansion because we see [
3# * replace operator did not escape \ in replace string 3# * replace operator did not escape \ in replace string
4 4
5IP=192.168.0.1 5IP=192.168.0.1
diff --git a/shell/hush_test/hush-invert/invert.right b/shell/hush_test/hush-invert/invert.right
new file mode 100644
index 000000000..5a9239aa6
--- /dev/null
+++ b/shell/hush_test/hush-invert/invert.right
@@ -0,0 +1,10 @@
11
21
31
40
50
61
70
81
90
101
diff --git a/shell/hush_test/hush-invert/invert.tests b/shell/hush_test/hush-invert/invert.tests
new file mode 100755
index 000000000..8393d95a4
--- /dev/null
+++ b/shell/hush_test/hush-invert/invert.tests
@@ -0,0 +1,19 @@
1# tests of return value inversion
2# placeholder for future expansion
3
4# user subshells (...) did this wrong in bash versions before 2.04
5
6! ( echo hello | grep h >/dev/null 2>&1 ); echo $?
7! echo hello | grep h >/dev/null 2>&1 ; echo $?
8
9! true ; echo $?
10! false; echo $?
11
12! (false) ; echo $?
13! (true); echo $?
14
15! true | false ; echo $?
16! false | true ; echo $?
17
18! (true | false) ; echo $?
19! (false | true) ; echo $?
diff --git a/shell/hush_test/hush-misc/heredoc4.right b/shell/hush_test/hush-misc/heredoc4.right
new file mode 100644
index 000000000..371b092e2
--- /dev/null
+++ b/shell/hush_test/hush-misc/heredoc4.right
@@ -0,0 +1 @@
'$'
diff --git a/shell/hush_test/hush-misc/heredoc4.tests b/shell/hush_test/hush-misc/heredoc4.tests
new file mode 100755
index 000000000..642ddb324
--- /dev/null
+++ b/shell/hush_test/hush-misc/heredoc4.tests
@@ -0,0 +1,3 @@
1cat <<EOF
2'$'
3EOF
diff --git a/shell/hush_test/hush-misc/last_amp.right b/shell/hush_test/hush-misc/last_amp.right
new file mode 100644
index 000000000..3da21aec2
--- /dev/null
+++ b/shell/hush_test/hush-misc/last_amp.right
@@ -0,0 +1,2 @@
13
2End
diff --git a/shell/hush_test/hush-misc/last_amp.tests b/shell/hush_test/hush-misc/last_amp.tests
new file mode 100755
index 000000000..160937644
--- /dev/null
+++ b/shell/hush_test/hush-misc/last_amp.tests
@@ -0,0 +1,8 @@
1$THIS_SH -c 'echo 3&'
2d=`date`
3while test "`date`" = "$d"; do true; done
4d1=`date`
5$THIS_SH -c 'sleep 1&'
6d2=`date`
7test "$d1" = "$d2" || echo BAD
8echo End
diff --git a/shell/hush_test/hush-misc/local1.right b/shell/hush_test/hush-misc/local1.right
new file mode 100644
index 000000000..a2d121df6
--- /dev/null
+++ b/shell/hush_test/hush-misc/local1.right
@@ -0,0 +1,4 @@
1A1:'A'
2A2:''
3A3:''
4A4:'A'
diff --git a/shell/hush_test/hush-misc/local1.tests b/shell/hush_test/hush-misc/local1.tests
new file mode 100755
index 000000000..b1e675059
--- /dev/null
+++ b/shell/hush_test/hush-misc/local1.tests
@@ -0,0 +1,11 @@
1a=A
2f() {
3 local a
4 # the above line unsets $a
5 echo "A2:'$a'"
6 unset a
7 echo "A3:'$a'"
8}
9echo "A1:'$a'"
10f
11echo "A4:'$a'"
diff --git a/shell/hush_test/hush-misc/nulltick1.right b/shell/hush_test/hush-misc/nulltick1.right
new file mode 100644
index 000000000..f90b8209e
--- /dev/null
+++ b/shell/hush_test/hush-misc/nulltick1.right
@@ -0,0 +1,3 @@
1Test 1
2Test 2
3Done
diff --git a/shell/hush_test/hush-misc/nulltick1.tests b/shell/hush_test/hush-misc/nulltick1.tests
new file mode 100755
index 000000000..f81923de3
--- /dev/null
+++ b/shell/hush_test/hush-misc/nulltick1.tests
@@ -0,0 +1,3 @@
1echo Test ` ` 1
2echo Test `</dev/null` 2
3echo Done
diff --git a/shell/hush_test/hush-quoting/dollar_repl_slash_bash1.right b/shell/hush_test/hush-quoting/dollar_repl_slash_bash1.right
new file mode 100644
index 000000000..b212c246c
--- /dev/null
+++ b/shell/hush_test/hush-quoting/dollar_repl_slash_bash1.right
@@ -0,0 +1,10 @@
1192\.168\.0\.1
2192\.168\.0\.1[
3192\.168\.0\.1[
4192\\.168\\.0\\.1[
5192\.168\.0\.1[
6192\.168\.0\.1
7192\.168\.0\.1[
8192\.168\.0\.1[
9192\\.168\\.0\\.1[
10192\.168\.0\.1[
diff --git a/shell/hush_test/hush-quoting/dollar_repl_slash_bash1.tests b/shell/hush_test/hush-quoting/dollar_repl_slash_bash1.tests
new file mode 100755
index 000000000..74dca1cc0
--- /dev/null
+++ b/shell/hush_test/hush-quoting/dollar_repl_slash_bash1.tests
@@ -0,0 +1,21 @@
1# The bug here was triggered by:
2# * performing pathname expansion because we see [
3# * replace operator did not escape \ in replace string
4
5IP=192.168.0.1
6
7rm -f '192.168.0.1['
8echo "${IP//./\\.}"
9echo "${IP//./\\.}"'[' # bug was here
10echo "${IP//./\\.}[" # bug was here
11echo "${IP//./\\\\.}[" # bug was here
12echo "192\.168\.0\.1["
13
14echo >'192.168.0.1['
15echo "${IP//./\\.}"
16echo "${IP//./\\.}"'[' # bug was here
17echo "${IP//./\\.}[" # bug was here
18echo "${IP//./\\\\.}[" # bug was here
19echo "192\.168\.0\.1["
20
21rm -f '192.168.0.1['
diff --git a/shell/hush_test/hush-read/read_r.tests b/shell/hush_test/hush-read/read_r.tests
index 2c4cc6106..1f0a18afc 100755
--- a/shell/hush_test/hush-read/read_r.tests
+++ b/shell/hush_test/hush-read/read_r.tests
@@ -1,2 +1,4 @@
1echo -e 'test\\\nbest' | (read reply; echo "$reply") 1echo 'test\
2echo -e 'test\\\nbest' | (read -r reply; echo "$reply") 2best' | (read reply; echo "$reply")
3echo 'test\
4best' | (read -r reply; echo "$reply")
diff --git a/shell/hush_test/hush-signals/reap1.right b/shell/hush_test/hush-signals/reap1.right
new file mode 100644
index 000000000..7326d9603
--- /dev/null
+++ b/shell/hush_test/hush-signals/reap1.right
@@ -0,0 +1 @@
Ok
diff --git a/shell/hush_test/hush-signals/reap1.tests b/shell/hush_test/hush-signals/reap1.tests
new file mode 100755
index 000000000..bf1a1f908
--- /dev/null
+++ b/shell/hush_test/hush-signals/reap1.tests
@@ -0,0 +1,14 @@
1#!/bin/sh
2
3# Must not find us alive
4{ sleep 2; kill -9 $$; } 2>/dev/null &
5
6sleep 1 &
7PID=$!
8
9# We must exit the loop in one second.
10# We had bug 5304: builtins never waited for exited children
11while kill -0 $PID >/dev/null 2>&1; do
12 true
13done
14echo Ok
diff --git a/shell/hush_test/hush-signals/sigint1.right b/shell/hush_test/hush-signals/sigint1.right
new file mode 100644
index 000000000..a9094b056
--- /dev/null
+++ b/shell/hush_test/hush-signals/sigint1.right
@@ -0,0 +1 @@
Sending SIGINT to main shell PID
diff --git a/shell/hush_test/hush-signals/sigint1.tests b/shell/hush_test/hush-signals/sigint1.tests
new file mode 100755
index 000000000..3d483d32a
--- /dev/null
+++ b/shell/hush_test/hush-signals/sigint1.tests
@@ -0,0 +1,41 @@
1# What should happen if non-interactive shell gets SIGINT?
2
3(sleep 1; echo Sending SIGINT to main shell PID; exec kill -INT $$) &
4
5# We create a child which exits with 0 even on SIGINT
6# (The complex command is necessary only if SIGINT is generated by ^C,
7# in this testcase even bare "sleep 2" would do because
8# in the testcase we don't send SIGINT *to the child*...)
9$THIS_SH -c 'trap "exit 0" SIGINT; sleep 2'
10
11# In one second, we (main shell) get SIGINT here.
12# The question is whether we should, or should not, exit.
13
14# bash will not stop here. It will execute next command(s).
15
16# The rationale for this is described here:
17# http://www.cons.org/cracauer/sigint.html
18#
19# Basically, bash will not exit on SIGINT immediately if it waits
20# for a child. It will wait for the child to exit.
21# If child exits NOT by dying on SIGINT, then bash will not exit.
22#
23# The idea is that the following script:
24# | emacs file.txt
25# | more cmds
26# User may use ^C to interrupt editor's ops like search. But then
27# emacs exits normally. User expects that script doesn't stop.
28#
29# This is a nice idea, but detecting "did process really exit
30# with SIGINT?" is racy. Consider:
31# | bash -c 'while true; do /bin/true; done'
32# When ^C is pressed while bash waits for /bin/true to exit,
33# it may happen that /bin/true exits with exitcode 0 before
34# ^C is delivered to it as SIGINT. bash will see SIGINT, then
35# it will see that child exited with 0, and bash will NOT EXIT.
36
37# Therefore we do not implement bash behavior.
38# I'd say that emacs need to put itself into a separate pgrp
39# to isolate shell from getting stray SIGINTs from ^C.
40
41echo Next command after SIGINT was executed
diff --git a/shell/hush_test/hush-signals/signal2.right b/shell/hush_test/hush-signals/signal2.right
new file mode 100644
index 000000000..a2af919c0
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal2.right
@@ -0,0 +1,3 @@
1child sleeps
2child exits as expected
3parent exits
diff --git a/shell/hush_test/hush-signals/signal2.tests b/shell/hush_test/hush-signals/signal2.tests
new file mode 100755
index 000000000..df639ca2c
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal2.tests
@@ -0,0 +1,18 @@
1#!/bin/sh
2
3$THIS_SH -c '
4cleanup() {
5 echo "child exits as expected"
6 exit
7}
8trap cleanup HUP
9echo "child sleeps"
10sleep 1
11echo "BAD exit from child!"
12' &
13
14child=$!
15sleep 0.1 # let child install handler first
16kill -HUP $child
17wait
18echo "parent exits"
diff --git a/shell/hush_test/hush-signals/signal3.right b/shell/hush_test/hush-signals/signal3.right
new file mode 100644
index 000000000..3113ba5cf
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal3.right
@@ -0,0 +1,4 @@
1child sleeps
2child got HUP
3child exits
4parent exits
diff --git a/shell/hush_test/hush-signals/signal3.tests b/shell/hush_test/hush-signals/signal3.tests
new file mode 100755
index 000000000..b56c2d97e
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal3.tests
@@ -0,0 +1,17 @@
1#!/bin/sh
2
3$THIS_SH -c '
4hup() {
5 echo "child got HUP"
6}
7trap hup HUP
8echo "child sleeps"
9sleep 1
10echo "child exits"
11' &
12
13child=$!
14sleep 0.1 # let child install handler first
15kill -HUP $child
16wait
17echo "parent exits"
diff --git a/shell/hush_test/hush-signals/signal5.right b/shell/hush_test/hush-signals/signal5.right
new file mode 100644
index 000000000..7cfd4110e
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal5.right
@@ -0,0 +1,12 @@
1Sleeping
2Sleeping
3Waiting
42 sec passed, sending USR1 to parent
5USR1 received
6Wait exit code: 138
7Waiting
83 sec passed, sending USR1 to parent
9USR1 received
10Wait exit code: 138
11Waiting
12Wait returned 0
diff --git a/shell/hush_test/hush-signals/signal5.tests b/shell/hush_test/hush-signals/signal5.tests
new file mode 100755
index 000000000..179bcdd80
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal5.tests
@@ -0,0 +1,14 @@
1trap "echo USR1 received" USR1
2stub() {
3 echo "Sleeping"
4 sleep $1
5 echo "$1 sec passed, sending USR1 to parent"
6 kill -USR1 $$
7}
8stub 3 &
9stub 2 &
10sleep 1
11until { echo "Waiting"; wait; } do
12 echo "Wait exit code: $?"
13done
14echo "Wait returned 0"
diff --git a/shell/hush_test/hush-signals/signal6.right b/shell/hush_test/hush-signals/signal6.right
new file mode 100644
index 000000000..df4d9306a
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal6.right
@@ -0,0 +1,2 @@
1got TERM
2Done: 0
diff --git a/shell/hush_test/hush-signals/signal6.tests b/shell/hush_test/hush-signals/signal6.tests
new file mode 100755
index 000000000..3ce151060
--- /dev/null
+++ b/shell/hush_test/hush-signals/signal6.tests
@@ -0,0 +1,2 @@
1{ trap "echo got TERM" TERM; sleep 3; }& sleep 1; kill $!; wait
2echo Done: $?
diff --git a/shell/hush_test/hush-signals/sigquit_exec.right b/shell/hush_test/hush-signals/sigquit_exec.right
new file mode 100644
index 000000000..a8041929a
--- /dev/null
+++ b/shell/hush_test/hush-signals/sigquit_exec.right
@@ -0,0 +1,2 @@
1SigIgn: 0000000000000000
2SigIgn: 0000000000000000
diff --git a/shell/hush_test/hush-signals/sigquit_exec.tests b/shell/hush_test/hush-signals/sigquit_exec.tests
new file mode 100755
index 000000000..24bda6921
--- /dev/null
+++ b/shell/hush_test/hush-signals/sigquit_exec.tests
@@ -0,0 +1,4 @@
1# Should show no masked signals in both cases.
2# We had a bug where SIGQUIT was masked on exec.
3grep SigIgn: /proc/self/status
4exec grep SigIgn: /proc/self/status
diff --git a/shell/hush_test/hush-standalone/noexec_gets_no_env.right b/shell/hush_test/hush-standalone/noexec_gets_no_env.right
new file mode 100644
index 000000000..8522dff31
--- /dev/null
+++ b/shell/hush_test/hush-standalone/noexec_gets_no_env.right
@@ -0,0 +1,4 @@
1VAR7=VAL
20
3VAR8=VAL
40
diff --git a/shell/hush_test/hush-standalone/noexec_gets_no_env.tests b/shell/hush_test/hush-standalone/noexec_gets_no_env.tests
new file mode 100755
index 000000000..0d347bdcd
--- /dev/null
+++ b/shell/hush_test/hush-standalone/noexec_gets_no_env.tests
@@ -0,0 +1,5 @@
1export VAR7=VAL
2env | grep ^VAR7=
3echo $?
4VAR8=VAL env | grep ^VAR8=
5echo $?
diff --git a/shell/hush_test/hush-standalone/nofork_trashes_getopt.right b/shell/hush_test/hush-standalone/nofork_trashes_getopt.right
new file mode 100644
index 000000000..573541ac9
--- /dev/null
+++ b/shell/hush_test/hush-standalone/nofork_trashes_getopt.right
@@ -0,0 +1 @@
0
diff --git a/shell/hush_test/hush-standalone/nofork_trashes_getopt.tests b/shell/hush_test/hush-standalone/nofork_trashes_getopt.tests
new file mode 100755
index 000000000..f42c50730
--- /dev/null
+++ b/shell/hush_test/hush-standalone/nofork_trashes_getopt.tests
@@ -0,0 +1,6 @@
1# In this test, rm is NOFORK and it modifies getopt internal state
2rm -f non_existent_file
3# Subsequent hexdump is run as NOEXEC, and thus still uses this state
4hexdump </dev/null
5# Did hexdump segfault etc?
6echo $?
diff --git a/shell/hush_test/hush-standalone/var_standalone1.right b/shell/hush_test/hush-standalone/var_standalone1.right
new file mode 100644
index 000000000..37457fd74
--- /dev/null
+++ b/shell/hush_test/hush-standalone/var_standalone1.right
@@ -0,0 +1 @@
Done: 1
diff --git a/shell/hush_test/hush-standalone/var_standalone1.tests b/shell/hush_test/hush-standalone/var_standalone1.tests
new file mode 100755
index 000000000..1e905ba75
--- /dev/null
+++ b/shell/hush_test/hush-standalone/var_standalone1.tests
@@ -0,0 +1,2 @@
1VAR=42 $THIS_SH -c 'unset VAR; env | grep ^VAR'
2echo Done: $?