#!/bin/sh

# Regression tests for BitSCCS
# @(#)regression 1.37 07/17/98 lm@work

if [ X$1 = X-v ]
then	Q=
	S=
else	Q=-q
	S=-s
fi
if [ '-n foo' = "`echo -n foo`" ] 
then	NL='\c'
	N=
else	NL=
	N=-n
fi
if [ -d /usr/xpg4/bin ]
then  PATH=/usr/xpg4/bin:$PATH
fi
PATH=$PWD:$PATH
export PATH
/bin/rm -rf .regression
mkdir .regression || exit 1
cd .regression || exit 1
if [ -d SCCS ]; then echo "There should be no SCCS directory here."; exit 1; fi
if [ X$USER = X ]; then
	whoami > USER 2>/dev/null
	USER=`cat USER`
fi
if [ X$USER = X ]; then
	echo Can not figure out user name.
	exit 1
fi

cat > foo <<EOF
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
Hi there, this is file foo.
EOF
mv foo SAVE
echo ---------- Basic tests ------------
for D in "" A/ A/A/A/A/
do
	if [ X$D != X ]; then mkdir -p $D; fi
	/bin/rm -rf ${D}foo ${D}SCCS ${D}s.foo
	cp SAVE ${D}foo
	echo $N checkin with ${D}SCCS/s.foo .................$NL
	ci $Q -i ${D}foo
	if [ ! -f ${D}SCCS/s.foo ]; then echo Failed to create s.foo.; exit 1; fi
	if [ -f ${D}foo ]; then echo Failed to get foo.; exit 1; fi
	echo OK
	echo $N checkout with ${D}SCCS/s.foo ................$NL
	co $Q ${D}foo
	if [ ! -f ${D}foo ]; then echo Failed to get foo.; exit 1; fi
	echo OK
	echo $N cleaning ${D} ................................$NL
	clean ${D}
	if [ -f ${D}foo ]; then echo Failed to clean foo.; exit 1; fi
	echo OK
	echo $N checkout of the directory ${D} ...............$NL
	co $Q ${D}
	if [ ! -f ${D}foo ]; then echo Failed to get foo.; exit 1; fi
	echo OK
	# OK, now try it with s.names, no SCCS/
	echo $N checkin with ${D}s.foo ......................$NL
	/bin/rm -rf ${D}foo ${D}SCCS
	cp SAVE ${D}foo
	ci $Q -i ${D}s.foo
	if [ ! -f ${D}s.foo ]; then echo Failed to create s.foo.; exit 1; fi
	if [ -f ${D}foo ]; then echo Failed to get foo.; exit 1; fi
	echo OK
	echo $N checkout with ${D}s.foo .....................$NL
	co $Q ${D}s.foo
	if [ ! -f ${D}foo ]; then echo Failed to get foo.; exit 1; fi
	echo OK
	echo $N cleaning ${D} ................................$NL
	clean ${D}
	if [ -f ${D}foo ]; then echo Failed to clean foo.; exit 1; fi
	echo OK
	echo $N checkout of the directory ${D} ...............$NL
	co $Q ${D}
	if [ ! -f ${D}foo ]; then echo Failed to get foo.; exit 1; fi
	echo OK
done

