3 # $NetBSD: rcstest,v 1.1.1.2 1996/10/13 21:56:37 veego Exp $
5 # Test RCS's functions.
6 # The RCS commands are searched for in the PATH as usual;
7 # to test the working directory's commands, prepend . to your PATH.
9 # Test RCS by creating files RCS/a.* and RCS/a.c.
10 # If all goes well, output nothing, and remove the temporary files.
11 # Otherwise, send a message to standard output.
12 # Exit status is 0 if OK, 1 if an RCS bug is found, and 2 if scaffolding fails.
13 # With the -v option, output more debugging info.
15 # If diff outputs `No differences encountered' when comparing identical files,
16 # then rcstest may also output these noise lines; ignore them.
18 # The current directory and ./RCS must be readable, writable, and searchable.
20 # Id: rcstest,v 5.14 1995/06/16 06:19:24 eggert Exp
23 # Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
24 # Distributed under license by the Free Software Foundation, Inc.
26 # This file is part of RCS.
28 # RCS is free software; you can redistribute it and/or modify
29 # it under the terms of the GNU General Public License as published by
30 # the Free Software Foundation; either version 2, or (at your option)
33 # RCS is distributed in the hope that it will be useful,
34 # but WITHOUT ANY WARRANTY; without even the implied warranty of
35 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 # GNU General Public License for more details.
38 # You should have received a copy of the GNU General Public License
39 # along with RCS; see the file COPYING.
40 # If not, write to the Free Software Foundation,
41 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
43 # Report problems and direct all questions to:
45 # rcs-bugs@cs.purdue.edu
47 # The Makefile overrides the following defaults.
48 : ${ALL_CFLAGS=-Dhas_conf_h}
51 # : ${LDFLAGS=} ${LIBS=} tickles old shell bug
53 CL
="$CC $ALL_CFLAGS $LDFLAGS -o a.out"
60 RCSfile
=RCS
${SLASH}a.c
61 RCS_alt
=RCS
${SLASH}a.d
62 lockfile
=RCS
${SLASH}a._
67 *) echo >&2 "$0: usage: $0 [-v]"; exit 2
72 else rmdir=rmdir; mkdir RCS ||
exit
75 rm -f a.
* $RCSfile $RCS_alt $lockfile &&
77 echo 1.1.1.1 >a
.3x1
&&
78 echo 1.2 >a
.12 ||
{ echo "#initialization failed"; exit 2; }
80 case "`$DIFF -c a.11 a.3x1`" in
84 echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic"
88 rcs
-i -L -ta.11 $q a.c
&&
90 echo "#rcs -i -L failed; perhaps RCS is not properly installed."
94 rlog a.c
>/dev
/null ||
{ echo "#rlog failed on empty RCS file"; exit 1; }
95 rm -f $RCSfile ||
exit 2
98 ci
-ta.11 -mm $q a.c
&&
100 rcs
-L $q a.c ||
{ echo "#ci+rcs -L failed"; exit 1; }
101 test ! -f a.c ||
{ echo "#ci did not remove working file"; exit 1; }
105 test -f a.c ||
{ echo '#co' $l did not create working
file; exit 1; }
106 $diff a
.11 a.c ||
{ echo '#ci' followed by co
$l is not a no-op
; exit 1; }
112 $diff a
.12 a.c ||
{ echo "#ci+co failed"; exit 1; }
116 $diff a
.11 a.c ||
{ echo "#can't retrieve first revision"; exit 1; }
120 ci
-r1.1
.1 -mm $q a.c
&&
121 co
-r1.1
.1.1 $q a.c
&&
122 $diff a
.3x1 a.c ||
{ echo "#branches failed"; exit 1; }
128 $diff a
.12 a.c ||
{ echo "#(co -l; ci -f) failed"; exit 1; }
135 ci
-mm $q a.c ||
{ echo "#ci -l failed"; exit 1; }
141 test -r a.c ||
{ echo "#ci -u didn't create a working file"; exit 1; }
143 echo error
>a.c ||
exit 2
144 ci
-mm $q a.c
2>/dev
/null
&& { echo "#ci -u didn't unlock the file"; exit 1; }
148 co
-u $q a.c ||
{ echo "#rcs -l + co -u failed"; exit 1; }
150 echo error
>a.c ||
exit 2
151 ci
-mm $q a.c
2>/dev
/null
&& { echo "#co -u didn't unlock the file"; exit 1; }
155 co
-f $q a.c ||
{ echo "#co -f failed"; exit 1; }
156 $diff a
.11 a.c
>/dev
/null
&& { echo "#co -f had no effect"; exit 1; }
158 co
-p1.1
$q a.c
>a.t
&&
159 $diff a
.11 a.t ||
{ echo "#co -p failed"; exit 1; }
167 ci
-${n}n
-mm $q a.c
&&
169 $diff a.
$n a.c ||
{ echo "#ci -$n failed"; exit 1; }
178 me
=`who am i` ||
exit 2
179 me
=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
181 '') echo >&2 "$0: cannot deduce user name"; exit 2
187 # Get the date of the previous revision in UTC.
188 date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` ||
exit
190 [0-9][0-9][0-9]*[0-9]/[0-1][0-9]/[0-3][0-9]\
[0-2][0-9]:[0-5][0-9]:[0-6][0-9]);;
191 *) echo >&2 "$0: $date: bad rlog date output"; exit 1
193 PWD
=`pwd` && export PWD
&&
196 sed 's/@/$/g' >a.kv
<<EOF
199 @Header: $PWD$SLASH$RCSfile 2.1 $date w s @
200 @Id: a.c 2.1 $date w s @
203 * Revision 2.1 $date w
209 @Source: $PWD$SLASH$RCSfile @
213 sed 's/:.*\$/$/' a.kv
>a.k
&&
214 sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv
>a.kvl
&&
215 sed s
/Oz
//g a.kv
>a.e
&&
216 sed s
/Oz
/N
/g a.kv
>a.N
&&
217 sed -e '/\$/!d' -e 's/\$$/: old $/' a.k
>a.o
&&
218 sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv
>a.v
&&
220 ci
-d"$date" -nOz -ss -ww -u2.1
-mm $q a.c
&&
221 $diff a.kv a.c ||
{ echo "#keyword expansion failed"; exit 1; }
222 co
-pOz -ko $q a.c
>a.oo
&&
223 $diff a.o a.oo ||
{ echo "#co -p -ko failed"; exit 1; }
224 cp a.kv a.o
&& cp a.o a.b ||
exit 2
228 $diff a.kv a.c ||
{ echo "#ci -k failed"; exit 1; }
229 sed -n 's/^[^$]*\$/$/p' a.kv
>a.i
&&
231 sed -e 1d
-e 's/^[ ]*//' a.i1
>a.i2
&&
232 $diff a.i a.i2 ||
{ echo "#ident failed"; exit 1; }
234 rcs
-i $q a.c
2>/dev
/null
&& { echo "#rcs -i permitted existing file"; exit 1; }
241 rcs
-l1.1
.1 $q a.c
&&
242 ci
-r1.1
.1.2 -mm $q a.c
&&
243 rcs
-b1.1
.1 $q a.c
&&
244 test " `co -p $q a.c`" = ' 1.1.1.2' ||
{ echo "#rcs -b1.1.1 failed"; exit 1; }
246 test " `co -p $q a.c`" = ' 2.2' ||
{ echo "#rcs -b failed"; exit 1; }
248 echo 2.3 >a.c ||
exit 2
249 rcs
-U $q a.c ||
{ echo "#rcs -U failed"; exit 1; }
250 ci
-mm $q a.c ||
{ echo "#rcs -U didn't unset strict locking"; exit 1; }
251 rcs
-L $q a.c ||
{ echo "#rcs -L failed"; exit 1; }
252 echo error
>a.c ||
exit 2
253 ci
-mm $q a.c
2>/dev
/null
&& { echo "#ci retest failed"; exit 1; }
256 log0
=`rlog -h a.c` &&
259 log1
=`rlog -h a.c` &&
260 test " $log0" = " $log1" ||
{ echo "#unchanged ci didn't revert"; exit 1; }
263 rcs
-nN:1.1 $q a.c
&&
265 $diff a
.11 a.c ||
{ echo "#rcs -n failed"; exit 1; }
268 rcs
-NN:2.1 $q a.c
&&
270 $diff a.N a.c ||
{ echo "#rcs -N failed"; exit 1; }
274 echo ':::$''Log$' >a.c
&&
276 test " `sed '$!d' a.c`" = ' :::' ||
{ echo "#comment leader failed"; exit 1; }
281 $diff a.e a.c ||
{ echo "#rcs -o failed"; exit 1; }
283 rcsdiff
-r1.1
-rOz $q a.c
>a
.0
286 *) echo "#rcsdiff bad status"; exit 1
289 $diff a
.0 a
.1 ||
{ echo "#rcsdiff failed"; exit 1; }
291 rcs
-l2.1
$q a.c ||
{ echo "#rcs -l2.1 failed"; exit 1; }
292 for i
in b k kv kvl o v
296 rcsdiff
-k$i -rOz $q a.c ||
{ echo "#rcsdiff -k$i failed"; exit 1; }
298 co
-p1.1
-ko $q a.c
>a.t
&&
299 $diff a
.11 a.t ||
{ echo "#co -p1.1 -ko failed"; exit 1; }
300 rcs
-u2.1
$q a.c ||
{ echo "#rcs -u2.1 failed"; exit 1; }
304 rcsclean
-u $q a.c ||
{ echo "#rcsclean botched a nonexistent file"; exit 1; }
308 rcsclean
-n $q a.c
&&
309 rcsclean
-n -u $q a.c
&&
310 test -f a.c ||
{ echo "#rcsclean -n removed a file"; exit 1; }
315 test ! -f a.c ||
{ echo "#rcsclean missed an unlocked file"; exit 1; }
320 test -f a.c ||
{ echo "#rcsclean removed a locked file"; exit 1; }
321 rcsclean
-u $q a.c
&&
323 echo "#rcsclean -u missed an unchanged locked file"; exit 1;
330 rcsclean
$q -u a.c
&&
331 test -f a.c ||
{ echo "#rcsclean removed a changed file"; exit 1; }
344 co
-p2.2
$q a.c |
sed -e s
/2.2/2.3/ -e s
/b
/b
1/ >a.c
&&
346 co
-p2.2
$q a.c |
sed -e s
/2.2/new
/ -e s
/d
/d
1/ >a.c ||
exit 2
365 rcsmerge
-E -r2.2
-r2.3
$q a.c
368 if $diff a
.0 a.c
>/dev
/null
369 then echo "#warning: diff3 -E does not work, " \
370 "so merge and rcsmerge ignore overlaps and suppress overlap lines."
372 $diff a
.1 a.c ||
{ echo "#rcsmerge failed (status 0)"; exit 1; }
373 echo "#warning: The diff3 lib program exit status ignores overlaps," \
374 "so rcsmerge does not warn about overlap lines that it generates."
378 $diff a
.1 a.c ||
{ echo "#rcsmerge failed (status 1)"; exit 1; }
381 echo "#rcsmerge bad status"; exit 1
384 # Avoid `tr' if possible; it's not portable, and it can't handle null bytes.
385 # Our substitute exclusive-ORs with '\n';
386 # this ensures null bytes on output, which is even better than `tr',
387 # since some diffs think a file is binary only if it contains null bytes.
392 while ((c=getchar()) != EOF)
398 if (rm -f a.exe a.out
&& $CL a.c
$L >&2) >/dev
/null
2>&1
407 co
-p $q a.c |
$tr '\012' '\200' >a
.24 &&
409 ciOut
=`(ci -l -mm $q a.c 2>&1)` &&
411 ?
*) echo >&2 "$ciOut"
413 co
-p $q a.c |
$tr '\200' '\012' >a.c
&&
414 rcsdiff
-r2.3
$q a.c
>/dev
/null
&&
419 rcsdiff
-r2.4
$q a.c
>/dev
/null
420 } ||
echo "#warning: Traditional diff is used, so RCS is limited to text files."
422 rcs
-u -o2.4
: $q a.c ||
{ echo "#rcs -u -o failed"; exit 1; }
424 rcs
-i -Aa.c
-t- $q a.d ||
{ echo "#rcs -i -A failed"; exit 1; }
426 rlog
-r2.1 a.c
>a.t
&&
427 grep '^checked in with -k' a.t
>/dev
/null
&&
428 sed '/^checked in with -k/d' a.t
>a.u
&&
441 keyword substitution: kv
442 total revisions: 13; selected revisions: 1
445 ----------------------------
447 date: $date; author: w; state: s; lines: +14 -1
448 =============================================================================
450 test $?
= 0 ||
{ echo "#rlog failed"; exit 1; }
453 test ! -f $lockfile ||
{ echo "#lock file not removed"; exit 1; }
455 rm -f a.
* $RCSfile $RCS_alt