diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-22 04:38:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-22 04:38:07 +0000 |
commit | 28ef1abc10cfbc2c3d2747c008eb2300858d0426 (patch) | |
tree | 41208fb8f393e6cb6cc8f939623ad47a0db17876 /tests/invalid-multibyte-infloop | |
download | grep-tarball-master.tar.gz |
Diffstat (limited to 'tests/invalid-multibyte-infloop')
-rwxr-xr-x | tests/invalid-multibyte-infloop | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/invalid-multibyte-infloop b/tests/invalid-multibyte-infloop new file mode 100755 index 0000000..d7c6165 --- /dev/null +++ b/tests/invalid-multibyte-infloop @@ -0,0 +1,39 @@ +#!/bin/sh +# Ensure that we don't trigger a grep -F infloop. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +require_en_utf8_locale_ +require_compiled_in_MB_support +require_timeout_ + +encode() { echo "$1" | tr A '\202'; } + +encode AA > input + +fail=0 + +# Before 2.15, this would infloop. +LC_ALL=en_US.UTF-8 timeout 3 grep -aF $(encode A) input > out +status=$? +if test $status -eq 0; then + compare input out +elif test $status -eq 1; then + compare_dev_null_ /dev/null out +else + test $status -eq 2 +fi || fail=1 + +echo 'Binary file input matches' >binary-file-matches + +LC_ALL=en_US.UTF-8 timeout 3 grep -F $(encode A) input > out +status=$? +if test $status -eq 0; then + compare binary-file-matches out +elif test $status -eq 1; then + compare_dev_null_ /dev/null out +else + test $status -eq 2 +fi || fail=1 + +Exit $fail |