diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-09-17 09:20:29 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-09-17 09:20:29 +0000 |
commit | 50b45fa0fbccc844732873a1b26dcff259dd0ad1 (patch) | |
tree | 98a102a43ac394bc60f2687563993d6c392b0816 /regress/usr.bin/sed/substitute.sh | |
parent | 7c1a5132c7c252a57ef25d9007decab1e6eb2b8c (diff) |
Also test input files ending without a newline,
and catch NUL characters in the sed output.
That requires using hexdump(1), which also makes
the test suite output more intelligible in case of errors.
Of course, many tests still fail, until i commit my patch to sed.
Diffstat (limited to 'regress/usr.bin/sed/substitute.sh')
-rwxr-xr-x | regress/usr.bin/sed/substitute.sh | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/regress/usr.bin/sed/substitute.sh b/regress/usr.bin/sed/substitute.sh index 233092e62ca..92a3158757c 100755 --- a/regress/usr.bin/sed/substitute.sh +++ b/regress/usr.bin/sed/substitute.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: substitute.sh,v 1.2 2011/07/24 13:16:18 schwarze Exp $ +# $OpenBSD: substitute.sh,v 1.3 2011/09/17 09:20:28 schwarze Exp $ # # Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> # @@ -29,16 +29,23 @@ err=0 # wanted output tf() { in=$1 - expr=$2 - flag=$3 + patt="s/$2/x/$3" want=$4 - out=`echo "$in" | sed -E "s/$expr/x/$flag"` - [ "X$out" = "X$want" ] || \ - echo "$in/$expr/$flag/$want/$out ($((++err)))" - [ -z "$in" ] && return - out=`echo -n "$in" | sed -E "s/$expr/x/$flag"` - [ "X$out" = "X$want" ] || \ - echo "-n:$in/$expr/$flag/$want/$out ($((++err)))" + hexwant=`echo $want | hexdump -C` + hexout=`echo "$in" | sed -E "$patt" | hexdump -C` + if [ "X$hexout" != "X$hexwant" ]; then + echo "patt: $patt input: \"$in\\\\n\"" + echo "want:" $hexwant + echo "got: " $hexout + fi + [ -z "$in" ] && want="" + hexwant=`echo -n $want | hexdump -C` + hexout=`echo -n "$in" | sed -E "$patt" | hexdump -C` + if [ "X$hexout" != "X$hexwant" ]; then + echo "patt: $patt input: \"$in\\\\0\"" + echo "want:" $hexwant + echo "got: " $hexout + fi } # test function for various flags; arguments are: |