From owner-svn-src-all@freebsd.org Sat Apr 22 21:40:11 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7ACDAD4BA3F; Sat, 22 Apr 2017 21:40:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E0CFEF5; Sat, 22 Apr 2017 21:40:11 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3MLeAbT001110; Sat, 22 Apr 2017 21:40:10 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3MLeAik001109; Sat, 22 Apr 2017 21:40:10 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201704222140.v3MLeAik001109@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 22 Apr 2017 21:40:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317299 - head/contrib/netbsd-tests/usr.bin/grep X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Apr 2017 21:40:11 -0000 Author: ngie Date: Sat Apr 22 21:40:10 2017 New Revision: 317299 URL: https://svnweb.freebsd.org/changeset/base/317299 Log: 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. Differential Revision: D10444 Reviewed by: emaste, ngie Submitted by: Kyle Evans Tested with: bsdgrep, gnu grep (base, ports) Sponsored by: Dell EMC Isilon Modified: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Modified: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Sat Apr 22 21:31:37 2017 (r317298) +++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Sat Apr 22 21:40:10 2017 (r317299) @@ -379,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() @@ -407,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 }