3 # Test RCS's functions.
4 # The RCS commands are searched for in the PATH as usual;
5 # to test the working directory's commands, prepend . to your PATH.
7 # Test RCS by creating files RCS/a.* and RCS/a.c.
8 # If all goes well, output nothing, and remove the temporary files.
9 # Otherwise, send a message to standard output.
10 # Exit status is 0 if OK, 1 if an RCS bug is found, and 2 if scaffolding fails.
11 # With the -v option, output more debugging info.
13 # If diff outputs `No differences encountered' when comparing identical files,
14 # then rcstest may also output these noise lines; ignore them.
16 # The current directory and ./RCS must be readable, writable, and searchable.
18 # $FreeBSD: src/gnu/usr.bin/rcs/rcstest,v 1.5 1999/08/27 23:36:37 peter Exp $
19 # $DragonFly: src/gnu/usr.bin/rcs/rcstest,v 1.2 2003/06/17 04:25:47 dillon Exp $
22 # Copyright 1990, 1991, 1992, 1993, 1994, 1995 Paul Eggert
23 # Distributed under license by the Free Software Foundation, Inc.
25 # This file is part of RCS.
27 # RCS is free software; you can redistribute it and/or modify
28 # it under the terms of the GNU General Public License as published by
29 # the Free Software Foundation; either version 2, or (at your option)
32 # RCS is distributed in the hope that it will be useful,
33 # but WITHOUT ANY WARRANTY; without even the implied warranty of
34 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 # GNU General Public License for more details.
37 # You should have received a copy of the GNU General Public License
38 # along with RCS; see the file COPYING.
39 # If not, write to the Free Software Foundation,
40 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 # Report problems and direct all questions to:
44 # rcs-bugs@cs.purdue.edu
46 # The Makefile overrides the following defaults.
47 : ${ALL_CFLAGS=-Dhas_conf_h}
50 # : ${LDFLAGS=} ${LIBS=} tickles old shell bug
52 CL
="$CC $ALL_CFLAGS $LDFLAGS -o a.out"
59 RCSfile
=RCS
${SLASH}a.c
60 RCS_alt
=RCS
${SLASH}a.d
61 lockfile
=RCS
${SLASH}a._
66 *) echo >&2 "$0: usage: $0 [-v]"; exit 2
71 else rmdir=rmdir; mkdir RCS ||
exit
74 rm -f a.
* $RCSfile $RCS_alt $lockfile &&
76 echo 1.1.1.1 >a
.3x1
&&
77 echo 1.2 >a
.12 ||
{ echo "#initialization failed"; exit 2; }
79 case "`$DIFF -c a.11 a.3x1`" in
83 echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic"
87 rcs
-i -L -ta.11 $q a.c
&&
89 echo "#rcs -i -L failed; perhaps RCS is not properly installed."
93 rlog a.c
>/dev
/null ||
{ echo "#rlog failed on empty RCS file"; exit 1; }
94 rm -f $RCSfile ||
exit 2
97 ci
-ta.11 -mm $q a.c
&&
99 rcs
-L $q a.c ||
{ echo "#ci+rcs -L failed"; exit 1; }
100 test ! -f a.c ||
{ echo "#ci did not remove working file"; exit 1; }
104 test -f a.c ||
{ echo '#co' $l did not create working
file; exit 1; }
105 $diff a
.11 a.c ||
{ echo '#ci' followed by co
$l is not a no-op
; exit 1; }
111 $diff a
.12 a.c ||
{ echo "#ci+co failed"; exit 1; }
115 $diff a
.11 a.c ||
{ echo "#can't retrieve first revision"; exit 1; }
119 ci
-r1.1
.1 -mm $q a.c
&&
120 co
-r1.1
.1.1 $q a.c
&&
121 $diff a
.3x1 a.c ||
{ echo "#branches failed"; exit 1; }
127 $diff a
.12 a.c ||
{ echo "#(co -l; ci -f) failed"; exit 1; }
134 ci
-mm $q a.c ||
{ echo "#ci -l failed"; exit 1; }
140 test -r a.c ||
{ echo "#ci -u didn't create a working file"; exit 1; }
142 echo error
>a.c ||
exit 2
143 ci
-mm $q a.c
2>/dev
/null
&& { echo "#ci -u didn't unlock the file"; exit 1; }
147 co
-u $q a.c ||
{ echo "#rcs -l + co -u failed"; exit 1; }
149 echo error
>a.c ||
exit 2
150 ci
-mm $q a.c
2>/dev
/null
&& { echo "#co -u didn't unlock the file"; exit 1; }
154 co
-f $q a.c ||
{ echo "#co -f failed"; exit 1; }
155 $diff a
.11 a.c
>/dev
/null
&& { echo "#co -f had no effect"; exit 1; }
157 co
-p1.1
$q a.c
>a.t
&&
158 $diff a
.11 a.t ||
{ echo "#co -p failed"; exit 1; }
166 ci
-${n}n
-mm $q a.c
&&
168 $diff a.
$n a.c ||
{ echo "#ci -$n failed"; exit 1; }
177 me
=`who am i` ||
exit 2
178 me
=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
180 '') echo >&2 "$0: cannot deduce user name"; exit 2
186 # Get the date of the previous revision in UTC.
187 date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` ||
exit
189 [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]);;
190 *) echo >&2 "$0: $date: bad rlog date output"; exit 1
192 PWD
=`pwd` && export PWD
&&
195 sed 's/@/$/g' >a.kv
<<EOF
198 @Header: $PWD$SLASH$RCSfile 2.1 $date w s @
199 @Id: a.c 2.1 $date w s @
202 * Revision 2.1 $date w
208 @Source: $PWD$SLASH$RCSfile @
212 sed 's/:.*\$/$/' a.kv
>a.k
&&
213 sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv
>a.kvl
&&
214 sed s
/Oz
//g a.kv
>a.e
&&
215 sed s
/Oz
/N
/g a.kv
>a.N
&&
216 sed -e '/\$/!d' -e 's/\$$/: old $/' a.k
>a.o
&&
217 sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv
>a.v
&&
219 ci
-d"$date" -nOz -ss -ww -u2.1
-mm $q a.c
&&
220 $diff a.kv a.c ||
{ echo "#keyword expansion failed"; exit 1; }
221 co
-pOz -ko $q a.c
>a.oo
&&
222 $diff a.o a.oo ||
{ echo "#co -p -ko failed"; exit 1; }
223 cp a.kv a.o
&& cp a.o a.b ||
exit 2
227 $diff a.kv a.c ||
{ echo "#ci -k failed"; exit 1; }
228 sed -n 's/^[^$]*\$/$/p' a.kv
>a.i
&&
230 sed -e 1d
-e 's/^[ ]*//' a.i1
>a.i2
&&
231 $diff a.i a.i2 ||
{ echo "#ident failed"; exit 1; }
233 rcs
-i $q a.c
2>/dev
/null
&& { echo "#rcs -i permitted existing file"; exit 1; }
240 rcs
-l1.1
.1 $q a.c
&&
241 ci
-r1.1
.1.2 -mm $q a.c
&&
242 rcs
-b1.1
.1 $q a.c
&&
243 test " `co -p $q a.c`" = ' 1.1.1.2' ||
{ echo "#rcs -b1.1.1 failed"; exit 1; }
245 test " `co -p $q a.c`" = ' 2.2' ||
{ echo "#rcs -b failed"; exit 1; }
247 echo 2.3 >a.c ||
exit 2
248 rcs
-U $q a.c ||
{ echo "#rcs -U failed"; exit 1; }
249 ci
-mm $q a.c ||
{ echo "#rcs -U didn't unset strict locking"; exit 1; }
250 rcs
-L $q a.c ||
{ echo "#rcs -L failed"; exit 1; }
251 echo error
>a.c ||
exit 2
252 ci
-mm $q a.c
2>/dev
/null
&& { echo "#ci retest failed"; exit 1; }
255 log0
=`rlog -h a.c` &&
258 log1
=`rlog -h a.c` &&
259 test " $log0" = " $log1" ||
{ echo "#unchanged ci didn't revert"; exit 1; }
262 rcs
-nN:1.1 $q a.c
&&
264 $diff a
.11 a.c ||
{ echo "#rcs -n failed"; exit 1; }
267 rcs
-NN:2.1 $q a.c
&&
269 $diff a.N a.c ||
{ echo "#rcs -N failed"; exit 1; }
273 echo ':::$''Log$' >a.c
&&
275 test " `sed '$!d' a.c`" = ' :::' ||
{ echo "#comment leader failed"; exit 1; }
280 $diff a.e a.c ||
{ echo "#rcs -o failed"; exit 1; }
282 rcsdiff
-r1.1
-rOz $q a.c
>a
.0
285 *) echo "#rcsdiff bad status"; exit 1
288 $diff a
.0 a
.1 ||
{ echo "#rcsdiff failed"; exit 1; }
290 rcs
-l2.1
$q a.c ||
{ echo "#rcs -l2.1 failed"; exit 1; }
291 for i
in b k kv kvl o v
295 rcsdiff
-k$i -rOz $q a.c ||
{ echo "#rcsdiff -k$i failed"; exit 1; }
297 co
-p1.1
-ko $q a.c
>a.t
&&
298 $diff a
.11 a.t ||
{ echo "#co -p1.1 -ko failed"; exit 1; }
299 rcs
-u2.1
$q a.c ||
{ echo "#rcs -u2.1 failed"; exit 1; }
303 rcsclean
-u $q a.c ||
{ echo "#rcsclean botched a nonexistent file"; exit 1; }
307 rcsclean
-n $q a.c
&&
308 rcsclean
-n -u $q a.c
&&
309 test -f a.c ||
{ echo "#rcsclean -n removed a file"; exit 1; }
314 test ! -f a.c ||
{ echo "#rcsclean missed an unlocked file"; exit 1; }
319 test -f a.c ||
{ echo "#rcsclean removed a locked file"; exit 1; }
320 rcsclean
-u $q a.c
&&
322 echo "#rcsclean -u missed an unchanged locked file"; exit 1;
329 rcsclean
$q -u a.c
&&
330 test -f a.c ||
{ echo "#rcsclean removed a changed file"; exit 1; }
343 co
-p2.2
$q a.c |
sed -e s
/2.2/2.3/ -e s
/b
/b
1/ >a.c
&&
345 co
-p2.2
$q a.c |
sed -e s
/2.2/new
/ -e s
/d
/d
1/ >a.c ||
exit 2
364 rcsmerge
-E -r2.2
-r2.3
$q a.c
367 if $diff a
.0 a.c
>/dev
/null
368 then echo "#warning: diff3 -E does not work, " \
369 "so merge and rcsmerge ignore overlaps and suppress overlap lines."
371 $diff a
.1 a.c ||
{ echo "#rcsmerge failed (status 0)"; exit 1; }
372 echo "#warning: The diff3 lib program exit status ignores overlaps," \
373 "so rcsmerge does not warn about overlap lines that it generates."
377 $diff a
.1 a.c ||
{ echo "#rcsmerge failed (status 1)"; exit 1; }
380 echo "#rcsmerge bad status"; exit 1
383 # Avoid `tr' if possible; it's not portable, and it can't handle null bytes.
384 # Our substitute exclusive-ORs with '\n';
385 # this ensures null bytes on output, which is even better than `tr',
386 # since some diffs think a file is binary only if it contains null bytes.
391 while ((c=getchar()) != EOF)
397 if (rm -f a.exe a.out
&& $CL a.c
$L >&2) >/dev
/null
2>&1
406 co
-p $q a.c |
$tr '\012' '\200' >a
.24 &&
408 ciOut
=`(ci -l -mm $q a.c 2>&1)` &&
410 ?
*) echo >&2 "$ciOut"
412 co
-p $q a.c |
$tr '\200' '\012' >a.c
&&
413 rcsdiff
-r2.3
$q a.c
>/dev
/null
&&
418 rcsdiff
-r2.4
$q a.c
>/dev
/null
419 } ||
echo "#warning: Traditional diff is used, so RCS is limited to text files."
421 rcs
-u -o2.4
: $q a.c ||
{ echo "#rcs -u -o failed"; exit 1; }
423 rcs
-i -Aa.c
-t- $q a.d ||
{ echo "#rcs -i -A failed"; exit 1; }
425 rlog
-r2.1 a.c
>a.t
&&
426 grep '^checked in with -k' a.t
>/dev
/null
&&
427 sed '/^checked in with -k/d' a.t
>a.u
&&
440 keyword substitution: kv
441 total revisions: 13; selected revisions: 1
444 ----------------------------
446 date: $date; author: w; state: s; lines: +14 -1
447 =============================================================================
449 test $?
= 0 ||
{ echo "#rlog failed"; exit 1; }
452 test ! -f $lockfile ||
{ echo "#lock file not removed"; exit 1; }
454 rm -f a.
* $RCSfile $RCS_alt