1# 2# Copyright (c) 2017 Kyle Evans <kevans@FreeBSD.org> 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# $FreeBSD$ 27 28# What grep(1) are we working with? 29# - 0 : bsdgrep 30# - 1 : gnu grep 2.51 (base) 31# - 2 : gnu grep (ports) 32GREP_TYPE_BSD=0 33GREP_TYPE_GNU_FREEBSD=1 34GREP_TYPE_GNU=2 35GREP_TYPE_UNKNOWN=3 36 37grep_type() 38{ 39 local grep_version=$(grep --version) 40 41 case "$grep_version" in 42 *"BSD grep"*) 43 return $GREP_TYPE_BSD 44 ;; 45 *"GNU grep"*) 46 case "$grep_version" in 47 *2.5.1-FreeBSD*) 48 return $GREP_TYPE_GNU_FREEBSD 49 ;; 50 *) 51 return $GREP_TYPE_GNU 52 ;; 53 esac 54 ;; 55 esac 56 atf_fail "unknown grep type: $grep_version" 57} 58 59atf_test_case grep_r_implied 60grep_r_implied_body() 61{ 62 grep_type 63 if [ $? -ne $GREP_TYPE_BSD ]; then 64 atf_skip "this test only works with bsdgrep(1)" 65 fi 66 67 (cd "$(atf_get_srcdir)" && grep -r --exclude="*.out" -e "test" .) > d_grep_r_implied.out 68 69 atf_check -s exit:0 -x \ 70 "(cd $(atf_get_srcdir) && grep -r --exclude=\"*.out\" -e \"test\") | diff d_grep_r_implied.out -" 71} 72 73atf_test_case rgrep 74rgrep_head() 75{ 76 atf_set "require.progs" "rgrep" 77} 78rgrep_body() 79{ 80 atf_check -o save:d_grep_r_implied.out grep -r --exclude="*.out" -e "test" "$(atf_get_srcdir)" 81 atf_check -o file:d_grep_r_implied.out rgrep --exclude="*.out" -e "test" "$(atf_get_srcdir)" 82} 83 84atf_init_test_cases() 85{ 86 atf_add_test_case grep_r_implied 87 atf_add_test_case rgrep 88} 89