bsdgrep: add some additional tests for fgrep
Previously added tests only check that fgrep is somewhat sane and works. Add some more tests that check that the implementation is basically functional and not producing incorrect results with various flags. Reviewed by: cem, emaste, ngie Approved by: emaste (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12056
This commit is contained in:
parent
de6feefdb7
commit
c552f48b6f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322825
@ -687,6 +687,59 @@ matchall_body()
|
|||||||
|
|
||||||
atf_check -s exit:1 grep "" test1
|
atf_check -s exit:1 grep "" test1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atf_test_case fgrep_multipattern
|
||||||
|
fgrep_multipattern_head()
|
||||||
|
{
|
||||||
|
atf_set "descr" "Check proper behavior with multiple patterns supplied to fgrep"
|
||||||
|
}
|
||||||
|
fgrep_multipattern_body()
|
||||||
|
{
|
||||||
|
printf "Foo\nBar\nBaz" > test1
|
||||||
|
|
||||||
|
atf_check -o inline:"Foo\nBaz\n" grep -F -e "Foo" -e "Baz" test1
|
||||||
|
atf_check -o inline:"Foo\nBaz\n" grep -F -e "Baz" -e "Foo" test1
|
||||||
|
atf_check -o inline:"Bar\nBaz\n" grep -F -e "Bar" -e "Baz" test1
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_test_case fgrep_icase
|
||||||
|
fgrep_icase_head()
|
||||||
|
{
|
||||||
|
atf_set "descr" "Check proper handling of -i supplied to fgrep"
|
||||||
|
}
|
||||||
|
fgrep_icase_body()
|
||||||
|
{
|
||||||
|
printf "Foo\nBar\nBaz" > test1
|
||||||
|
|
||||||
|
atf_check -o inline:"Foo\nBaz\n" grep -Fi -e "foo" -e "baz" test1
|
||||||
|
atf_check -o inline:"Foo\nBaz\n" grep -Fi -e "baz" -e "foo" test1
|
||||||
|
atf_check -o inline:"Bar\nBaz\n" grep -Fi -e "bar" -e "baz" test1
|
||||||
|
atf_check -o inline:"Bar\nBaz\n" grep -Fi -e "BAR" -e "bAz" test1
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_test_case fgrep_oflag
|
||||||
|
fgrep_oflag_head()
|
||||||
|
{
|
||||||
|
atf_set "descr" "Check proper handling of -o supplied to fgrep"
|
||||||
|
}
|
||||||
|
fgrep_oflag_body()
|
||||||
|
{
|
||||||
|
printf "abcdefghi\n" > test1
|
||||||
|
|
||||||
|
atf_check -o inline:"a\n" grep -Fo "a" test1
|
||||||
|
atf_check -o inline:"i\n" grep -Fo "i" test1
|
||||||
|
atf_check -o inline:"abc\n" grep -Fo "abc" test1
|
||||||
|
atf_check -o inline:"fgh\n" grep -Fo "fgh" test1
|
||||||
|
atf_check -o inline:"cde\n" grep -Fo "cde" test1
|
||||||
|
atf_check -o inline:"bcd\n" grep -Fo -e "bcd" -e "cde" test1
|
||||||
|
atf_check -o inline:"bcd\nefg\n" grep -Fo -e "bcd" -e "efg" test1
|
||||||
|
|
||||||
|
atf_check -s exit:1 grep -Fo "xabc" test1
|
||||||
|
atf_check -s exit:1 grep -Fo "abcx" test1
|
||||||
|
atf_check -s exit:1 grep -Fo "xghi" test1
|
||||||
|
atf_check -s exit:1 grep -Fo "ghix" test1
|
||||||
|
atf_check -s exit:1 grep -Fo "abcdefghiklmnopqrstuvwxyz" test1
|
||||||
|
}
|
||||||
# End FreeBSD
|
# End FreeBSD
|
||||||
|
|
||||||
atf_init_test_cases()
|
atf_init_test_cases()
|
||||||
@ -728,5 +781,8 @@ atf_init_test_cases()
|
|||||||
atf_add_test_case mmap
|
atf_add_test_case mmap
|
||||||
atf_add_test_case mmap_eof_not_eol
|
atf_add_test_case mmap_eof_not_eol
|
||||||
atf_add_test_case matchall
|
atf_add_test_case matchall
|
||||||
|
atf_add_test_case fgrep_multipattern
|
||||||
|
atf_add_test_case fgrep_icase
|
||||||
|
atf_add_test_case fgrep_oflag
|
||||||
# End FreeBSD
|
# End FreeBSD
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user