bsdgrep: create additional tests for coverage on recent fixes
Create additional tests to cover regressions that were discovered by PRs linked to reviews D10098, D10102, and D10104. It is worth noting that neither bsdgrep(1) nor gnugrep(1) in the base system currently pass all of these tests, and gnugrep(1) not quite being up to snuff was also noted in at least one of the PRs. PR: 175314 202022 195763 180990 197555 197531 181263 209116 Submitted by: Kyle Evans <kevans91@ksu.edu> Reviewed by: cem, ngie, emaste MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D10112
This commit is contained in:
parent
4db3787dd9
commit
799c5faa8b
1
contrib/netbsd-tests/usr.bin/grep/d_color_a.in
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_color_a.in
Normal file
@ -0,0 +1 @@
|
||||
abcd*
|
1
contrib/netbsd-tests/usr.bin/grep/d_color_a.out
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_color_a.out
Normal file
@ -0,0 +1 @@
|
||||
abcd*
|
5
contrib/netbsd-tests/usr.bin/grep/d_color_b.in
Normal file
5
contrib/netbsd-tests/usr.bin/grep/d_color_b.in
Normal file
@ -0,0 +1,5 @@
|
||||
fojeiwuroiuwet
|
||||
ljfajsljkfabcdddjlfkajlkj
|
||||
abcaaa
|
||||
zzzabc
|
||||
|
3
contrib/netbsd-tests/usr.bin/grep/d_color_b.out
Normal file
3
contrib/netbsd-tests/usr.bin/grep/d_color_b.out
Normal file
@ -0,0 +1,3 @@
|
||||
ljfajsljkfabcdddjlfkajlkj
|
||||
abcaaa
|
||||
zzzabc
|
3
contrib/netbsd-tests/usr.bin/grep/d_color_c.out
Normal file
3
contrib/netbsd-tests/usr.bin/grep/d_color_c.out
Normal file
@ -0,0 +1,3 @@
|
||||
ljfajsljkf[01;31m[Kabcddd[m[Kjlfkajlkj
|
||||
[01;31m[Kabc[m[Kaaa
|
||||
zzz[01;31m[Kabc[m[K
|
1
contrib/netbsd-tests/usr.bin/grep/d_escmap.in
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_escmap.in
Normal file
@ -0,0 +1 @@
|
||||
f.oo
|
2
contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in
Normal file
2
contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in
Normal file
@ -0,0 +1,2 @@
|
||||
Fish zebra monkey suits
|
||||
|
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in
Normal file
@ -0,0 +1 @@
|
||||
01:1:01
|
3
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out
Normal file
3
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out
Normal file
@ -0,0 +1,3 @@
|
||||
0
|
||||
:
|
||||
:0
|
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in
Normal file
@ -0,0 +1 @@
|
||||
1:1:01
|
2
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out
Normal file
2
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out
Normal file
@ -0,0 +1,2 @@
|
||||
:
|
||||
:0
|
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in
Normal file
@ -0,0 +1 @@
|
||||
bla bla
|
2
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out
Normal file
2
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out
Normal file
@ -0,0 +1,2 @@
|
||||
bla
|
||||
bla
|
3
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in
Normal file
3
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in
Normal file
@ -0,0 +1,3 @@
|
||||
bla
|
||||
bla
|
||||
|
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in
Normal file
@ -0,0 +1 @@
|
||||
abcdef
|
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out
Normal file
1
contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out
Normal file
@ -0,0 +1 @@
|
||||
ab
|
@ -226,10 +226,102 @@ context2_body()
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_context2_c.out" \
|
||||
grep -z -C1 cod test1 test2
|
||||
}
|
||||
# Begin FreeBSD
|
||||
atf_test_case oflag_zerolen
|
||||
oflag_zerolen_head()
|
||||
{
|
||||
atf_set "descr" "Check behavior of zero-length matches with -o flag (PR 195763)"
|
||||
}
|
||||
oflag_zerolen_body()
|
||||
{
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_a.out" \
|
||||
grep -Eo '(^|:)0*' "$(atf_get_srcdir)/d_oflag_zerolen_a.in"
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_b.out" \
|
||||
grep -Eo '(^|:)0*' "$(atf_get_srcdir)/d_oflag_zerolen_b.in"
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_c.out" \
|
||||
grep -Eo '[[:alnum:]]*' "$(atf_get_srcdir)/d_oflag_zerolen_c.in"
|
||||
|
||||
atf_check -o empty grep -Eo '' "$(atf_get_srcdir)/d_oflag_zerolen_d.in"
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_e.out" \
|
||||
grep -o -e 'ab' -e 'bc' "$(atf_get_srcdir)/d_oflag_zerolen_e.in"
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_oflag_zerolen_e.out" \
|
||||
grep -o -e 'bc' -e 'ab' "$(atf_get_srcdir)/d_oflag_zerolen_e.in"
|
||||
}
|
||||
|
||||
atf_test_case xflag
|
||||
xflag_head()
|
||||
{
|
||||
atf_set "descr" "Check that we actually get a match with -x flag (PR 180990)"
|
||||
}
|
||||
xflag_body()
|
||||
{
|
||||
echo 128 > match_file
|
||||
seq 1 128 > pattern_file
|
||||
grep -xf pattern_file match_file
|
||||
}
|
||||
|
||||
atf_test_case color
|
||||
color_head()
|
||||
{
|
||||
atf_set "descr" "Check --color support"
|
||||
}
|
||||
color_body()
|
||||
{
|
||||
echo 'abcd*' > grepfile
|
||||
echo 'abc$' >> grepfile
|
||||
echo '^abc' >> grepfile
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_color_a.out" \
|
||||
grep --color=auto -e '.*' -e 'a' "$(atf_get_srcdir)/d_color_a.in"
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_color_b.out" \
|
||||
grep --color=auto -f grepfile "$(atf_get_srcdir)/d_color_b.in"
|
||||
|
||||
atf_check -o file:"$(atf_get_srcdir)/d_color_c.out" \
|
||||
grep --color=always -f grepfile "$(atf_get_srcdir)/d_color_b.in"
|
||||
}
|
||||
|
||||
atf_test_case f_file_empty
|
||||
f_file_empty_head()
|
||||
{
|
||||
atf_set "descr" "Check for handling of a null byte in empty file, specified by -f (PR 202022)"
|
||||
}
|
||||
f_file_empty_body()
|
||||
{
|
||||
printf "\0\n" > nulpat
|
||||
|
||||
atf_check -s exit:1 grep -f nulpat "$(atf_get_srcdir)/d_f_file_empty.in"
|
||||
}
|
||||
|
||||
atf_test_case escmap
|
||||
escmap_head()
|
||||
{
|
||||
atf_set "descr" "Check proper handling of escaped vs. unescaped dot expressions (PR 175314)"
|
||||
}
|
||||
escmap_body()
|
||||
{
|
||||
atf_check -s exit:1 grep -o 'f.o\.' "$(atf_get_srcdir)/d_escmap.in"
|
||||
atf_check -o not-empty grep -o 'f.o.' "$(atf_get_srcdir)/d_escmap.in"
|
||||
}
|
||||
|
||||
atf_test_case egrep_empty_invalid
|
||||
egrep_empty_invalid_head()
|
||||
{
|
||||
atf_set "descr" "Check for handling of an invalid empty pattern (PR 194823)"
|
||||
}
|
||||
egrep_empty_invalid_body()
|
||||
{
|
||||
atf_check -s exit:1 egrep '{' /dev/null
|
||||
}
|
||||
# End FreeBSD
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case basic
|
||||
atf_add_test_case basic
|
||||
atf_add_test_case binary
|
||||
atf_add_test_case recurse
|
||||
atf_add_test_case recurse_symlink
|
||||
@ -245,4 +337,12 @@ atf_init_test_cases()
|
||||
atf_add_test_case zgrep
|
||||
atf_add_test_case nonexistent
|
||||
atf_add_test_case context2
|
||||
# Begin FreeBSD
|
||||
atf_add_test_case oflag_zerolen
|
||||
atf_add_test_case xflag
|
||||
atf_add_test_case color
|
||||
atf_add_test_case f_file_empty
|
||||
atf_add_test_case escmap
|
||||
atf_add_test_case egrep_empty_invalid
|
||||
# End FreeBSD
|
||||
}
|
||||
|
@ -8,6 +8,11 @@ ${PACKAGE}FILES+= d_basic.out
|
||||
${PACKAGE}FILES+= d_begin_end_a.out
|
||||
${PACKAGE}FILES+= d_begin_end_b.out
|
||||
${PACKAGE}FILES+= d_binary.out
|
||||
${PACKAGE}FILES+= d_color_a.in
|
||||
${PACKAGE}FILES+= d_color_a.out
|
||||
${PACKAGE}FILES+= d_color_b.in
|
||||
${PACKAGE}FILES+= d_color_b.out
|
||||
${PACKAGE}FILES+= d_color_c.out
|
||||
${PACKAGE}FILES+= d_context2_a.out
|
||||
${PACKAGE}FILES+= d_context2_b.out
|
||||
${PACKAGE}FILES+= d_context2_c.out
|
||||
@ -18,12 +23,23 @@ ${PACKAGE}FILES+= d_context_b.out
|
||||
${PACKAGE}FILES+= d_context_c.out
|
||||
${PACKAGE}FILES+= d_context_d.out
|
||||
${PACKAGE}FILES+= d_egrep.out
|
||||
${PACKAGE}FILES+= d_escmap.in
|
||||
${PACKAGE}FILES+= d_f_file_empty.in
|
||||
${PACKAGE}FILES+= d_file_exp.in
|
||||
${PACKAGE}FILES+= d_file_exp.out
|
||||
${PACKAGE}FILES+= d_ignore_case.out
|
||||
${PACKAGE}FILES+= d_input
|
||||
${PACKAGE}FILES+= d_invert.in
|
||||
${PACKAGE}FILES+= d_invert.out
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_a.in
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_a.out
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_b.in
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_b.out
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_c.in
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_c.out
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_d.in
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_e.in
|
||||
${PACKAGE}FILES+= d_oflag_zerolen_e.out
|
||||
${PACKAGE}FILES+= d_recurse.out
|
||||
${PACKAGE}FILES+= d_recurse_symlink.err
|
||||
${PACKAGE}FILES+= d_recurse_symlink.out
|
||||
|
Loading…
x
Reference in New Issue
Block a user