From owner-svn-src-all@freebsd.org Fri May 26 00:19:52 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 00311D7A711; Fri, 26 May 2017 00:19:51 +0000 (UTC) (envelope-from emaste@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 A8D0E17CF; Fri, 26 May 2017 00:19:51 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4Q0Joua000731; Fri, 26 May 2017 00:19:50 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4Q0JoOw000730; Fri, 26 May 2017 00:19:50 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201705260019.v4Q0JoOw000730@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 26 May 2017 00:19:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318908 - 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: Fri, 26 May 2017 00:19:52 -0000 Author: emaste Date: Fri May 26 00:19:50 2017 New Revision: 318908 URL: https://svnweb.freebsd.org/changeset/base/318908 Log: bsdgrep: add --mmap tests Basic sanity tests as well as coverage for the bug fixed in r318565. Submitted by: Kyle Evans Reviewed by: bapt, ngie Differential Revision: https://reviews.freebsd.org/D10827 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 Thu May 25 23:19:09 2017 (r318907) +++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Fri May 26 00:19:50 2017 (r318908) @@ -627,6 +627,46 @@ binary_flags_body() atf_check -o inline:"A\000B\000C\n" grep --binary-files=text 'B' test1 atf_check -s exit:1 grep --binary-files=without-match 'B' test2 } + +atf_test_case mmap +mmap_head() +{ + atf_set "descr" "Check basic matching with --mmap flag" +} +mmap_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU ]; then + atf_expect_fail "gnu grep from ports has no --mmap option" + fi + + printf "A\nB\nC\n" > test1 + + atf_check -s exit:0 -o inline:"B\n" grep --mmap -oe "B" test1 + atf_check -s exit:1 grep --mmap -e "Z" test1 +} + +atf_test_case mmap_eof_not_eol +mmap_eof_not_eol_head() +{ + atf_set "descr" "Check --mmap flag handling of encountering EOF without EOL (PR 165471, 219402)" +} +mmap_eof_not_eol_body() +{ + grep_type + if [ $? -eq $GREP_TYPE_GNU ]; then + atf_expect_fail "gnu grep from ports has no --mmap option" + fi + + printf "ABC" > test1 + jot -b " " -s "" 4096 >> test2 + + atf_check -s exit:0 -o inline:"B\n" grep --mmap -oe "B" test1 + # Dependency on jemalloc(3) to detect buffer overflow, otherwise this + # unreliably produces a SIGSEGV or SIGBUS + atf_check -s exit:0 -o not-empty \ + env MALLOC_CONF="redzone:true" grep --mmap -e " " test2 +} # End FreeBSD atf_init_test_cases() @@ -665,5 +705,7 @@ atf_init_test_cases() atf_add_test_case grep_nomatch_flags atf_add_test_case binary_flags atf_add_test_case badcontext + atf_add_test_case mmap + atf_add_test_case mmap_eof_not_eol # End FreeBSD }