Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Aug 2017 00:55:56 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r322561 - stable/11/contrib/netbsd-tests/usr.bin/grep
Message-ID:  <201708160055.v7G0tun2042078@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Aug 16 00:55:56 2017
New Revision: 322561
URL: https://svnweb.freebsd.org/changeset/base/322561

Log:
  bsdgrep: Revise tests based on recent fixes and future changes
  
  MFC r317297: Remove the expected failures for :context and :context2 with
  bsdgrep(1)
  
  They're no longer needed after recent fixes made to bsdgrep(1).
  
  MFC r317299: Add more sanity tests for grep, egrep, and fgrep
  
  The test suite currently lacks basic sanity checks to ensure that egrep,
  fgrep, and grep are actually matching the right expression types, i.e.
  passing the right flags to regcomp(3). Amend the test suite to make sure
  that not only are the individual versions doing the right thing, but also
  that we don't have some kind of frankenregex situation happening where egrep
  is accepting a BRE or grep an ERE.
  
  I've chosen to not expand the 'basic' test but to add the 'grep_sanity'
  checks to their own test case since this is testing for more than just
  'grep matches things', but actual expression types.
  
  MFC r317694: bsdgrep: revise test case which will soon become a failure
  
  Work in progress (D10315) is going to make egrep_empty_invalid an
  actually invalid regex, to be consistent with the equivalent BRE "{"
  behavior, when using regex(3).
  
  Any non-0 exit value is acceptable, depending on how the installed grep
  interprets the expression. GNU grep interprets it as non-matching, and
  in the future BSD grep will interpret it is an error.
  
  Approved by:	emaste (mentor, blanket MFC)

Modified:
  stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
==============================================================================
--- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh	Wed Aug 16 00:47:53 2017	(r322560)
+++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh	Wed Aug 16 00:55:56 2017	(r322561)
@@ -159,12 +159,6 @@ context_head()
 }
 context_body()
 {
-	# Begin FreeBSD
-	grep_type
-	if [ $? -eq $GREP_TYPE_BSD ]; then
-		atf_expect_fail "this test doesn't pass with BSD grep yet"
-	fi
-	# End FreeBSD
 	cp $(atf_get_srcdir)/d_context_*.* .
 
 	atf_check -o file:d_context_a.out grep -C2 bamboo d_context_a.in
@@ -226,12 +220,6 @@ context2_head()
 }
 context2_body()
 {
-	# Begin FreeBSD
-	grep_type
-	if [ $? -eq $GREP_TYPE_BSD ]; then
-		atf_expect_fail "this test doesn't pass with BSD grep yet"
-	fi
-	# End FreeBSD
 	printf "haddock\000cod\000plaice\000" > test1
 	printf "mackeral\000cod\000crab\000" > test2
 
@@ -375,7 +363,7 @@ egrep_empty_invalid_head()
 }
 egrep_empty_invalid_body()
 {
-	atf_check -s exit:1 egrep '{' /dev/null
+	atf_check -e ignore -s not-exit:0 egrep '{' /dev/null
 }
 
 atf_test_case zerolen
@@ -391,6 +379,66 @@ zerolen_body()
 
 	atf_check -o inline:"Eggs\nCheese\n" grep -v -e "^$" test1
 }
+
+atf_test_case fgrep_sanity
+fgrep_sanity_head()
+{
+	atf_set "descr" "Check for fgrep sanity, literal expressions only"
+}
+fgrep_sanity_body()
+{
+	printf "Foo" > test1
+
+	atf_check -o inline:"Foo\n" fgrep -e "Foo" test1
+
+	atf_check -s exit:1 -o empty fgrep -e "Fo." test1
+}
+
+atf_test_case egrep_sanity
+egrep_sanity_head()
+{
+	atf_set "descr" "Check for egrep sanity, EREs only"
+}
+egrep_sanity_body()
+{
+	printf "Foobar(ed)" > test1
+	printf "M{1}" > test2
+
+	atf_check -o inline:"Foo\n" egrep -o -e "F.." test1
+
+	atf_check -o inline:"Foobar\n" egrep -o -e "F[a-z]*" test1
+
+	atf_check -o inline:"Fo\n" egrep -o -e "F(o|p)" test1
+
+	atf_check -o inline:"(ed)\n" egrep -o -e "\(ed\)" test1
+
+	atf_check -o inline:"M\n" egrep -o -e "M{1}" test2
+
+	atf_check -o inline:"M{1}\n" egrep -o -e "M\{1\}" test2
+}
+
+atf_test_case grep_sanity
+grep_sanity_head()
+{
+	atf_set "descr" "Check for basic grep sanity, BREs only"
+}
+grep_sanity_body()
+{
+	printf "Foobar(ed)" > test1
+	printf "M{1}" > test2
+
+	atf_check -o inline:"Foo\n" grep -o -e "F.." test1
+
+	atf_check -o inline:"Foobar\n" grep -o -e "F[a-z]*" test1
+
+	atf_check -o inline:"Fo\n" grep -o -e "F\(o\)" test1
+
+	atf_check -o inline:"(ed)\n" grep -o -e "(ed)" test1
+
+	atf_check -o inline:"M{1}\n" grep -o -e "M{1}" test2
+
+	atf_check -o inline:"M\n" grep -o -e "M\{1\}" test2
+}
 # End FreeBSD
 
 atf_init_test_cases()
@@ -419,5 +467,8 @@ atf_init_test_cases()
 	atf_add_test_case escmap
 	atf_add_test_case egrep_empty_invalid
 	atf_add_test_case zerolen
+	atf_add_test_case fgrep_sanity
+	atf_add_test_case egrep_sanity
+	atf_add_test_case grep_sanity
 # End FreeBSD
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708160055.v7G0tun2042078>