echo ---------- Get tests ------------
/bin/rm -rf foo SCCS A
echo Hallo > date
admin $Q -n -idate date; /bin/rm date
co $Q -l date
echo Hi >> date
ci $Q -y date
co $Q -l date
echo Hi >> date
ci $Q -y date
echo $N Make sure -Gname works ......................$NL
get $S -GA -r1.1 date
get $S -G B -r1.2 date
if [ ! -f A ]; then echo Failed to creat A.; exit 1; fi
if [ ! -f B ]; then echo Failed to creat A.; exit 1; fi
grep -q Hallo A
if [ $? -ne 0 ]; then echo Bad data in A.; exit 1; fi
grep -q HI A
if [ $? -ne 1 ]; then echo Bad data in A.; exit 1; fi
grep -q Hallo B
if [ $? -ne 0 ]; then echo Bad data in B.; exit 1; fi
grep -q Hi B
if [ $? -ne 0 ]; then echo Bad data in B.; exit 1; fi
echo OK
echo $N Check paths in file .........................$NL
grep -q 'f p 1.1 /' SCCS/s.date
if [ $? -ne 0 ]; then echo No path found.; exit 1; fi
grep -q 'f p 1.2 /' SCCS/s.date
if [ $? -ne 1 ]; then echo Duplicate path in rev 1.2.; exit 1; fi
grep -q 'f p 1.3 /' SCCS/s.date
if [ $? -ne 1 ]; then echo Duplicate path in rev 1.3.; exit 1; fi
echo OK
echo $N Check hosts in file .........................$NL
grep -q 'f h 1.1 ' SCCS/s.date
if [ $? -ne 0 ]; then echo No path found.; exit 1; fi
grep -q 'f h 1.2 ' SCCS/s.date
if [ $? -ne 1 ]; then echo Duplicate host in rev 1.2.; exit 1; fi
grep -q 'f h 1.3 ' SCCS/s.date
if [ $? -ne 1 ]; then echo Duplicate host in rev 1.3.; exit 1; fi
echo OK
echo $N Check zones in file .........................$NL
grep -q 'f w 1.1 ' SCCS/s.date
if [ $? -ne 0 ]; then echo No path found.; exit 1; fi
grep -q 'f w 1.2 ' SCCS/s.date
if [ $? -ne 1 ]; then echo Duplicate path in rev 1.2.; exit 1; fi
grep -q 'f w 1.3 ' SCCS/s.date
if [ $? -ne 1 ]; then echo Duplicate path in rev 1.3.; exit 1; fi
echo OK
echo $N Make sure get -b works w/ no -b flag ........$NL
get $S -eb date 
grep -q '1.3 1.4 ' SCCS/p.date
if [ $? -ne 0 ]; then echo Failed, bad rev.; exit 1; fi
clean date
echo OK
echo $N Make sure get -r1.1 works w/ no b flag ......$NL
get $S -er1.1 date 
if [ ! -f SCCS/p.date ]; then echo Failed, did not edit file.; exit 1; fi
grep -q '1.1 1.1.1.1 ' SCCS/p.date
if [ $? -ne 0 ]; then echo Failed, bad rev.; exit 1; fi
clean date
echo OK
echo $N Make sure get -b works with -b flag .........$NL
admin -qfb date
get $S -eb date 
grep -q '1.3 1.3.1.1 ' SCCS/p.date
if [ $? -ne 0 ]; then echo Failed, bad rev.; exit 1; fi
clean date
echo OK
echo $N Make sure get -g does not get file ..........$NL
get $S -g date 
if [ -f date ]; then echo Failed, got file.; exit 1; fi
echo OK
echo $N Make sure get -k does not expand keywords ...$NL
get $S -e date 
echo '@A@ @B@ @D@ @E@ @F@ @G@ @H@ @I@ @L@ @M@ @P@ @R@ @S@ @T@ @U@ @W@ @Y@ @Z@ @@@' | sed s/@/%/g > date
X=`wc date`
ci $Q -y date
get $S -k date
if [ "$X" != "`wc date`" ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N Make sure get does expand keywords ..........$NL
get $S date
if [ "$X" = "`wc date`" ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N RCS keywords should fail w/o -fR ............$NL
get $S -e date
echo '$Id$' > date
ci $S -y date
get $S date
if [ '$Id$' != "`cat date`" ]; then echo Failed.; exit 1; fi
echo OK
echo $N RCS keywords should work w/ -fR .............$NL
admin $Q -fR date
get $S date
if [ '$Id$' = "`cat date`" ]; then echo Failed.; exit 1; fi
echo OK
echo $N Make sure get -n works ......................$NL
echo HI > T
ci $Q -i T
if [ "`get $S -pn T`" != "T	HI" ]; then echo Failed.; exit 1; fi
echo OK
echo $N Make sure get -m works ......................$NL
if [ "`get $S -pm T`" != "1.1	HI" ]; then echo Failed.; exit 1; fi
echo OK
echo $N Make sure get -n works ......................$NL
if [ "`get $S -pn T`" != "T	HI" ]; then echo Failed.; exit 1; fi
echo OK
echo $N Make sure get -u works ......................$NL
if [ "`get $S -pu T`" != "$USER	HI" ]; then echo Failed.; exit 1; fi
echo OK

echo ---------- Delta tests ------------
echo $N Make sure delta -i works ....................$NL
echo hi there > init
delta $S -i init
if [ ! -f SCCS/s.init ]; then echo Failed to create s.file; exit 1; fi
echo OK
echo $N Make sure delta -l works ....................$NL
X=`wc SCCS/s.T`
get $S -e T
if [ ! -w T ]; then echo Get failed to get file writeable; exit 1; fi
delta $S -ly T
if [ "`wc SCCS/s.T`" = "$X" ]; then echo Failed to create delta; exit 1; fi
if [ ! -f SCCS/p.T ]; then echo Failed to leave file locked; exit 1; fi
if [ ! -f T ]; then echo Failed to get file; exit 1; fi
if [ ! -w T ]; then echo Failed to leave file writeable; exit 1; fi
echo OK
# I've removed this option, nobody uses it.
#echo $N Make sure delta -G works ....................$NL
#X=`wc SCCS/s.T`
#delta $S -Gy T
#if [ "`wc SCCS/s.T`" = "$X" ]; then echo Failed to create delta; exit 1; fi
#if [ ! -f SCCS/p.T ]; then echo Failed to leave file locked; exit 1; fi
#if [ -f T ]; then echo Failed to delete file or got it 2x; exit 1; fi
#echo OK
/bin/rm -f SCCS/p.T T
echo $N Make sure delta -n works ....................$NL
get $S -e T
delta $S -ny T
if [ ! -f T ]; then echo Failed to save file; exit 1; fi
if [ ! -w T ]; then echo Failed to save file writeable; exit 1; fi
echo OK

echo ---------- Fully specified date range tests ------------
echo $N Building up file with dates .................$NL
R=1
for D in '87/05/28 23:49:57' '97/05/28 23:49:57' '97/05/30 01:34:11' '97/06/23 01:33:45' '98/01/30 17:45:17' 
do	cat > INIT <<EOF
D 1.$R $D $USER 0 0 0/0/0
C This is revision 1.$R of $D
EOF
	echo 1.$R >> FILE
	if [ $R -eq 1 ] 
	then	delta $Q -i -IINIT FILE
	else	delta $Q -IINIT FILE
	fi
	R=`expr $R + 1`
	co $Q -l FILE
done
ci $Q FILE	# clean it
echo OK
DATE1=87/05/2823:49:57
DATE2=97/05/2823:49:57
DATE3=97/05/3001:34:11
DATE4=97/06/2301:33:45
DATE5=98/01/3017:45:17
REV=1.2
echo $N Range test '(D and D,' on 1.1 .................$NL
X=`prs -1c\(${DATE1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1c${DATE1}, FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test '[D and D. and D' on 1.1 ...........$NL
X=`prs -1c\[${DATE1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1c${DATE1}. FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
X=`prs -1c${DATE1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with nothing - got bad range $X; exit 1
fi
echo OK
REV=1.3
echo $N Range test '(D and D,' on 1.2 .................$NL
X=`prs -1c\(${DATE2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1c${DATE2}, FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.2
echo $N Range test '[D and D. and D' on 1.2 ...........$NL
X=`prs -1c\[${DATE2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1c${DATE2}. FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
X=`prs -1c${DATE2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with nothing - got bad range $X; exit 1
fi
echo OK
echo $N Range test '(D and D,' on 1.5 .................$NL
X=`prs -1c\(${DATE5} FILE | head -1`
if [ "$X" != "" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1c${DATE5}, FILE | head -1`
if [ "$X" != "" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.5
echo $N Range test '[D and D. and D' on 1.5 ...........$NL
X=`prs -1c\[${DATE5} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1c${DATE5}. FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
X=`prs -1c${DATE5} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with nothing - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test 'D) and ,D' on 1.2 .................$NL
X=`prs -1c${DATE2}\) FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1c,${DATE2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.2
echo $N Range test 'D] and .D' on 1.2 .................$NL
X=`prs -1c${DATE2}\] FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1c.${DATE2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test 'D) and ,D' on 1.1 .................$NL
X=`prs -1c${DATE1}\) FILE | head -1`
if [ "$X" != "" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1c,${DATE1} FILE | head -1`
if [ "$X" != "" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test 'D] and .D' on 1.1 .................$NL
X=`prs -1c${DATE1}\] FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1c.${DATE1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test '(D,D)' and D,,D on 1.1..1.3 .......$NL
X=`prs -c\(${DATE1},${DATE3}\) FILE | head -1`
REV=1.2
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE1},,${DATE3} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[D,D]' and D..D on 1.1..1.3 .......$NL
X=`prs -c\[${DATE1},${DATE3}\] FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.3 ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -c${DATE1}..${DATE3} FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.3 ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test '(D,D]' and D,.D on 1.2..1.3 .......$NL
X=`prs -c\(${DATE1},${DATE3}\] FILE | head -1`
if [ "$X" != "======== FILE 1.2..1.3 ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -c${DATE1},.${DATE3} FILE | head -1`
if [ "$X" != "======== FILE 1.2..1.3 ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[D,D)' and D.,D on 1.1..1.2 .......$NL
X=`prs -c\[${DATE1},${DATE3}\) FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.2 ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -c${DATE1}.,${DATE3} FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.2 ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
# end of fully specified date ranges (partially specifed below revisions)

echo ---------- Revision range tests ------------
REV1=1.1
REV2=1.2
REV3=1.3
REV4=1.4
REV5=1.5
REV=1.2
echo $N Range test '(1.1 and 1.1,' ....................$NL
X=`prs -1r\(${REV1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1r${REV1}, FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test '[1.1 and 1.1. and 1.1' ............$NL
X=`prs -1r\[${REV1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1r${REV1}. FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
X=`prs -1r${REV1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with nothing - got bad range $X; exit 1
fi
echo OK
REV=1.3
echo $N Range test '(1.2 and 1.2,' ....................$NL
X=`prs -1r\(${REV2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1r${REV2}, FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.2
echo $N Range test '[1.2 and 1.2. and 1.2' ............$NL
X=`prs -1r\[${REV2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1r${REV2}. FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
X=`prs -1r${REV2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with nothing - got bad range $X; exit 1
fi
echo OK
echo $N Range test '(1.5 and 1.5,' ....................$NL
X=`prs -1r\(${REV5} FILE | head -1`
if [ "$X" != "" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1r${REV5}, FILE | head -1`
if [ "$X" != "" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.5
echo $N Range test '[1.5 and 1.5. and 1.5' ............$NL
X=`prs -1r\[${REV5} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1r${REV5}. FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
X=`prs -1r${REV5} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with nothing - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test '1.2) and ,1.2' ....................$NL
X=`prs -1r${REV2}\) FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1r,${REV2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.2
echo $N Range test '1.2] and .1.2' ....................$NL
X=`prs -1r${REV2}\] FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1r.${REV2} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test '1.1) and ,1.1' ....................$NL
X=`prs -1r${REV1}\) FILE | head -1`
if [ "$X" != "" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -1r,${REV1} FILE | head -1`
if [ "$X" != "" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
REV=1.1
echo $N Range test '1.1] and .1.1' ....................$NL
X=`prs -1r${REV1}\] FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -1r.${REV1} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test '(1.1,1.3)' and 1.1,,1.3 ...........$NL
X=`prs -r\(${REV1},${REV3}\) FILE | head -1`
REV=1.2
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -r${REV1},,${REV3} FILE | head -1`
if [ "$X" != "======== FILE ${REV} ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[1.1,1.3]' and 1.1..1.3 on ........$NL
X=`prs -r\[${REV1},${REV3}\] FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.3 ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -r${REV1}..${REV3} FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.3 ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test '(1.2,1.3]' and 1.2,.1.3 ...........$NL
X=`prs -r\(${REV1},${REV3}\] FILE | head -1`
if [ "$X" != "======== FILE 1.2..1.3 ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -r${REV1},.${REV3} FILE | head -1`
if [ "$X" != "======== FILE 1.2..1.3 ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[D,D)' and D.,D on 1.1..1.2 .......$NL
X=`prs -r\[${REV1},${REV3}\) FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.2 ========" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -r${REV1}.,${REV3} FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.2 ========" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
# ---------------------- end of revision ranges

echo ---------- Partially specified date range tests ------------
DATE=87
echo $N Range test '(87 and 87,' on 1.1.. .............$NL
X=`prs -c\(${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.1.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}, FILE | head -1`
if [ "$X" != "======== FILE 1.1.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
DATE=8705
echo $N Range test '(8705 and 8705,' on 1.1.. .........$NL
X=`prs -c\(${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.1.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}, FILE | head -1`
if [ "$X" != "======== FILE 1.1.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
DATE=8706
echo $N Range test '(8706 and 8706,' on 1.2.. .........$NL
X=`prs -c\(${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.2.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}, FILE | head -1`
if [ "$X" != "======== FILE 1.2.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
DATE=87/05/2823:49:57
echo $N Range test '(87/05/2823:49:57' on 1.2.. .......$NL
X=`prs -c\(${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.2.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}, FILE | head -1`
if [ "$X" != "======== FILE 1.2.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[87/05/2823:49:57' on 1.1.. .......$NL
X=`prs -c\[${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.1.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}. FILE | head -1`
if [ "$X" != "======== FILE 1.1.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
DATE=97/05/2823:49:57
echo $N Range test '(97/05/2823:49:57' on 1.3.. .......$NL
X=`prs -c\(${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.3.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}, FILE | head -1`
if [ "$X" != "======== FILE 1.3.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[97/05/2823:49:57' on 1.2.. .......$NL
X=`prs -c\[${DATE} FILE | head -1`
if [ "$X" != "======== FILE 1.2.. ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c${DATE}. FILE | head -1`
if [ "$X" != "======== FILE 1.2.. ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[87,97]' on 1.1..1.4 ..............$NL
X=`prs -c\[87,97\] FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.4 ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c87..97 FILE | head -1`
if [ "$X" != "======== FILE 1.1..1.4 ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test '[97,97]' on 1.2..1.4 ..............$NL
X=`prs -c\[97,97\] FILE | head -1`
if [ "$X" != "======== FILE 1.2..1.4 ========" ]
then	echo failed with paren - got bad range $X; exit 1
fi
X=`prs -c97..97 FILE | head -1`
if [ "$X" != "======== FILE 1.2..1.4 ========" ]
then	echo failed with comma - got bad range $X; exit 1
fi
echo OK
echo $N Range test -c86\] and -c.86 on null ..........$NL
X=`prs -c86\] FILE | head -1`
if [ "$X" != "" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -c.86 FILE | head -1`
if [ "$X" != "" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK
echo $N Range test -c\[99 and -c99. on null ..........$NL
X=`prs -c\[99 FILE | head -1`
if [ "$X" != "" ]
then	echo failed with bracket - got bad range $X; exit 1
fi
X=`prs -c99. FILE | head -1`
if [ "$X" != "" ]
then	echo failed with dot - got bad range $X; exit 1
fi
echo OK

echo ---------- Multiple file range tests ------------
# Make sure the same thing works with multiple files
# We're testing to make sure that splitting dates get unsplit across each file.
# Test D..D and (D,D]
for i in FILE1 FILE2 FILE3 FILE4
do cp SCCS/s.FILE SCCS/s.$i
done
admin -qsA=1.3 FILE2
echo $N Range test -cA, in only some files ..........$NL
GOOD=`prs -1cA, FILE2 | head -1`
if [ "$GOOD" != "`prs -1cA, FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -cA. in only some files ..........$NL
GOOD=`prs -1cA. FILE2 | head -1`
if [ "$GOOD" != "`prs -1cA. FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -c,A in only some files ..........$NL
GOOD=`prs -1c,A FILE2 | head -1`
if [ "$GOOD" != "`prs -1c,A FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -c.A in only some files ..........$NL
GOOD=`prs -1c.A FILE2 | head -1`
if [ "$GOOD" != "`prs -1c.A FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -c\(A in only some files ..........$NL
GOOD=`prs -1c\(A FILE2 | head -1`
if [ "$GOOD" != "`prs -1c\(A FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -c\[A in only some files ..........$NL
GOOD=`prs -1c\[A FILE2 | head -1`
if [ "$GOOD" != "`prs -1c\[A FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -cA\) in only some files ..........$NL
GOOD=`prs -1cA\) FILE2 | head -1`
if [ "$GOOD" != "`prs -1cA\) FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -cA\] in only some files ..........$NL
GOOD=`prs -1cA\] FILE2 | head -1`
if [ "$GOOD" != "`prs -1cA\] FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
# -----------------------------------------------------------------

for i in 1 2 3
do	co -ql FILE3
	ls >> FILE3
	delta -qy'' FILE3
done
echo $N Range test -r1.5, in only some files ........$NL
GOOD=`prs -1r1.5, FILE3 | head -1`
if [ "$GOOD" != "`prs -1r1.5, FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r1.6. in only some files ........$NL
GOOD=`prs -1r1.6. FILE3 | head -1`
if [ "$GOOD" != "`prs -1r1.6. FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r,1.6 in only some files ........$NL
GOOD=`prs -1r,1.6 FILE3 | head -1`
if [ "$GOOD" != "`prs -1r,1.6 FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r.1.6 in only some files ........$NL
GOOD=`prs -1r.1.6 FILE3 | head -1`
if [ "$GOOD" != "`prs -1r.1.6 FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r\(1.6 in only some files ........$NL
GOOD=`prs -1r\(1.6 FILE3 | head -1`
if [ "$GOOD" != "`prs -1r\(1.6 FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r\[1.6 in only some files ........$NL
GOOD=`prs -1r\[1.6 FILE3 | head -1`
if [ "$GOOD" != "`prs -1r\[1.6 FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r1.6\) in only some files ........$NL
GOOD=`prs -1r1.6\) FILE3 | head -1`
if [ "$GOOD" != "`prs -1r1.6\) FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK
echo $N Range test -r1.6\] in only some files ........$NL
GOOD=`prs -1r1.6\] FILE3 | head -1`
if [ "$GOOD" != "`prs -1r1.6\] FILE1 FILE2 FILE3 FILE4 | head -1`" ]
then	echo Stomped on range; exit 1
fi
echo OK

echo $N Range test -c87..87 on multiple files .......$NL
for i in FILE FILE1 FILE2 FILE3 FILE4
do	prs -c87..87 $i >> PRS
	if [ $i != FILE4 ]; then echo "" >> PRS; fi
done
prs -c87..87 FILE FILE1 FILE2 FILE3 FILE4 > PRS2
cmp -s PRS PRS2
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Range test -c\[87,87\] on multiple files ......$NL
/bin/rm PRS PRS2
for i in FILE FILE1 FILE2 FILE3 FILE4
do	prs -c'[87,87]' $i >> PRS
	if [ $i != FILE4 ]; then echo "" >> PRS; fi
done
prs -c'[87,87]' FILE FILE1 FILE2 FILE3 FILE4 > PRS2
cmp -s PRS PRS2
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK

echo ---------- Misc date tests ------------
echo $N Getting the first delta with -c .............$NL
/bin/rm -f FILE
get $S -c90 FILE
echo 1.1 > F
cmp -s F FILE
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Getting the second delta with -c ............$NL
/bin/rm -f FILE
get $S -c970529 FILE
echo 1.1 > F
echo 1.2 >> F
cmp -s F FILE
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Getting the last delta with -c ..............$NL
/bin/rm -f FILE
get $S -c970624. FILE
cat > F <<EOF
1.1
1.2
1.3
1.4
1.5
EOF
cmp -s F FILE
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Attempting a bad date with -c80 .............$NL
/bin/rm -f FILE
get $S -c80 FILE 2>/dev/null
if [ -f FILE ]; then echo Failed - found a delta that is not there.; exit 1; fi
echo OK
echo $N Attempting a bad date with -c99. ............$NL
/bin/rm -f FILE
get $S -c99. FILE 2>/dev/null
if [ -f FILE ]; then echo Failed - found a delta that is not there.; exit 1; fi
echo OK
echo $N Attempting a bad date with -c01. ............$NL
/bin/rm -f FILE
get $S -c01. FILE 2>/dev/null
if [ -f FILE ]; then echo Failed - found a delta that is not there.; exit 1; fi
echo OK
echo $N Adding dates after 2000 .....................$NL
for D in '00/05/28 23:49:57' '01/05/28 23:49:57' '02/05/30 01:34:11' 
do	cat > INIT <<EOF
D 1.$R $D $USER 0 0 0/0/0
C This is revision 1.$R of $D
EOF
	co $Q -l FILE
	echo 1.$R >> FILE
	delta $Q -IINIT FILE
	R=`expr $R + 1`
done
echo OK
echo $N Trying a date range that covers nothing .....$NL
prs -c88 -c88 FILE > OUT
if [ -s OUT ]; then echo Error - found a delta.; exit 1; fi
echo OK
echo $N Getting the last delta with -c ..............$NL
/bin/rm -f FILE
get $S -c02 FILE
cat > F <<EOF
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
EOF
cmp -s F FILE
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Getting a delta in year 2000 with -c ........$NL
/bin/rm -f FILE
get $S -c00 FILE
cat > F <<EOF
1.1
1.2
1.3
1.4
1.5
1.6
EOF
cmp -s F FILE
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Getting a delta in year 2001 with -c ........$NL
/bin/rm -f FILE
get $S -c01 FILE
cat > F <<EOF
1.1
1.2
1.3
1.4
1.5
1.6
1.7
EOF
cmp -s F FILE
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
R=1
for D in '97/06/23 01:33:45' '00/01/30 17:45:17' '01/01/10 10:10:10'
do	cat > INIT <<EOF
D 1.$R $D $USER 0 0 0/0/0
C This is revision 1.$R of $D
EOF
	echo '%''G%' > YEAR4
	if [ $R -eq 1 ] 
	then	delta $Q -i -IINIT YEAR4
	else	delta $Q -IINIT YEAR4
	fi
	R=`expr $R + 1`
	co $Q -l YEAR4
done
ci $Q YEAR4	# clean it
echo $N Checking Y2K date expansion w/o -fY .........$NL
get $S -r1.1 YEAR4
if [ '06/23/97' != "`cat YEAR4`" ]; then echo Failed on 1.1.; exit 1; fi
get $S YEAR4
if [ '01/10/01' != "`cat YEAR4`" ]; then echo Failed on 1.3.; exit 1; fi
echo OK
echo $N Checking Y2K date expansion w -fY ...........$NL
admin $Q -fY YEAR4
get $S -r1.1 YEAR4
if [ '06/23/1997' != "`cat YEAR4`" ]; then echo Failed on 1.1.; exit 1; fi
get $S YEAR4
if [ '01/10/2001' != "`cat YEAR4`" ]; then echo Failed on 1.3.; exit 1; fi
echo OK

echo ---------- Admin tests ------------
/bin/rm -rf foo SCCS A
echo $N Creating an empty file ......................$NL
admin $Q -n empty
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
if [ ! -f SCCS/s.empty ]; then echo Failed.; exit 1; fi
set `wc -w SCCS/s.empty`
if [ $1 -ne 46 ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N Creating the same file '(should fail)' ........$NL
admin $Q -n empty 2> ERR
if [ $? -eq 0 ]; then echo Bad exit code 0.; exit 1; fi
echo OK
/bin/rm -f ERR
echo $N Creating a file from foo ....................$NL
cp SAVE foo
admin $Q -ifoo foo
if [ ! -f SCCS/s.foo ]; then echo Failed.; exit 1; fi
if [ ! -f foo ]; then echo Failed - gfile was removed.; exit 1; fi
set `wc -w SCCS/s.foo`
if [ $1 -ne 100 ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N Creating an empty file from /dev/null .......$NL
admin $Q -i/dev/null empty2
if [ ! -f SCCS/s.empty2 ]; then echo Failed.; exit 1; fi
set `wc -w SCCS/s.empty2`
if [ $1 -ne 46 ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N Creating a file from stdin ..................$NL
admin $Q -i stdin < SAVE
if [ ! -f SCCS/s.stdin ]; then echo Failed.; exit 1; fi
set `wc -w SCCS/s.stdin`
if [ $1 -ne 100 ]; then echo Failed - wrong size.; exit 1; fi
echo OK
/bin/rm -rf foo SCCS 
echo $N Creating an empty file with rel 3.1 .........$NL
admin $Q -r3.1 -n empty
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
if [ ! -f SCCS/s.empty ]; then echo Failed.; exit 1; fi
grep -q 'd D 3.1 ' SCCS/s.empty
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
/bin/rm -rf SCCS 
echo $N Creating an empty file with rel 1.2.3.4 .....$NL
admin $Q -r1.2.3.4 -n empty
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
if [ ! -f SCCS/s.empty ]; then echo Failed.; exit 1; fi
grep -q 'd D 1.2.3.4 ' SCCS/s.empty
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
/bin/rm -rf SCCS 
echo $N Attempting bad create with rel 1.2.3 ........$NL
admin $Q -r1.2.3 -n empty 2> ERR
if [ $? -eq 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
/bin/rm -rf SCCS 
echo $N Attempting bad create with rel 1.2.3.4.9999 .$NL
admin $Q -r1.2.3.4.9999 -n empty 2> ERR
if [ $? -eq 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
/bin/rm -rf SCCS 
echo This is the description. > D
echo $N Creating a file with description ............$NL
admin $Q -n -tD foo
if [ ! -f SCCS/s.foo ]; then echo Failed.; exit 1; fi
set `wc -w SCCS/s.foo`
if [ $1 -ne 50 ]; then echo Failed - wrong size.; exit 1; fi
grep -q "`cat D`" SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
echo $N Removing description ........................$NL
cp SCCS/s.foo SCCS/s.bar
admin $Q -t foo
admin $Q -T bar
set `wc -w SCCS/s.foo`
if [ $1 -ne 46 ]; then echo Failed - wrong size.; exit 1; fi
set `wc -w SCCS/s.bar`
if [ $1 -ne 46 ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N And putting it back .........................$NL
admin $Q -tD bar
set `wc -w SCCS/s.bar`
if [ $1 -ne 50 ]; then echo Failed - wrong size.; exit 1; fi
echo OK
echo $N One last text test ..........................$NL
admin $Q -n -t junk 2>ERR
if [ $? -eq 0 ]; then echo Failed.; exit 1; fi
echo OK
/bin/rm -rf SCCS foo
cp SAVE foo
echo $N Creating a file with a comment ..............$NL
admin $Q -n -y'THIS IS THE COMMENT' foo
grep -q "c THIS IS THE COMMENT" SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
/bin/rm -rf SCCS foo
echo $N File w/ comment, text, release ..............$NL
admin $Q -n -tD -r1.2 -y'THIS IS THE COMMENT' foo
grep -q "c THIS IS THE COMMENT" SCCS/s.foo
if [ $? -ne 0 ]; then echo Bad comment.; exit 1; fi
grep -q "`cat D`" SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
echo $N Making sure that admin -r1.2 -z fails .......$NL
admin $Q -r1.2 -z foo 2>ERR
if [ $? -eq 0 ]; then echo Failed - exit code.; exit 1; fi
echo OK
echo $N Changing the path. ..........................$NL
admin $Q -p/this/is/the/path:1.2 foo
grep -q 'f p 1.2 /this/is/the/path$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Deleting the path. ..........................$NL
admin $Q -P1.2 foo
grep -q 'f p 1.2 /this/is/the/path$' SCCS/s.foo
if [ $? -ne 1 ]; then echo Failed - same path there.; exit 1; fi
grep -q 'f p 1.2' SCCS/s.foo
if [ $? -ne 1 ]; then echo Failed - some path there.; exit 1; fi
echo OK
echo $N And putting it back. ........................$NL
admin $Q -p/this/is/the/path:1.2 foo
grep -q 'f p 1.2 /this/is/the/path$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Adding a symbol to rev 1.2  ..................$NL
admin $Q -sSYMBOL:1.2 foo
grep -q 'f s 1.2 SYMBOL$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
co -lq foo
ci -fqy foo
echo $N Attempting the same add to rev 1.3 ..........$NL
admin $Q -sSYMBOL:1.3 foo 2>ERR
if [ $? -eq 0 ]; then echo should have failed.; exit 1; fi
echo OK
echo $N Replacing the symbol ........................$NL
admin $Q -sSYMBOL=1.3 foo 
grep -q 'f s 1.2 SYMBOL$' SCCS/s.foo
if [ $? -eq 0 ]; then echo Failed to delete old symbol.; exit 1; fi
grep -q 'f s 1.3 SYMBOL$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed to add new symbol.; exit 1; fi
echo OK
echo $N Adding a symbol to TOT ......................$NL
admin $Q -sTOT: foo
grep -q 'f s 1.3 TOT$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Changing TOT to rev 1.2 .....................$NL
admin $Q -sTOT=1.2 foo
grep -q 'f s 1.3 TOT$' SCCS/s.foo
if [ $? -ne 1 ]; then echo Failed.; exit 1; fi
grep -q 'f s 1.2 TOT$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Putting TOT back to TOT .....................$NL
admin $Q -sTOT= foo
grep -q 'f s 1.3 TOT$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
grep -q 'f s 1.2 TOT$' SCCS/s.foo
if [ $? -ne 1 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Trying symbol \'the symbol\' ..................$NL
admin $Q -s'the symbol':1.2 foo 
grep -q 'f s 1.2 the\\ symbol$' SCCS/s.foo
if [ $? -ne 0 ]; then echo Failed to add symbol properly.; exit 1; fi
echo OK
echo XXX - test symbols and paths with spaces in them - XXX
echo XXX - make two different symbols like "'the a'" and "'the b'"
echo XXX - and make sure that you get the right rev.
# "admin -h A foo" used to fail
echo $N Checking argument processing ................$NL
date > Z
ci $Q -i Z
admin $Q -h Z foo
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK

echo ---------- Include/exclude tests ------------
admin $Q -n include
touch I
for i in 1 2 3 4 5 6 7 8 9 10
do	co $Q -l include
	echo $i >> include
	echo $i >> I
	ci $Q -y"Rev $i" include
done
co $Q include
echo $N Making sure of contents .....................$NL
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
co $Q -r1 include
echo $N Making sure of contents w/ -r1 ..............$NL
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Including a rev in the middle ...............$NL
get $S -r1.2 -i1.4 include
echo 1 > I
echo 3 >> I
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Including two revs in the middle ............$NL
get $S -r1.2 -i1.4,1.6 include
echo 1 > I
echo 3 >> I
echo 5 >> I
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Including all revs -i1.2-1.11 ...............$NL
get $S -r1.1 -i1.2-1.11 include
cp /dev/null I; for i in 1 2 3 4 5 6 7 8 9 10; do echo $i >> I; done
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
admin $Q -sTOT include
echo $N Including all revs -i1.2-TOT ................$NL
/bin/rm -f include
get $S -r1.1 -i1.2-TOT include
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Including all revs -i1.2,1.3,1.4-TOT ........$NL
/bin/rm -f include
get $S -r1.1 -i1.2,1.3,1.4-TOT include
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Excluding one rev in the middle .............$NL
cp /dev/null I; for i in 1 2 3 4 6 7 8 9 10; do echo $i >> I; done
get $S -x1.6 include
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Excluding last rev -xTOT ....................$NL
cp /dev/null I; for i in 1 2 3 4 5 6 7 8 9; do echo $i >> I; done
get $S -xTOT include
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Checking exclude lists in s.file ............$NL
cp /dev/null I; for i in 1 2 3 4 5 6 7 8 9; do echo $i >> I; done
get $S -exTOT include
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
ci $Q -fy include
X=`sed -n 4p < SCCS/s.include`
if [ "$X" != "x 11" ]; then echo Failed - bad exclude list $X; exit 1; fi
echo OK
echo $N Checking include lists in s.file ............$NL
cp /dev/null I; for i in 1 2 3 4; do echo $i >> I; done
get $S -r1.1 -ei1.2-1.5 include
cmp -s I include
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
/bin/rm -f SAVE
cp include SAVE
ci $Q -fy include
X=`sed -n 4p < SCCS/s.include`
if [ "$X" != "i 2 3 4 5" ]; then echo Failed - bad include list $X; exit 1; fi
echo OK
echo $N Making sure the includes worked .............$NL
co $Q -r1.1.1.1 include
cmp -s include SAVE
if [ $? -ne 0 ]; then echo Failed.; exit 1; fi
echo OK
echo $N Include/exclude ixg0 ........................$NL
# Clean up 
/bin/rm -f s.i i p.i x.i z.i
# Build up a file with 1.1 .. 1.4
echo 1.1 > i
admin -n -ii s.i 2>/dev/null
rm i
for i in 2 3 4 
do	get -s -e s.i
	echo 1.$i >> i
	delta -s -y'' s.i
done
# Make a branch
get -s -e -r1.2 s.i
echo 1.2.1.1 >> i
delta -s -y'' s.i
# Make a different branch which includes the previous branch
get -s -e -r1.2 -i1.2.1.1 s.i
echo 1.2.2.1 >> i
delta -s -y'' s.i
get -s -r1.2.2.1 s.i 
cat >I <<EOF
1.1
1.2
1.2.1.1
1.2.2.1
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg0 failure 1; exit 1; fi
# Make a child that includes the second branch
get -s -e -i1.2.2.1 s.i
echo 1.5 >> i
delta -s -y'' s.i
# Make a branch which includes the second but excludes the first
get -s -e -r1.2 -i1.2.2.1 -x1.2.1.1 s.i
echo 1.2.3.1 >> i
delta -s -y'' s.i
get -s -r1.2.3.1 s.i
cat >I <<EOF
1.1
1.2
1.2.2.1
1.2.3.1
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg0 failure 2; exit 1; fi
# Make a child that includes that last branch and see what we get.
get -s -e -i1.2.3.1 s.i
echo 1.6 >> i
delta -s -y'' s.i
get -s s.i
cat >I <<EOF
1.1
1.2
1.2.2.1
1.2.3.1
1.3
1.4
1.5
1.6
EOF
echo OK
# --------------------- include/exclude ixg1 ------------------
#
# See if includes mean include all the way up the trunk or just
# the one delta.  It should not.
echo $N Include/exclude ixg1 ........................$NL
# Clean up 
/bin/rm -f s.i i p.i x.i z.i
# Build up a file with 1.1 1.2
echo 1.1 > i
admin -n -ii s.i 2>/dev/null
rm i
get -s -e s.i
echo 1.2 >> i
delta -s -y'' s.i
# Make a branch
get -s -e -r1.1 s.i
echo A >> i
delta -s -y'' s.i
# Continue the branch
get -s -e -r1.1.1 s.i
echo B >> i
delta -s -y'' s.i
# Continue the branch
get -s -e -r1.1.1 s.i
echo C >> i
delta -s -y'' s.i
# Make a child that includes the branch
get -s -e -i1.1.1.3 s.i
echo 1.3 >> i
delta -s -y'' s.i
# If this has A/B/C in it, then an include implies to the root.
# In SUN SCCS, this gets just C.
# echo Should have at least C, and maybe C/B/A 
get -s s.i
cat >I <<EOF
1.1
C
1.2
1.3
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg1 failure 1; exit 1; fi
# Force the whole branch onto the trunk
get -s -e -i1.1.1.3,1.1.1.2,1.1.1.1 s.i
echo 1.4 >> i
delta -s -y'' s.i
# echo Should have C/B/A 
get -s s.i
cat >I <<EOF
1.1
A
B
C
1.2
1.3
1.4
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg1 failure 2; exit 1; fi
echo OK
# --------------------- include/exclude ixg2 ------------------
# See what happens when you include two nodes that have conflicting
# include/excludes.
#
# We create a trunk, 1.1, 1.2
# Create a branch, 1.1.1.1 - this will be either included or excluded
# Create a branch, 1.1.2.1 - this includes 1.1.1.1
# Create a branch, 1.1.3.1 - this also includes 1.1.1.1
# Create a child, 1.1.3.2 - this excludes 1.1.1.1
# Create a child, 1.3 - this includes 1.1.2.1 and 1.1.3.2
echo $N Include/exclude ixg2 ........................$NL
# Clean up 
/bin/rm -f s.i i p.i x.i z.i
# Build up a file with 1.1 1.2
echo 1.1 > i
admin -n -ii s.i 2>/dev/null
rm i
get -s -e s.i
echo 1.2 >> i
delta -s -y'' s.i
# Make a branch
get -s -e -r1.1 s.i
echo A >> i
delta -s -y'' s.i
# Make another branch and include the first branch
get -s -e -r1.1 -i1.1.1.1 s.i
delta -s -y'' s.i
# Make another branch and include the first branch
get -s -e -r1.1 -i1.1.1.1 s.i
delta -s -y'' s.i
# Continue the branch but exclude the first branch
get -s -e -r1.1.3.1 -x1.1.1.1 s.i
delta -s -y'' s.i
# Make a child that includes both branches.
get -s -e -i1.1.2.1,1.1.3.2 s.i
echo 1.3 >> i
delta -s -y'' s.i
# echo ----------- Branch w/ include -------------
get -s -r1.1.2.1 s.i
cat >I <<EOF
1.1
A
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg2 failure 1; exit 1; fi
# echo ----------- Branch w/o include -------------
get -s -r1.1.3.2 s.i
cat >I <<EOF
1.1
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg2 failure 2; exit 1; fi
# echo ----------- Result --------------
get -s s.i
cat >I <<EOF
1.1
1.2
1.3
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg2 failure 3; exit 1; fi
echo OK
# The above should show the result w/o the branch because the exclude
# should be a higher serial number
# --------------------- include/exclude ixg3 ------------------
# See what happens when you include two nodes that have conflicting
# include/excludes.
#
# We create a trunk, 1.1, 1.2
# Create a branch, 1.1.1.1 - this will be either included or excluded
# Create a branch, 1.1.2.1 - this includes 1.1.1.1
# Create a branch, 1.1.3.1 - this also includes 1.1.1.1
# Create a child, 1.1.3.2 - this excludes 1.1.1.1
# Create a child, 1.3 - this includes 1.1.2.1 and 1.1.3.2
echo $N Include/exclude ixg3 ........................$NL
# Clean up 
/bin/rm -f s.i i p.i x.i z.i
# Build up a file with 1.1 1.2
echo 1.1 > i
admin -n -ii s.i 2>/dev/null
rm i
get -s -e s.i
echo 1.2 >> i
delta -s -y'' s.i
# Make a branch
get -s -e -r1.1 s.i
echo A >> i
delta -s -y'' s.i
# Make another branch and include the first branch
get -s -e -r1.1 -i1.1.1.1 s.i
delta -s -y'' s.i
# Continue the branch but exclude the first branch
get -s -e -r1.1.2.1 -x1.1.1.1 s.i
delta -s -y'' s.i
# Make another branch and include the first branch
get -s -e -r1.1 -i1.1.1.1 s.i
delta -s -y'' s.i
# Make a child that includes both branches.
get -s -e -i1.1.2.2,1.1.3.1 s.i
echo 1.3 >> i
delta -s -y'' s.i
# echo ----------- Branch w/ include -------------
get -s -r1.1.3.1 s.i
cat >I <<EOF
1.1
A
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg3 failure 1; exit 1; fi
# echo ----------- Branch w/o include -------------
get -s -r1.1.2.2 s.i
cat >I <<EOF
1.1
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg3 failure 2; exit 1; fi
# echo ----------- Result --------------
get -s s.i
cat >I <<EOF
1.1
A
1.2
1.3
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg3 failure 3; exit 1; fi
echo OK
# The above should show the result w/ the branch because the include
# should be a higher serial number
# --------------------- include/exclude ixg4 ------------------
# See what happens when you include two nodes that have conflicting
# include/excludes.
#
# We create a trunk, 1.1, 1.2
# Create a branch, 1.1.1.1 - this will be either included or excluded
# Create a branch, 1.1.2.1 - this includes 1.1.1.1
# Create a branch, 1.1.3.1 - this excludes 1.1.1.1
# Note: the above ecluded one that wasn't included.
# Create a child, 1.3 - this includes 1.1.2.1 and 1.1.3.1
echo $N Include/exclude ixg4 ........................$NL
# Clean up 
/bin/rm -f s.i i p.i x.i z.i
# Build up a file with 1.1 1.2
echo 1.1 > i
admin -n -ii s.i 2>/dev/null
rm i
get -s -e s.i
echo 1.2 >> i
delta -s -y'' s.i
# Make a branch
get -s -e -r1.1 s.i
echo A >> i
delta -s -y'' s.i
# Make another branch and include the first branch
get -s -e -r1.1 -i1.1.1.1 s.i
delta -s -y'' s.i
# Make another branch and exclude the first branch
get -s -e -r1.1 -x1.1.1.1 s.i
delta -s -y'' s.i
# Make a child that includes both branches.
get -s -e -i1.1.2.1,1.1.3.1 s.i
echo 1.3 >> i
delta -s -y'' s.i
# echo ----------- Branch w/ include -------------
get -s -r1.1.2.1 s.i
cat >I <<EOF
1.1
A
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg4 failure 1; exit 1; fi
# echo ----------- Branch w/ exclude -------------
get -s -r1.1.3.1 s.i
echo 1.1 > I
cmp -s i I
if [ $? -ne 0 ]; then echo ixg4 failure 2; exit 1; fi
# echo ----------- Result --------------
get -s s.i
cat >I <<EOF
1.1
1.2
1.3
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg4 failure 2; exit 1; fi
echo OK
# The above should show the result w/o the branch because the exclude
# should be a higher serial number
# -------------------- include/exclude ixg5 -----------------
# See what happens when you include two nodes that have conflicting
# include/excludes.
#
# We create a trunk, 1.1, 1.2
# Create a branch, 1.1.1.1 - this will be either included or excluded
# Create a branch, 1.1.2.1 - this includes 1.1.1.1
# Create a branch, 1.1.3.1 - this excludes 1.1.1.1
# Note: the above excluded one that wasn't included.
# Create a child, 1.3 - this includes 1.1.2.1 and 1.1.3.1
echo $N Include/exclude ixg5 ........................$NL
# Clean up 
/bin/rm -f s.i i p.i x.i z.i
# Build up a file with 1.1 1.2
echo 1.1 > i
admin -n -ii s.i 2>/dev/null
rm i
get -s -e s.i
echo 1.2 >> i
delta -s -y'' s.i
# Make a branch
get -s -e -r1.1 s.i
echo A >> i
delta -s -y'' s.i
# Make another branch and exclude the first branch
get -s -e -r1.1 -x1.1.1.1 s.i
delta -s -y'' s.i
# Make another branch and include the first branch
get -s -e -r1.1 -i1.1.1.1 s.i
delta -s -y'' s.i
# Make a child that includes both branches.
get -s -e -i1.1.2.1,1.1.3.1 s.i
echo 1.3 >> i
delta -s -y'' s.i
# echo ----------- Branch w/ include -------------
get -s -r1.1.3.1 s.i
echo 1.1 > I
echo A >> I
cmp -s i I
if [ $? -ne 0 ]; then echo ixg5 failure 1; exit 1; fi
# echo ----------- Branch w/ exclude -------------
get -s -r1.1.2.1 s.i
echo 1.1 > I
cmp -s i I
if [ $? -ne 0 ]; then echo ixg5 failure 2; exit 1; fi
# echo ----------- Result --------------
get -s s.i
cat >I <<EOF
1.1
A
1.2
1.3
EOF
cmp -s i I
if [ $? -ne 0 ]; then echo ixg5 failure 3; exit 1; fi
echo OK
# The above should show the result w/ the branch because the exclude
# should be a higher serial number

echo ---------- diffs tests ------------
echo 1.1 > Diffs
admin -q -n -iDiffs Diffs
/bin/rm -f Diffs
# D 1.2 93/03/11 00:50:40.000 butthead 2 1  9/2/44
# C added 4.x etc targets
for i in 2 3 4 5 6 7 8 9 10
do	co $Q -l Diffs
	echo 1.$i >> Diffs
	echo "D 1.$i 20/03/11 00:00:0$i butthead a b c/d/e" | sed s/010/10/ > Init
	echo "C Rev $i" >> Init
	delta $Q -IInit Diffs
done
echo $N Checking diffs against readonly file ........$NL
co $Q -r1.9 Diffs
diffs Diffs > D
cat > W << EOF
===== Diffs 1.10 vs ? =====
10d9
< 1.10
EOF
cmp -s D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK
echo $N Checking diff against edited file ...........$NL
co $Q -l Diffs
echo foo >> Diffs
diffs Diffs > D
cat > W <<EOF
===== Diffs 1.10 vs edited =====
10a11
> foo
EOF
cmp -s D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK
echo $N Checking diff -r1.8 against edited file .....$NL
diffs -r1.8 Diffs > D
cat > W <<EOF
===== Diffs 1.8 vs edited =====
8a9,11
> 1.9
> 1.10
> foo
EOF
cmp -s D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK
echo $N Checking diff -r1.8 w/ no file ..............$NL
clean -u Diffs
diffs -r1.8 Diffs > D
cat > W <<EOF
===== Diffs 1.8 vs 1.10 =====
8a9,10
> 1.9
> 1.10
EOF
cmp -s D W
diff D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK
echo $N Checking diff -r1.8 -r1.9 ...................$NL
diffs -r1.8 -r1.9 Diffs > D
cat > W <<EOF
===== Diffs 1.8 vs 1.9 =====
8a9
> 1.9
EOF
cmp -s D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK
echo $N Checking diff -dSSS -r1.9 ...................$NL
admin $Q -sSSS=1.7 Diffs
diffs -dSSS -r1.9 Diffs > D
cat > W <<EOF
===== Diffs 1.7 vs 1.9 =====
7a8,9
> 1.8
> 1.9
EOF
cmp -s D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK
echo $N Checking diff -dSSS .........................$NL
diffs -dSSS Diffs > D
cat > W <<EOF
===== Diffs 1.7 vs 1.10 =====
7a8,10
> 1.8
> 1.9
> 1.10
EOF
cmp -s D W
if [ $? -ne 0 ]; then echo Failed to get correct diffs.; exit 1; fi
echo OK

echo ---------- Binary/gzipped tests ------------
echo $N Trying to check in some binary data .........$NL
cp ../ci data
admin $Q -idata -b uuencode
co $Q -l uuencode
cmp -s ../ci uuencode
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Trying to change some binary data ...........$NL
cp ../co uuencode
ci $Q -y uuencode
co $Q uuencode
cmp -s ../co uuencode
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Checking that revision 1.1 is still OK ......$NL
co -r1.1 $Q uuencode
cmp -s ../ci uuencode
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Trying to clean an encoded file .............$NL
co $Q -l uuencode
clean uuencode
if [ $? -ne 0 ]; then echo Clean failed ; exit 1; fi
if [ -f gzipped ]; then echo Clean failed ; exit 1; fi
echo OK
echo $N Trying to check in some gzipped data ........$NL
cp ../ci data
admin $Q -idata -g gzipped
co -l $Q gzipped
cmp -s ../ci gzipped
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Trying to change some gzipped data ..........$NL
cp ../co gzipped
ci $Q -y gzipped
co $Q gzipped
cmp -s ../co gzipped
if [ $? -ne 0 ]; then echo Failed - files differ.; exit 1; fi
echo OK
echo $N Trying to clean a gzipped file ..............$NL
co $Q -l gzipped
clean gzipped
if [ $? -ne 0 ]; then echo Clean failed ; exit 1; fi
if [ -f gzipped ]; then echo Clean failed ; exit 1; fi
echo OK

# Clean up.
cd ..
/bin/rm -rf .regression

echo ---------------------------------------------
echo Hey, all tests passed.  Must be my lucky day.
echo ---------------------------------------------
exit 0
