diff options
author | Ed Maste <emaste@FreeBSD.org> | 2017-05-15 20:41:29 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2017-05-15 20:41:29 +0000 |
commit | f701bdc59e6589aed410dd1b28267d43ed93414f (patch) | |
tree | 6cd658d0bffc701e1eb0f089789d746d07226287 /contrib | |
parent | a520574d76c8a66a5fa90825b14e9e4d04bece5c (diff) | |
download | src-f701bdc59e6589aed410dd1b28267d43ed93414f.tar.gz src-f701bdc59e6589aed410dd1b28267d43ed93414f.zip |
bsdgrep: add more tests for different binary flags
The existing 'binary' test in netbsd-tests/ does a basic check of the
default treatment for binary behavior, but not much more than that.
Given some opportunity for breakage recently that did not trigger any
failures, add some tests to cover the three different binary file
behaviors (a, -I, -U) and their --binary-files= equivalent values.
Submitted by: Kyle Evans <kevans91@ksu.edu>
Reviewed by: cem, ngie
Differential Revision: https://reviews.freebsd.org/D10620
Notes
Notes:
svn path=/head/; revision=318317
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/netbsd-tests/usr.bin/grep/t_grep.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh index 95e92b2d9d00..05d06f6ba8dd 100755 --- a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh +++ b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh @@ -539,6 +539,41 @@ badcontext_body() atf_check -s not-exit:0 -e ignore grep -C "B" "B" test1 } + +atf_test_case binary_flags +binary_flags_head() +{ + atf_set "descr" "Check output for binary flags (-a, -I, -U, --binary-files)" +} +binary_flags_body() +{ + printf "A\000B\000C" > test1 + printf "A\n\000B\n\000C" > test2 + binmatchtext="Binary file test1 matches\n" + + # Binaries not treated as text (default, -U) + atf_check -o inline:"${binmatchtext}" grep 'B' test1 + atf_check -o inline:"${binmatchtext}" grep 'B' -C 1 test1 + + atf_check -o inline:"${binmatchtext}" grep -U 'B' test1 + atf_check -o inline:"${binmatchtext}" grep -U 'B' -C 1 test1 + + # Binary, -a, no newlines + atf_check -o inline:"A\000B\000C\n" grep -a 'B' test1 + atf_check -o inline:"A\000B\000C\n" grep -a 'B' -C 1 test1 + + # Binary, -a, newlines + atf_check -o inline:"\000B\n" grep -a 'B' test2 + atf_check -o inline:"A\n\000B\n\000C\n" grep -a 'B' -C 1 test2 + + # Binary files ignored + atf_check -s exit:1 grep -I 'B' test2 + + # --binary-files equivalence + atf_check -o inline:"${binmatchtext}" grep --binary-files=binary 'B' test1 + atf_check -o inline:"A\000B\000C\n" grep --binary-files=text 'B' test1 + atf_check -s exit:1 grep --binary-files=without-match 'B' test2 +} # End FreeBSD atf_init_test_cases() @@ -573,6 +608,7 @@ atf_init_test_cases() atf_add_test_case egrep_sanity atf_add_test_case grep_sanity atf_add_test_case grep_nomatch_flags + atf_add_test_case binary_flags atf_add_test_case badcontext # End FreeBSD } |