Index: contrib/netbsd-tests/usr.bin/grep/d_color_a.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_color_a.in @@ -0,0 +1 @@ +abcd* Index: contrib/netbsd-tests/usr.bin/grep/d_color_a.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_color_a.out @@ -0,0 +1 @@ +abcd* Index: contrib/netbsd-tests/usr.bin/grep/d_color_b.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_color_b.in @@ -0,0 +1,5 @@ +fojeiwuroiuwet +ljfajsljkfabcdddjlfkajlkj +abcaaa +zzzabc + Index: contrib/netbsd-tests/usr.bin/grep/d_color_b.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_color_b.out @@ -0,0 +1,3 @@ +ljfajsljkfabcdddjlfkajlkj +abcaaa +zzzabc Index: contrib/netbsd-tests/usr.bin/grep/d_color_c.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_color_c.out @@ -0,0 +1,3 @@ +ljfajsljkfabcdddjlfkajlkj +abcaaa +zzzabc Index: contrib/netbsd-tests/usr.bin/grep/d_escmap.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_escmap.in @@ -0,0 +1 @@ +f.oo Index: contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_f_file_empty.in @@ -0,0 +1,2 @@ +Fish zebra monkey suits + Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.in @@ -0,0 +1 @@ +01:1:01 Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_a.out @@ -0,0 +1,3 @@ +0 +: +:0 Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.in @@ -0,0 +1 @@ +1:1:01 Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_b.out @@ -0,0 +1,2 @@ +: +:0 Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.in @@ -0,0 +1 @@ +bla bla Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_c.out @@ -0,0 +1,2 @@ +bla +bla Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_d.in @@ -0,0 +1,3 @@ +bla +bla + Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.in @@ -0,0 +1 @@ +abcdef Index: contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out =================================================================== --- /dev/null +++ contrib/netbsd-tests/usr.bin/grep/d_oflag_zerolen_e.out @@ -0,0 +1 @@ +ab Index: contrib/netbsd-tests/usr.bin/grep/t_grep.sh =================================================================== --- contrib/netbsd-tests/usr.bin/grep/t_grep.sh +++ contrib/netbsd-tests/usr.bin/grep/t_grep.sh @@ -226,10 +226,102 @@ 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" "Checks behavior of zero-length matches with -o flag" +} +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" +} +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" "Checks behavior using --color" +} +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 -f file" +} +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 for validity in building escaped dot maps of pattern" +} +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 invalidly empty pattern" +} +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_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 } Index: usr.bin/grep/tests/Makefile =================================================================== --- usr.bin/grep/tests/Makefile +++ usr.bin/grep/tests/Makefile @@ -8,6 +8,11 @@ ${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_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