diff options
author | Rob Landley <rob@landley.net> | 2021-03-16 02:29:15 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-03-16 02:29:15 -0500 |
commit | 8c7af93bde1798da7d59182201b3599158bf926d (patch) | |
tree | 72aab1708cabb546ce489d2f459564b40e038dfb /scripts | |
parent | e63c9967423b5b9c6fc48d2b31a04e3c030bc16a (diff) | |
download | toybox-8c7af93bde1798da7d59182201b3599158bf926d.tar.gz |
Add more shell tests, and teach txpect to do regex matches (RO and RE).
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/runtest.sh | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 6aad9ff1..158ed7fa 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -61,7 +61,7 @@ optional() # Not set? if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] then - SKIP="" + unset SKIP return fi SKIP=1 @@ -183,6 +183,8 @@ do_fail() # X means close stdin/stdout/stderr and match return code (blank means nonzero) txpect() { + local NAME CASE VERBOSITY LEN A B + # Run command with redirection through fifos NAME="$CMDNAME $1" CASE= @@ -206,16 +208,18 @@ txpect() LEN=$((${#1}-1)) CASE="$1" A= + B= case ${1::1} in # send input to child I) printf %s "${1:1}" >&$IN || { do_fail;break;} ;; + R) LEN=0; B=1; ;& # check output from child [OE]) [ $LEN == 0 ] && LARG="" || LARG="-rN $LEN" O=$OUT - [ ${1::1} == 'E' ] && O=$ERR + [ "${1:$B:1}" == 'E' ] && O=$ERR A= read -t2 $LARG A <&$O VERBOSITY="$VERBOSITY"$'\n'"$A" @@ -223,8 +227,9 @@ txpect() then [ -z "$A" ] && { do_fail;break;} else - if [ "$A" != "${1:1}" ] - then + if [ ${1::1} == 'R' ] && [[ "$A" =~ "${1:2}" ]]; then true + elif [ ${1::1} != 'R' ] && [ "$A" == "${1:1}" ]; then true + else # Append the rest of the output if there is any. read -t.1 B <&$O A="$A$B" |