Explicitly request literal mode after .Xr.
[netbsd-mini2440.git] / gnu / usr.bin / rcs / rcstest
blobfda4a3949cfa1468767b2cb3e98d00bb79779534
1 #! /bin/sh
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)
31 # any later version.
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}
49 : ${CC=cc}
50 : ${DIFF=diff}
51 # : ${LDFLAGS=} ${LIBS=} tickles old shell bug
53 CL="$CC $ALL_CFLAGS $LDFLAGS -o a.out"
54 L=$LIBS
56 RCSINIT=-x
57 export RCSINIT
59 SLASH=/
60 RCSfile=RCS${SLASH}a.c
61 RCS_alt=RCS${SLASH}a.d
62 lockfile=RCS${SLASH}a._
64 case $1 in
65 -v) q=; set -x;;
66 '') q=-q;;
67 *) echo >&2 "$0: usage: $0 [-v]"; exit 2
68 esac
70 if test -d RCS
71 then rmdir=:
72 else rmdir=rmdir; mkdir RCS || exit
75 rm -f a.* $RCSfile $RCS_alt $lockfile &&
76 echo 1.1 >a.11 &&
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
81 *!\ 1.1.1.1)
82 diff="$DIFF -c";;
84 echo "#warning: $DIFF -c does not work, so diagnostics may be cryptic"
85 diff=$DIFF
86 esac
88 rcs -i -L -ta.11 $q a.c &&
89 test -r $RCSfile || {
90 echo "#rcs -i -L failed; perhaps RCS is not properly installed."
91 exit 1
94 rlog a.c >/dev/null || { echo "#rlog failed on empty RCS file"; exit 1; }
95 rm -f $RCSfile || exit 2
97 cp a.11 a.c &&
98 ci -ta.11 -mm $q a.c &&
99 test -r $RCSfile &&
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; }
102 for l in '' '-l'
104 co $l $q a.c &&
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; }
107 done
109 cp a.12 a.c &&
110 ci -mm $q a.c &&
111 co $q a.c &&
112 $diff a.12 a.c || { echo "#ci+co failed"; exit 1; }
114 rm -f a.c &&
115 co -r1.1 $q a.c &&
116 $diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; }
118 rm -f a.c &&
119 cp a.3x1 a.c &&
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; }
124 rm -f a.c &&
125 co -l $q a.c &&
126 ci -f -mm $q a.c &&
127 co -r1.3 $q a.c &&
128 $diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; }
130 rm -f a.c &&
131 co -l $q a.c &&
132 echo 1.4 >a.c &&
133 ci -l -mm $q a.c &&
134 echo error >a.c &&
135 ci -mm $q a.c || { echo "#ci -l failed"; exit 1; }
137 rm -f a.c &&
138 co -l $q a.c &&
139 echo 1.5 >a.c &&
140 ci -u -mm $q a.c &&
141 test -r a.c || { echo "#ci -u didn't create a working file"; exit 1; }
142 rm -f a.c &&
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; }
146 rm -f a.c &&
147 rcs -l $q a.c &&
148 co -u $q a.c || { echo "#rcs -l + co -u failed"; exit 1; }
149 rm -f a.c &&
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; }
153 rm -f a.c &&
154 cp a.11 a.c &&
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; }
161 for n in n N
163 rm -f a.c &&
164 co -l $q a.c &&
165 echo $n >a.$n &&
166 cp a.$n a.c &&
167 ci -${n}n -mm $q a.c &&
168 co -rn $q a.c &&
169 $diff a.$n a.c || { echo "#ci -$n failed"; exit 1; }
170 done
172 case $LOGNAME in
173 ?*) me=$LOGNAME;;
175 case $USER in
176 ?*) me=$USER;;
178 me=`who am i` || exit 2
179 me=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
180 case $me in
181 '') echo >&2 "$0: cannot deduce user name"; exit 2
182 esac
183 esac
184 esac
187 # Get the date of the previous revision in UTC.
188 date=`rlog -r a.c | sed -n '/^date: /{ s///; s/;.*//; p; q; }'` || exit
189 case $date in
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
192 esac
193 PWD=`pwd` && export PWD &&
194 rm -f a.c &&
195 co -l $q a.c &&
196 sed 's/@/$/g' >a.kv <<EOF
197 @Author: w @
198 @Date: $date @
199 @Header: $PWD$SLASH$RCSfile 2.1 $date w s @
200 @Id: a.c 2.1 $date w s @
201 @Locker: @
202 * @Log: a.c @
203 * Revision 2.1 $date w
206 @Name: Oz @
207 @RCSfile: a.c @
208 @Revision: 2.1 @
209 @Source: $PWD$SLASH$RCSfile @
210 @State: s @
212 test $? = 0 &&
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 &&
219 cp a.o a.c &&
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
225 rcs -oOz $q a.c &&
226 rcs -l $q a.c &&
227 ci -k -u $q a.c &&
228 $diff a.kv a.c || { echo "#ci -k failed"; exit 1; }
229 sed -n 's/^[^$]*\$/$/p' a.kv >a.i &&
230 ident a.c >a.i1 &&
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; }
236 rm -f a.c &&
237 co -l $q a.c &&
238 echo 2.2 >a.c &&
239 ci -mm $q a.c &&
240 echo 1.1.1.2 >a.c &&
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; }
245 rcs -b $q a.c &&
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; }
255 rm -f a.c &&
256 log0=`rlog -h a.c` &&
257 co -l $q a.c &&
258 ci -mm $q a.c &&
259 log1=`rlog -h a.c` &&
260 test " $log0" = " $log1" || { echo "#unchanged ci didn't revert"; exit 1; }
262 rm -f a.c &&
263 rcs -nN:1.1 $q a.c &&
264 co -rN $q a.c &&
265 $diff a.11 a.c || { echo "#rcs -n failed"; exit 1; }
267 rm -f a.c &&
268 rcs -NN:2.1 $q a.c &&
269 co -rN $q a.c &&
270 $diff a.N a.c || { echo "#rcs -N failed"; exit 1; }
272 rm -f a.c &&
273 co -l $q a.c &&
274 echo ':::$''Log$' >a.c &&
275 ci -u -mm $q a.c &&
276 test " `sed '$!d' a.c`" = ' :::' || { echo "#comment leader failed"; exit 1; }
278 rm -f a.c &&
279 rcs -o2.2: $q a.c &&
280 co $q a.c &&
281 $diff a.e a.c || { echo "#rcs -o failed"; exit 1; }
283 rcsdiff -r1.1 -rOz $q a.c >a.0
284 case $? in
285 1) ;;
286 *) echo "#rcsdiff bad status"; exit 1
287 esac
288 $DIFF a.11 a.kv >a.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
294 rm -f a.c &&
295 cp a.$i a.c &&
296 rcsdiff -k$i -rOz $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; }
297 done
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; }
302 rm -f a.c &&
303 rcsclean $q a.c &&
304 rcsclean -u $q a.c || { echo "#rcsclean botched a nonexistent file"; exit 1; }
306 rm -f a.c &&
307 co $q a.c &&
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; }
312 rm -f a.c &&
313 co $q a.c &&
314 rcsclean $q a.c &&
315 test ! -f a.c || { echo "#rcsclean missed an unlocked file"; exit 1; }
317 rm -f a.c &&
318 co -l $q a.c &&
319 rcsclean $q a.c &&
320 test -f a.c || { echo "#rcsclean removed a locked file"; exit 1; }
321 rcsclean -u $q a.c &&
322 test ! -f a.c || {
323 echo "#rcsclean -u missed an unchanged locked file"; exit 1;
326 rm -f a.c &&
327 co -l $q a.c &&
328 echo change >>a.c &&
329 rcsclean $q a.c &&
330 rcsclean $q -u a.c &&
331 test -f a.c || { echo "#rcsclean removed a changed file"; exit 1; }
333 rm -f a.c &&
334 co -l $q a.c &&
335 cat >a.c <<'EOF'
342 test $? = 0 &&
343 ci -l -mm $q a.c &&
344 co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
345 ci -l -mm $q a.c &&
346 co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
347 cat >a.0 <<'EOF'
354 cat >a.1 <<'EOF'
355 <<<<<<< a.c
357 =======
359 >>>>>>> 2.3
365 rcsmerge -E -r2.2 -r2.3 $q a.c
366 case $? in
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."
371 else
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
382 esac
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.
388 cat >a.c <<'EOF'
389 #include <stdio.h>
390 int main() {
391 int c;
392 while ((c=getchar()) != EOF)
393 putchar(c ^ '\n');
394 return 0;
397 tr=tr
398 if (rm -f a.exe a.out && $CL a.c $L >&2) >/dev/null 2>&1
399 then
400 if test -s a.out
401 then tr=./a.out
402 elif test -s a.exe
403 then tr=./a.exe
407 co -p $q a.c | $tr '\012' '\200' >a.24 &&
408 cp a.24 a.c &&
409 ciOut=`(ci -l -mm $q a.c 2>&1)` &&
410 case $ciOut in
411 ?*) echo >&2 "$ciOut"
412 esac &&
413 co -p $q a.c | $tr '\200' '\012' >a.c &&
414 rcsdiff -r2.3 $q a.c >/dev/null &&
416 echo 2.5 >a.c &&
417 ci -l -mm $q a.c &&
418 cp a.24 a.c &&
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 &&
429 $diff - a.u <<EOF
431 RCS file: $RCSfile
432 Working file: a.c
433 head: 2.3
434 branch:
435 locks: strict
436 access list:
437 symbolic names:
438 N: 2.1
439 Oz: 2.1
440 n: 1.8
441 keyword substitution: kv
442 total revisions: 13; selected revisions: 1
443 description:
445 ----------------------------
446 revision 2.1
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
456 $rmdir RCS