aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-01-14 02:03:59 -0600
committerRob Landley <rob@landley.net>2021-01-14 02:03:59 -0600
commitb3910f4871f05ed3c90dab7aa7e9cc25abae2c91 (patch)
tree24a328da9b8684fd9cfd6d2fa0a1046f2c2723c4 /tests
parente7c86f7d79f641ab8a0e542d32e857494e943389 (diff)
downloadtoybox-b3910f4871f05ed3c90dab7aa7e9cc25abae2c91.tar.gz
A few more shell tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/sh.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/sh.test b/tests/sh.test
index 1d021acd..58fd6dad 100644
--- a/tests/sh.test
+++ b/tests/sh.test
@@ -1,5 +1,7 @@
#!/bin/echo no
+# TODO: categorize tests
+
# TODO https://mywiki.wooledge.org/BashFAQ
# http://tiswww.case.edu/php/chet/bash/FAQ
# https://mywiki.wooledge.org/BashPitfalls#set_-euo_pipefail
@@ -206,6 +208,9 @@ testing 'loop in && ||' \
'false && for i in a b c; do echo $i; done || echo no' 'no\n' '' ''
testing "continue" 'for i in a b c; do for j in d e f; do echo $i $j; continue 2; done; done' \
"a d\nb d\nc d\n" "" ""
+testing "piped loops that don't exit" \
+ 'while X=$(($X+1)); do echo $X; done | while read i; do echo $i; done | head -n 5' \
+ '1\n2\n3\n4\n5\n' '' ''
# <glinda>A variable occurred</glinda>
@@ -238,6 +243,11 @@ testing "{5..1}" "echo {5..1}" "5 4 3 2 1\n" "" ""
testing "{5..1..2}" "echo {5..1..2}" "5 3 1\n" "" ""
testing "{a..z..-3}" "echo {a..z..-3}" "a d g j m p s v y\n" "" ""
+mkfifo POIT
+testing 'background curly block' \
+ '{ sed s/ll/xx/ POIT; }& echo hello > POIT; wait' 'hexxo\n' '' ''
+rm -f POIT
+
testing 'background pipe block' \
'if true; then { sleep .25;bzcat "$FILES"/blkid/ntfs.bz2; }& fi | wc -c' \
'8388608\n' '' ''
@@ -481,6 +491,10 @@ shxpect '[+(]) overlap priority' I$'shopt -s extglob\n' E"$P" \
shxpect '${a?b} sets err, stops cmdline eval' \
I$': ${a?b} ${c:=d}\n' E E"$P" I$'echo $?$c\n' O$'1\n'
+shxpect 'trace redirect' I$'set -x; echo one\n' E$'+ echo one\n'"$P" O$'one\n' \
+ I$'echo two 2>/dev/null\n' O$'two\n' E$'+ echo two\n'"$P" \
+ I$'{ echo three; } 2>/dev/null\n' O$'three\n' E"$P"
+
testing 'source file' 'source input' 'hello\n' 'echo hello \\\n' ''
testing '. file' '. input' 'hello\n' 'echo hello \\\n' ''
testing 'source no newline' 'source input' 'hello \\\n' 'echo hello \\' ''
@@ -520,3 +534,13 @@ testing 'source no newline' 'source input' 'hello \\\n' 'echo hello \\' ''
#TMOUT - used by read
# does not match: ./sh -c 'echo {a..Z}' becomes a ` _ ^ ] \ [ Z
+
+# commit ec6639407b9e
+#- IS_TOYBOX_RE='(toybox|This is not GNU).*'
+#- [[ "$IS_TOYBOX" =~ $IS_TOYBOX_RE ]] || SKIPNEXT=1
+#+ case "$IS_TOYBOX" in
+#+ toybox*) ;;
+#+ This\ is\ not\ GNU*) ;;
+#+ *) SKIPNEXT=1 ;;
+#+ esac
+