From keramida@ceid.upatras.gr  Sun Jan 13 02:29:42 2008
Return-Path: <keramida@ceid.upatras.gr>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7FF4A16A41A
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Jan 2008 02:29:42 +0000 (UTC)
	(envelope-from keramida@ceid.upatras.gr)
Received: from mx-out-01.forthnet.gr (mx-out.forthnet.gr [193.92.150.104])
	by mx1.freebsd.org (Postfix) with ESMTP id D6BBF13C447
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 13 Jan 2008 02:29:41 +0000 (UTC)
	(envelope-from keramida@ceid.upatras.gr)
Received: from mx-av-04.forthnet.gr (mx-av.forthnet.gr [193.92.150.27])
	by mx-out-01.forthnet.gr (8.13.8/8.13.8) with ESMTP id m0D2TeZf011307;
	Sun, 13 Jan 2008 04:29:40 +0200
Received: from MX-IN-05.forthnet.gr (mx-in-05.forthnet.gr [193.92.150.32])
	by mx-av-04.forthnet.gr (8.14.1/8.14.1) with ESMTP id m0D2Tef6027720;
	Sun, 13 Jan 2008 04:29:40 +0200
Received: from kobe.laptop (ppp43-253.adsl.forthnet.gr [62.1.60.253])
	by MX-IN-05.forthnet.gr (8.14.2/8.14.2) with ESMTP id m0D2TYtU007813;
	Sun, 13 Jan 2008 04:29:35 +0200
Received: from kobe.laptop (kobe.laptop [127.0.0.1])
	by kobe.laptop (8.14.2/8.14.2) with ESMTP id m0D2TYVR002258;
	Sun, 13 Jan 2008 04:29:34 +0200 (EET)
	(envelope-from keramida@kobe.laptop)
Received: (from keramida@localhost)
	by kobe.laptop (8.14.2/8.14.2/Submit) id m0D2TYpV002257;
	Sun, 13 Jan 2008 04:29:34 +0200 (EET)
	(envelope-from keramida)
