summaryrefslogtreecommitdiff
path: root/contrib/netbsd-tests
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2019-09-25 17:14:43 +0000
committerKyle Evans <kevans@FreeBSD.org>2019-09-25 17:14:43 +0000
commit38325e2ab8f0c7823e31df13bfc52e38e7f6d616 (patch)
treec072427d77503a8c6e447ee6e9de504e85d978ff /contrib/netbsd-tests
parent2b93f779d22332da86a5398e59b57a5e27b9ffb6 (diff)
downloadsrc-test2-38325e2ab8f0c7823e31df13bfc52e38e7f6d616.tar.gz
src-test2-38325e2ab8f0c7823e31df13bfc52e38e7f6d616.zip
Notes
Diffstat (limited to 'contrib/netbsd-tests')
-rwxr-xr-xcontrib/netbsd-tests/usr.bin/grep/t_grep.sh64
1 files changed, 63 insertions, 1 deletions
diff --git a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
index d6d0d46f4ac3..c5c47e992378 100755
--- a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+++ b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
@@ -413,6 +413,60 @@ wflag_emptypat_body()
atf_check -o file:test4 grep -w -e "" test4
}
+atf_test_case xflag_emptypat
+xflag_emptypat_body()
+{
+ printf "" > test1
+ printf "\n" > test2
+ printf "qaz" > test3
+ printf " qaz\n" > test4
+
+ # -x is whole-line, more strict than -w.
+ atf_check -s exit:1 -o empty grep -x -e "" test1
+
+ atf_check -o file:test2 grep -x -e "" test2
+
+ atf_check -s exit:1 -o empty grep -x -e "" test3
+
+ atf_check -s exit:1 -o empty grep -x -e "" test4
+
+ total=$(wc -l /COPYRIGHT | sed 's/[^0-9]//g')
+
+ # Simple checks that grep -x with an empty pattern isn't matching every
+ # line. The exact counts aren't important, as long as they don't
+ # match the total line count and as long as they don't match each other.
+ atf_check -o save:xpositive.count grep -Fxc '' /COPYRIGHT
+ atf_check -o save:xnegative.count grep -Fvxc '' /COPYRIGHT
+
+ atf_check -o not-inline:"${total}" cat xpositive.count
+ atf_check -o not-inline:"${total}" cat xnegative.count
+
+ atf_check -o not-file:xnegative.count cat xpositive.count
+}
+
+atf_test_case xflag_emptypat_plus
+xflag_emptypat_plus_body()
+{
+ printf "foo\n\nbar\n\nbaz\n" > target
+ printf "foo\n \nbar\n \nbaz\n" > target_spacelines
+ printf "foo\nbar\nbaz\n" > matches
+ printf " \n \n" > spacelines
+
+ printf "foo\n\nbar\n\nbaz\n" > patlist1
+ printf "foo\n\nba\n\nbaz\n" > patlist2
+
+ sed -e '/bar/d' target > matches_not2
+
+ # Normal handling first
+ atf_check -o file:target grep -Fxf patlist1 target
+ atf_check -o file:matches grep -Fxf patlist1 target_spacelines
+ atf_check -o file:matches_not2 grep -Fxf patlist2 target
+
+ # -v handling
+ atf_check -s exit:1 -o empty grep -Fvxf patlist1 target
+ atf_check -o file:spacelines grep -Fxvf patlist1 target_spacelines
+}
+
atf_test_case excessive_matches
excessive_matches_head()
{
@@ -551,6 +605,12 @@ grep_nomatch_flags_head()
grep_nomatch_flags_body()
{
+ grep_type
+
+ if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then
+ atf_expect_fail "this test does not pass with GNU grep in base"
+ fi
+
printf "A\nB\nC\n" > test1
atf_check -o inline:"1\n" grep -c -C 1 -e "B" test1
@@ -563,7 +623,7 @@ grep_nomatch_flags_body()
atf_check -o inline:"test1\n" grep -l -A 1 -e "B" test1
atf_check -o inline:"test1\n" grep -l -C 1 -e "B" test1
- atf_check -s exit:1 -o inline:"test1\n" grep -L -e "D" test1
+ atf_check -o inline:"test1\n" grep -L -e "D" test1
atf_check -o empty grep -q -e "B" test1
atf_check -o empty grep -q -B 1 -e "B" test1
@@ -777,6 +837,8 @@ atf_init_test_cases()
atf_add_test_case egrep_empty_invalid
atf_add_test_case zerolen
atf_add_test_case wflag_emptypat
+ atf_add_test_case xflag_emptypat
+ atf_add_test_case xflag_emptypat_plus
atf_add_test_case excessive_matches
atf_add_test_case wv_combo_break
atf_add_test_case fgrep_sanity