From owner-svn-src-head@freebsd.org Mon May 15 20:41:30 2017 Return-Path: Delivered-To: svn-src-head@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 89C00D6E562; Mon, 15 May 2017 20:41:30 +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 429381624; Mon, 15 May 2017 20:41:30 +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 v4FKfTRm019133; Mon, 15 May 2017 20:41:29 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4FKfTd8019132; Mon, 15 May 2017 20:41:29 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201705152041.v4FKfTd8019132@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 15 May 2017 20:41:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318317 - 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-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 May 2017 20:41:30 -0000 Author: emaste Date: Mon May 15 20:41:29 2017 New Revision: 318317 URL: https://svnweb.freebsd.org/changeset/base/318317 Log: bsdgrep: add more tests for different binary flags The existing 'binary' test in netbsd-tests/ does a basic check of the default treatment for binary behavior, but not much more than that. Given some opportunity for breakage recently that did not trigger any failures, add some tests to cover the three different binary file behaviors (a, -I, -U) and their --binary-files= equivalent values. Submitted by: Kyle Evans Reviewed by: cem, ngie Differential Revision: https://reviews.freebsd.org/D10620 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 Mon May 15 20:18:14 2017 (r318316) +++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Mon May 15 20:41:29 2017 (r318317) @@ -539,6 +539,41 @@ badcontext_body() atf_check -s not-exit:0 -e ignore grep -C "B" "B" test1 } + +atf_test_case binary_flags +binary_flags_head() +{ + atf_set "descr" "Check output for binary flags (-a, -I, -U, --binary-files)" +} +binary_flags_body() +{ + printf "A\000B\000C" > test1 + printf "A\n\000B\n\000C" > test2 + binmatchtext="Binary file test1 matches\n" + + # Binaries not treated as text (default, -U) + atf_check -o inline:"${binmatchtext}" grep 'B' test1 + atf_check -o inline:"${binmatchtext}" grep 'B' -C 1 test1 + + atf_check -o inline:"${binmatchtext}" grep -U 'B' test1 + atf_check -o inline:"${binmatchtext}" grep -U 'B' -C 1 test1 + + # Binary, -a, no newlines + atf_check -o inline:"A\000B\000C\n" grep -a 'B' test1 + atf_check -o inline:"A\000B\000C\n" grep -a 'B' -C 1 test1 + + # Binary, -a, newlines + atf_check -o inline:"\000B\n" grep -a 'B' test2 + atf_check -o inline:"A\n\000B\n\000C\n" grep -a 'B' -C 1 test2 + + # Binary files ignored + atf_check -s exit:1 grep -I 'B' test2 + + # --binary-files equivalence + atf_check -o inline:"${binmatchtext}" grep --binary-files=binary 'B' test1 + 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 +} # End FreeBSD atf_init_test_cases() @@ -573,6 +608,7 @@ atf_init_test_cases() atf_add_test_case egrep_sanity atf_add_test_case grep_sanity atf_add_test_case grep_nomatch_flags + atf_add_test_case binary_flags atf_add_test_case badcontext # End FreeBSD }