Message-Id: <200801130229.m0D2TYpV002257@kobe.laptop>
Date: Sun, 13 Jan 2008 04:29:34 +0200 (EET)
From: Giorgos Keramidas <keramida@freebsd.org>
Reply-To: Giorgos Keramidas <keramida@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: dds@freebsd.org (Diomidis Spinellis)
Subject: regression tests for tr(1)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         119614
>Category:       bin
>Synopsis:       [feature request] [patch] add regression tests for tr(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    keramida
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 13 02:30:00 UTC 2008
>Closed-Date:    Fri Jan 30 17:30:27 UTC 2009
>Last-Modified:  Fri Jan 30 17:30:27 UTC 2009
>Originator:     Giorgos Keramidas
>Release:        FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD kobe 8.0-CURRENT FreeBSD 8.0-CURRENT #0: \
Tue Jan 8 23:38:14 EET 2008 \
build@kobe:/home/build/obj/home/build/src/sys/KOBE i386

>Description:

The attached patch adds a small set of regression tests for tr(1).
It is far from a complete set of tests, but we can always expand
it (I'm hoping for the help of Diomidis for directions about the
best way to do that).

>How-To-Repeat:

After applying the patch, it should be possible to run:

	cd /usr/src/tools/regression/usr.bin/tr
	make

>Fix:

--- regression-tr.patch begins here ---
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/Makefile
--- a/tools/regression/usr.bin/Makefile	Sun Jan 13 04:24:27 2008 +0200
+++ b/tools/regression/usr.bin/Makefile	Sun Jan 13 04:24:28 2008 +0200
@@ -1,5 +1,16 @@
 # $FreeBSD: src/tools/regression/usr.bin/Makefile,v 1.12 2007/06/03 03:29:31 grog Exp $
 
-SUBDIR=	calendar file2c join jot m4 printf sed uudecode uuencode xargs lastcomm
+SUBDIR = calendar
+SUBDIR+= file2c
+SUBDIR+= join
+SUBDIR+= jot
+SUBDIR+= lastcomm
+SUBDIR+= m4
+SUBDIR+= printf
+SUBDIR+= sed
+SUBDIR+= tr
+SUBDIR+= uudecode
+SUBDIR+= uuencode
+SUBDIR+= xargs
 
 .include <bsd.subdir.mk>
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/Makefile	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+all:
+	@m4 ${.CURDIR}/../regress.m4 ${.CURDIR}/regress.sh | sh /dev/stdin ${.CURDIR}
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.00.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.00.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+qui3k 2rown
+fox jump54
+ov5r th5 l1zy
+4og
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.01.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.01.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+quick brown
+fox jumped
+over the lazy
+dog
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.02.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.02.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+quik brown
+fox jumpd
+ovr th lzy
+do
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.03.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.03.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+QUICK BROWN
+FOX JUMPED
+OVER THE LAZY
+DOG
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.04.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.04.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+..... .....
+... ......
+.... ... ....
+...
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.05.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.05.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+quick brown
+fox jumped
+over the lazy
+dog
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.06.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.06.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,9 @@
+??? bottles of beer on the wall, ??? bottles of beer.
+Take one down and pass it around - ?? bottles of beer on the wall.
+?? bottles of beer on the wall, ?? bottles of beer.
+Take one down and pass it around - ?? bottles of beer on the wall.
+...
+? bottles of beer on the wall, ? bottles of beer!!!
+Take one down and pass it around - ? bottle of beer on the wall.
+? bottle of beer on the wall, ? bottle of beer!!!
+Take it down and pass it around - NO MORE bottles of beer on the wall!!!
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.07.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.07.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,9 @@
+### ####### ## #### ## ### ####, ### ####### ## ####.
+#### ### #### ### #### ## ###### - ## ####### ## #### ## ### ####.
+## ####### ## #### ## ### ####, ## ####### ## ####.
+#### ### #### ### #### ## ###### - ## ####### ## #### ## ### ####.
+...
+# ####### ## #### ## ### ####, # ####### ## ####!!!
+#### ### #### ### #### ## ###### - # ###### ## #### ## ### ####.
+# ###### ## #### ## ### ####, # ###### ## ####!!!
+#### ## #### ### #### ## ###### - ## #### ####### ## #### ## ### ####!!!
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.08.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.08.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,9 @@
+100,100.
+-99.
+99,99.
+-98.
+...
+2,2!!!
+-1.
+1,1!!!
+-!!!
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.09.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.09.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,1 @@
+?#
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.0a.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.0a.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,1 @@
+$?$$$$$$$$
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.0b.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.0b.out	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,1 @@
+100befbeeea100befbeeaeedadaad99befbeeea99befbeeea99befbeeaeedadaad98befbeeea2befbeeea2befbeeaeedadaad1befbeeea1befbeeea1befbeeaedadaadEbefbeeea
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.in	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,4 @@
+quick brown
+fox jumped
+over the lazy
+dog
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.sh	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,20 @@
+# $FreeBSD$
+
+echo 1..12
+
+REGRESSION_START($1)
+
+REGRESSION_TEST(`00', `tr abcde 12345 < regress.in')
+REGRESSION_TEST(`01', `tr 12345 abcde < regress.in')
+REGRESSION_TEST(`02', `tr -d aceg < regress.in')
+REGRESSION_TEST(`03', `tr "[[:lower:]]" "[[:upper:]]" < regress.in')
+REGRESSION_TEST(`04', `tr "[[:alpha:]]" . < regress.in')
+REGRESSION_TEST(`05', `tr "[[:lower:]]" "[[:upper:]]" < regress.in | tr "[[:upper:]]" "[[:lower:]]"')
+REGRESSION_TEST(`06', `tr "[[:digit:]]" "?" < regress2.in')
+REGRESSION_TEST(`07', `tr "[[:alnum:]]" "#" < regress2.in')
+REGRESSION_TEST(`08', `tr "[[:upper:]]" "[[:lower:]]" < regress2.in | tr -d "[^[:alpha:]] "')
+REGRESSION_TEST(`09', `printf "\\f\\r\\n" | tr "\\014\\r" "?#"')
+REGRESSION_TEST(`0a', `printf "0xdeadbeef\\n" | tr "x[[:xdigit:]]" "?\$"')
+REGRESSION_TEST(`0b', `(tr -cd "[[:xdigit:]]" < regress2.in ; echo)')
+
+REGRESSION_END()
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress.t	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,6 @@
+#!/bin/sh
+# $FreeBSD$
+
+cd `dirname $0`
+
+m4 ../regress.m4 regress.sh | sh
diff -r cdc776357ea9 -r 5f6d24ce0a4d tools/regression/usr.bin/tr/regress2.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/regression/usr.bin/tr/regress2.in	Sun Jan 13 04:24:28 2008 +0200
@@ -0,0 +1,9 @@
+100 bottles of beer on the wall, 100 bottles of beer.
+Take one down and pass it around - 99 bottles of beer on the wall.
+99 bottles of beer on the wall, 99 bottles of beer.
+Take one down and pass it around - 98 bottles of beer on the wall.
+...
+2 bottles of beer on the wall, 2 bottles of beer!!!
+Take one down and pass it around - 1 bottle of beer on the wall.
+1 bottle of beer on the wall, 1 bottle of beer!!!
+Take it down and pass it around - NO MORE bottles of beer on the wall!!!
--- regression-tr.patch ends here ---
>Release-Note:
>Audit-Trail:

From: David Schultz <das@FreeBSD.ORG>
To: Giorgos Keramidas <keramida@FreeBSD.ORG>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG, Diomidis Spinellis <dds@FreeBSD.ORG>
Subject: Re: bin/119614: regression tests for tr(1)
Date: Sat, 12 Jan 2008 22:28:23 -0500

 Cool, looks useful to me. Tests for various other command-line
 options, especially -d and -s, and checking that it does the right
 thing with NULs. There's also the issue of making sure it does the
 right thing with locales and multi-byte characters (if we even
 support that), but I don't have much expertise in that area.
 But I'd say commit whatever tests you have, so the next time
 we find a bug, it will be a one-line change for someone to add a
 regression test for it.

From: Giorgos Keramidas <keramida@freebsd.org>
To: David Schultz <das@freebsd.org>
Cc: FreeBSD-gnats-submit@freebsd.org, Diomidis Spinellis <dds@freebsd.org>
Subject: Re: bin/119614: regression tests for tr(1)
Date: Sun, 13 Jan 2008 06:32:55 +0200

 On 2008-01-12 22:28, David Schultz <das@FreeBSD.ORG> wrote:
 > But I'd say commit whatever tests you have, so the next time we find a
 > bug, it will be a one-line change for someone to add a regression test
 > for it.
 
 Thanks.  I'll wait a bit for Diomidis to see the PR too, in case he
 wants to add/change something.  Then in 1-2 days I'll commit the current
 patch.
 
 In the meantime, I'll try adding more tests for the -d / -s options.
 
 The current patch already includes a pair of tests for -d and -cd:
 
 REGRESSION_TEST(`02', `tr -d aceg < regress.in')
 REGRESSION_TEST(`0b', `(tr -cd "[[:xdigit:]]" < regress2.in ; echo)')
 
 I'm sure we can come up with more :)
 
 Locales shouldn't be too hard to do too, but I only have experience with
 the en_US.* and el_GR.* locales, so I may need a bit of help with the
 rest of them.

From: Diomidis Spinellis <dds@aueb.gr>
To: Giorgos Keramidas <keramida@FreeBSD.ORG>
Cc: David Schultz <das@FreeBSD.ORG>, FreeBSD-gnats-submit@FreeBSD.ORG,
        Diomidis Spinellis <dds@FreeBSD.ORG>
Subject: Re: bin/119614: regression tests for tr(1)
Date: Sun, 13 Jan 2008 09:36:41 +0200

 Giorgos Keramidas wrote:
 > On 2008-01-12 22:28, David Schultz <das@FreeBSD.ORG> wrote:
 >> But I'd say commit whatever tests you have, so the next time we find a
 >> bug, it will be a one-line change for someone to add a regression test
 >> for it.
 > 
 > Thanks.  I'll wait a bit for Diomidis to see the PR too, in case he
 > wants to add/change something.  Then in 1-2 days I'll commit the current
 > patch.
 
 Great!  As David commented the most important thing is to have a 
 regression test and a place where more tests can be added in the future. 
   So go ahead and commit it.
 
 You might want to add tests for the [#*n] and the [=char=] notations.
 
 Also, verify that your tests interact gracefully with Perl's 
 Test::Harness prove(1) command.
 
 Diomidis Spinellis - http://www.spinellis.gr
State-Changed-From-To: open->patched 
State-Changed-By: keramida 
State-Changed-When: Sun Jan 13 08:34:43 UTC 2008 
State-Changed-Why:  
Committed to HEAD.  I'll MFC these after I verify that 
they also pass on RELENG_X branches. 


Responsible-Changed-From-To: freebsd-bugs->keramida 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Sun Jan 13 08:34:43 UTC 2008 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=119614 

From: Giorgos Keramidas <keramida@ceid.upatras.gr>
To: Diomidis Spinellis <dds@aueb.gr>
Cc: David Schultz <das@FreeBSD.ORG>, FreeBSD-gnats-submit@FreeBSD.ORG,
        Diomidis Spinellis <dds@FreeBSD.ORG>
Subject: Re: bin/119614: regression tests for tr(1)
Date: Sun, 13 Jan 2008 10:34:24 +0200

 On 2008-01-13 09:36, Diomidis Spinellis <dds@aueb.gr> wrote:
 > Giorgos Keramidas wrote:
 >> On 2008-01-12 22:28, David Schultz <das@FreeBSD.ORG> wrote:
 >>> But I'd say commit whatever tests you have, so the next time we find a
 >>> bug, it will be a one-line change for someone to add a regression test
 >>> for it.
 >> Thanks.  I'll wait a bit for Diomidis to see the PR too, in case he
 >> wants to add/change something.  Then in 1-2 days I'll commit the current
 >> patch.
 >
 > Great!  As David commented the most important thing is to have a regression
 > test and a place where more tests can be added in the future.  So go ahead
 > and commit it.
 
 Committed, thanks to both :)
 
 > You might want to add tests for the [#*n] and the [=char=] notations.
 >
 > Also, verify that your tests interact gracefully with Perl's Test::Harness
 > prove(1) command.
 
 Good point.  They do:
 
 % build@kobe:/home/build/src/tools/regression/usr.bin/tr$ prove .
 % ./regress....ok
 % All tests successful.
 % Files=1, Tests=12,  0 wallclock secs ( 0.02 cusr +  0.12 csys =  0.14 CPU)
 % build@kobe:/home/build/src/tools/regression/usr.bin/tr$
 
 > Diomidis Spinellis - http://www.spinellis.gr
State-Changed-From-To: patched->closed 
State-Changed-By: keramida 
State-Changed-When: Fri Jan 30 17:30:01 UTC 2009 
State-Changed-Why:  
Merged to stable/6 and stable/7 

http://www.freebsd.org/cgi/query-pr.cgi?pr=119614 
>Unformatted:
