Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/usr.bin/grep Import of some regression tests for gre...



details:   https://anonhg.NetBSD.org/src/rev/2f311aa58420
branches:  trunk
changeset: 551955:2f311aa58420
user:      cjep <cjep%NetBSD.org@localhost>
date:      Sun Sep 14 13:47:47 2003 +0000

description:
Import of some regression tests for grep. Some of them based on tests
seen in OpenBSD src/regress/usr.bin/grep.

diffstat:

 regress/usr.bin/grep/Makefile        |    8 +
 regress/usr.bin/grep/contextinput    |   10 ++
 regress/usr.bin/grep/contextinput1   |    3 +
 regress/usr.bin/grep/greptests.sh    |  145 +++++++++++++++++++++++++++++++++++
 regress/usr.bin/grep/input           |   12 ++
 regress/usr.bin/grep/negativeinput   |   10 ++
 regress/usr.bin/grep/test1.gnu.out   |  119 ++++++++++++++++++++++++++++
 regress/usr.bin/grep/test11a.gnu.out |    5 +
 regress/usr.bin/grep/test11b.gnu.out |    4 +
 regress/usr.bin/grep/test11c.gnu.out |    5 +
 regress/usr.bin/grep/test11d.gnu.out |   13 +++
 regress/usr.bin/grep/test13.gnu.out  |    1 +
 regress/usr.bin/grep/test14.gnu.out  |    2 +
 regress/usr.bin/grep/test2.gnu.out   |    1 +
 regress/usr.bin/grep/test3.gnu.out   |    2 +
 regress/usr.bin/grep/test4.gnu.out   |    3 +
 regress/usr.bin/grep/test5.gnu.out   |    1 +
 regress/usr.bin/grep/test6a.gnu.out  |    1 +
 regress/usr.bin/grep/test6b.gnu.out  |    1 +
 regress/usr.bin/grep/test7.gnu.out   |    2 +
 regress/usr.bin/grep/test8.gnu.out   |    5 +
 regress/usr.bin/grep/test9.gnu.out   |    1 +
 22 files changed, 354 insertions(+), 0 deletions(-)

diffs (truncated from 442 to 300 lines):

diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/Makefile     Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,8 @@
+#      $NetBSD: Makefile,v 1.1.1.1 2003/09/14 13:47:47 cjep Exp $
+
+NOMAN= # defined
+
+regress:
+       @/bin/sh ${.CURDIR}/greptests.sh ${.CURDIR}
+
+.include <bsd.prog.mk>
diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/contextinput
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/contextinput Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,10 @@
+A pig is a jolly companion,
+Boar, sow, barrow, or gilt --
+A pig is a pal, who'll boost your morale, 
+Though mountains may topple and tilt.
+When they've blackballed, bamboozled, and burned you,
+When they've turned on you, Tory and Whig,
+Though you may be thrown over by Tabby and Rover,
+You'll never go wrong with a pig, a pig,
+You'll never go wrong with a pig!
+                -- Thomas Pynchon, "Gravity's Rainbow"
diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/contextinput1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/contextinput1        Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,3 @@
+This is to test output of context from multiple files.
+Dave was a happy pig who wandered around the orchard eating
+apples all day long.
diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/greptests.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/greptests.sh Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,145 @@
+#!/bin/sh
+#
+# $NetBSD: greptests.sh,v 1.1.1.1 2003/09/14 13:47:48 cjep Exp $
+#
+#
+# Regression tests for grep. Some of these tests are based on those
+# from OpenBSD src/regress/usr.bin/grep/Makefile
+#
+# OpenBSD: Makefile,v 1.4 2003/07/17 19:14:43 pvalchev Exp 
+
+p="$1";
+[ -z "$1" ] && p=".";
+
+# Temporary measure so that multiple greps can be tested
+#
+grep=grep
+egrep=egrep
+fgrep=fgrep
+zgrep=zgrep
+
+# Path to words directory
+#
+words=/usr/share/dict/words;
+
+
+# Test 1: Simple grep from words.
+#
+echo "1. Simple grep"
+${grep} aa ${words} | diff $p/test1.gnu.out -
+echo ""
+
+# Test 2: Binary files.
+#
+echo "2. Binary files"
+${grep} NetBSD /bin/sh | diff $p/test2.gnu.out -
+echo ""
+
+# Test 3: Simple recursive grep
+#
+echo "3. Recursive grep"
+tmpdir=`mktemp -d /tmp/greptest.XXXXXX` || exit 1;
+mkdir -p ${tmpdir}/recurse/a/f ${tmpdir}/recurse/d
+cat <<EOF > ${tmpdir}/recurse/a/f/favourite-fish
+cod
+haddock
+plaice
+EOF
+
+cat <<EOF > ${tmpdir}/recurse/d/fish
+cod
+dover sole
+haddock
+halibut
+pilchard
+EOF
+
+(cd ${tmpdir} && ${grep} -r haddock recurse) | diff $p/test3.gnu.out -
+rm -rf ${tmpdir}
+echo ""
+
+# Test 4: Symbolic link recursion
+#
+echo "4. Symbolic link recursion"
+tmpdir=`mktemp -d /tmp/greptest.XXXXXX` || exit 1;
+mkdir -p ${tmpdir}/test/c/d
+(cd ${tmpdir}/test/c/d && ln -s ../d .)
+echo "Test string" > ${tmpdir}/test/c/match
+(cd ${tmpdir} && ${grep} -r string test) 2>&1 | diff $p/test4.gnu.out -
+rm -rf ${tmpdir}
+echo ""
+
+# Test 5: Test word-regexps
+#
+echo "5. Test word-regexps"
+${grep} -w separated $p/input | diff $p/test5.gnu.out -
+echo ""
+
+# Test 6: Beginning and ends
+#
+echo "6. Beginnings and ends"
+${grep} ^Front $p/input | diff $p/test6a.gnu.out -
+${grep} ending$ $p/input | diff $p/test6b.gnu.out -
+echo ""
+
+# Test 7: Match on any case
+#
+echo "7. Ignore case"
+${grep} -i Upper $p/input | diff $p/test7.gnu.out -
+echo ""
+
+# Test 8: Test -v
+#
+echo "8. -v"
+${grep} -v fish $p/negativeinput | diff $p/test8.gnu.out -
+echo ""
+
+# Test 9: Test whole-line matching with -x
+#
+echo "9. Whole-line matching"
+${grep} -x matchme $p/input | diff $p/test9.gnu.out -
+echo ""
+
+# Test 10: Check for negative matches
+#
+echo "10. Test for non-matches"
+${grep} "not a hope in hell" $p/input | diff /dev/null -
+echo ""
+
+# Test 11: Context
+#
+echo "11. Context tests"
+${grep} -C2 bamboo $p/contextinput | diff $p/test11a.gnu.out -
+${grep} -A3 tilt $p/contextinput | diff $p/test11b.gnu.out -
+${grep} -B4 Whig $p/contextinput | diff $p/test11c.gnu.out -
+(cd $p && ${grep} -C1 pig contextinput contextinput1) \
+       | diff $p/test11d.gnu.out -
+echo ""
+
+# Test 12: Test reading expressions from a file
+#
+echo "12. Test reading expressions from a file"
+${grep} -f $p/test1.gnu.out ${words} | diff $p/test1.gnu.out -
+echo ""
+
+# Test 13: Extended grep
+#
+echo "13. Extended grep of special characters"
+${egrep} '\?|\*$$' $p/input | diff $p/test13.gnu.out -
+echo ""
+
+# Test 14: zgrep
+#
+echo "14. zgrep"
+tmpdir=`mktemp -d /tmp/greptest.XXXXXX` || exit 1;
+cp $p/input ${tmpdir}/input
+gzip ${tmpdir}/input
+${zgrep} line ${tmpdir}/input.gz | diff $p/test14.gnu.out -
+rm -rf ${tmpdir}
+echo ""
+
+# Test 15: Don't print out infomation about non-existent files
+#
+echo "15. Ignore non-existent files (-s)"
+${grep} -s foobar $p/notexistent | diff /dev/null -
+echo ""
diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/input
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/input        Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,12 @@
+dot.separated@words
+kkseparatedkk
+Front of the line
+This is a another line with a Front and an ending
+Special characters [, $, ^, *
+Here is another ending.
+
+Mostly I prefer lower case to upper case,
+but UpPeR cAsE has its merits too.
+
+matchme
+
diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/negativeinput
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/negativeinput        Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,10 @@
+
+fish
+fish
+dog
+cat
+fish
+fish
+
+poodle
+fish
diff -r 5d65727a85de -r 2f311aa58420 regress/usr.bin/grep/test1.gnu.out
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/usr.bin/grep/test1.gnu.out        Sun Sep 14 13:47:47 2003 +0000
@@ -0,0 +1,119 @@
+aa
+aal
+aalii
+aam
+aardvark
+aardwolf
+Afrikaans
+ahaaina
+Alcaaba
+amaas
+assbaa
+baa
+baahling
+Baal
+baal
+Baalath
+Baalish
+Baalism
+Baalist
+Baalite
+Baalitical
+Baalize
+Baalshem
+baar
+Balaam
+Balaamite
+Balaamitical
+balmacaan
+Bastaard
+bataan
+baviaantje
+bazaar
+berghaan
+Bilaan
+caam
+caama
+caaming
+caapeba
+caatinga
+cabaan
+Canaan
+Canaanite
+Canaanitess
+Canaanitic
+Canaanitish
+chaa
+daalder
+Danaan
+encraal
+enkraal
+golandaas
+Graafian
+haab
+haaf
+heemraad
+Isaac
+Jaalin
+knorhaan
+kraal
+laager
+laang
+Landsmaal
+maam
+maamselle
+macaasim
+malaanonang
+molengraaffite
+mushaa
+naa
+naam
+Naaman
+Naassenes
+nagmaal
+paal
+paar
+paauw
+paraaminobenzoic
+praam
+raad
+raash
+reaal
+Rigsmaal
+Riksmaal
+saa



Home | Main Index | Thread Index | Old Index