b-make libg++-2.3.90
[unix-history] / gnu / usr.bin / rcs / rcstest
CommitLineData
8c4ebc23
JH
1#!/bin/sh
2
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.
6
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.
12
13# If diff outputs `No differences encountered' when comparing identical files,
14# then rcstest may also output these noise lines; ignore them.
15
16# The current directory and ./RCS must be readable, writable, and searchable.
17
18# $Id: rcstest,v 5.8 1991/11/20 17:58:10 eggert Exp $
19
20
21# Copyright 1990, 1991 by Paul Eggert
22# Distributed under license by the Free Software Foundation, Inc.
23#
24# This file is part of RCS.
25#
26# RCS is free software; you can redistribute it and/or modify
27# it under the terms of the GNU General Public License as published by
28# the Free Software Foundation; either version 2, or (at your option)
29# any later version.
30#
31# RCS is distributed in the hope that it will be useful,
32# but WITHOUT ANY WARRANTY; without even the implied warranty of
33# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34# GNU General Public License for more details.
35#
36# You should have received a copy of the GNU General Public License
37# along with RCS; see the file COPYING. If not, write to
38# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
39#
40# Report problems and direct all questions to:
41#
42# rcs-bugs@cs.purdue.edu
43
44RCSINIT=-x
45export RCSINIT
46
47SLASH=/
48RCSfile=RCS${SLASH}a.c
49RCS_alt=RCS${SLASH}a.d
50lockfile=RCS${SLASH}a._
51
52case $1 in
53-v) q=; set -x;;
54'') q=-q;;
55*) echo >&2 "$0: usage: $0 [-v]"; exit 2
56esac
57
58test -d RCS || {
59 echo >&2 "$0: RCS: not a directory; please \`mkdir RCS' first."
60 exit 1
61}
62
63rm -f a.* $RCSfile $RCS_alt $lockfile &&
64echo 1.1 >a.11 &&
65echo 1.1.1.1 >a.3x1 &&
66echo 1.2 >a.12 || { echo "#initialization failed"; exit 2; }
67
68case `diff -c a.11 a.3x1` in
69*'! 1.1.1.1')
70 diff='diff -c';;
71*)
72 echo "#warning: diff -c does not work, so diagnostics may be cryptic"
73 diff=diff
74esac
75
76rcs -i -L -ta.11 $q a.c &&
77<$RCSfile || {
78 echo "#rcs -i -L failed; perhaps RCS is not properly installed."
79 exit 1
80}
81
82rlog a.c >/dev/null || { echo "#rlog failed on empty RCS file"; exit 1; }
83rm -f $RCSfile || exit 2
84
85cp a.11 a.c &&
86ci -ta.11 -mm $q a.c &&
87<$RCSfile &&
88rcs -L $q a.c || { echo "#ci+rcs -L failed"; exit 1; }
89test ! -f a.c || { echo "#ci did not remove working file"; exit 1; }
90for l in '' '-l'
91do
92 co $l $q a.c &&
93 test -f a.c || { echo '#co' $l did not create working file; exit 1; }
94 $diff a.11 a.c || { echo '#ci' followed by co $l is not a no-op; exit 1; }
95done
96
97cp a.12 a.c &&
98ci -mm $q a.c &&
99co $q a.c &&
100$diff a.12 a.c || { echo "#ci+co failed"; exit 1; }
101
102co -r1.1 $q a.c &&
103$diff a.11 a.c || { echo "#can't retrieve first revision"; exit 1; }
104
105rm -f a.c &&
106cp a.3x1 a.c &&
107ci -r1.1.1 -mm $q a.c &&
108co -r1.1.1.1 $q a.c &&
109$diff a.3x1 a.c || { echo "#branches failed"; exit 1; }
110
111co -l $q a.c &&
112ci -f -mm $q a.c &&
113co -r1.3 $q a.c &&
114$diff a.12 a.c || { echo "#(co -l; ci -f) failed"; exit 1; }
115
116co -l $q a.c &&
117echo 1.4 >a.c &&
118ci -l -mm $q a.c &&
119echo error >a.c &&
120ci -mm $q a.c || { echo "#ci -l failed"; exit 1; }
121
122co -l $q a.c &&
123echo 1.5 >a.c &&
124ci -u -mm $q a.c &&
125<a.c || { echo "#ci -u didn't create a working file"; exit 1; }
126rm -f a.c &&
127echo error >a.c || exit 2
128ci -mm $q a.c 2>/dev/null && { echo "#ci -u didn't unlock the file"; exit 1; }
129
130rm -f a.c &&
131rcs -l $q a.c &&
132co -u $q a.c || { echo "#rcs -l + co -u failed"; exit 1; }
133rm -f a.c &&
134echo error >a.c || exit 2
135ci -mm $q a.c 2>/dev/null && { echo "#co -u didn't unlock the file"; exit 1; }
136
137rm -f a.c &&
138cp a.11 a.c &&
139co -f $q a.c || { echo "#co -f failed"; exit 1; }
140$diff a.11 a.c >/dev/null && { echo "#co -f had no effect"; exit 1; }
141
142co -p1.1 $q a.c >a.t &&
143$diff a.11 a.t || { echo "#co -p failed"; exit 1; }
144
145for n in n N
146do
147 rm -f a.c &&
148 co -l $q a.c &&
149 echo $n >a.$n &&
150 cp a.$n a.c &&
151 ci -${n}n -mm $q a.c &&
152 co -rn $q a.c &&
153 $diff a.$n a.c || { echo "#ci -$n failed"; exit 1; }
154done
155
156case $LOGNAME in
157?*) me=$LOGNAME;;
158*)
159 case $USER in
160 ?*) me=$USER;;
161 *)
162 me=`who am i` || exit 2
163 me=`echo "$me" | sed -e 's/ .*//' -e 's/.*!//'`
164 case $me in
165 '') echo >&2 "$0: cannot deduce user name"; exit 2
166 esac
167 esac
168esac
169date=`date -u 2>/dev/null` ||
170date=`TZ=GMT0 date 2>/dev/null` ||
171date=`TZ= date` || exit 2
172set $date
173case $2 in
174Jan) m=01;; Feb) m=02;; Mar) m=03;; Apr) m=04;; May) m=05;; Jun) m=06;;
175Jul) m=07;; Aug) m=08;; Sep) m=09;; Oct) m=10;; Nov) m=11;; Dec) m=12;;
176*) echo >&2 "$0: $2: unknown month name"; exit 2
177esac
178case $3 in
179?) d=0$3;;
180*) d=$3
181esac
182case $6 in
183[0-9][0-9][0-9][0-9]*) D=$6/$m/$d;;
184*)
185 case $5 in
186 [0-9][0-9][0-9][0-9]*) D=$5/$m/$d;;
187 *) echo >&2 "$0: bad date format: $date"; exit 2
188 esac
189esac
190T=$4
191case $PWD in
192'') PWD=`pwd`
193esac &&
194co -l $q a.c &&
195sed 's/@/$/g' >a.kv <<EOF
196@Author: w @
197@Date: $D $T @
198@Header: $PWD$SLASH$RCSfile 2.1 $D $T w s @
199@Id: a.c 2.1 $D $T w s @
200@Locker: @
201@Log: a.c @
202 * Revision 2.1 $D $T w
203 * m
204 *
205@RCSfile: a.c @
206@Revision: 2.1 @
207@Source: $PWD$SLASH$RCSfile @
208@State: s @
209EOF
210test $? = 0 &&
211sed 's/:.*\$/$/' a.kv >a.k &&
212sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl &&
213sed -e '/^\$/!d' -e 's/\$$/: old $/' a.k >a.o &&
214sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v &&
215cp a.o a.c &&
216ci -d"$date" -ss -ww -u2.1 -mm $q a.c &&
217$diff a.kv a.c || { echo "#keyword expansion failed"; exit 1; }
218co -p -ko $q a.c >a.oo &&
219$diff a.o a.oo || { echo "#co -p -ko failed"; exit 1; }
220cp a.kv a.o || exit 2
221rcs -o2.1 $q a.c &&
222rcs -l $q a.c &&
223ci -k -u $q a.c &&
224$diff a.kv a.c || { echo "#ci -k failed"; exit 1; }
225sed '/^[^$]/d' a.kv >a.i &&
226ident a.c >a.i1 &&
227sed -e 1d -e 's/^[ ]*//' a.i1 >a.i2 &&
228$diff a.i a.i2 || { echo "#ident failed"; exit 1; }
229
230rcs -i $q a.c 2>/dev/null && { echo "#rcs -i permitted existing file"; exit 1; }
231
232co -l $q a.c &&
233echo 2.2 >a.c &&
234ci -mm $q a.c &&
235echo 1.1.1.2 >a.c &&
236rcs -l1.1.1 $q a.c &&
237ci -r1.1.1.2 -mm $q a.c &&
238rcs -b1.1.1 $q a.c &&
239test " `co -p $q a.c`" = ' 1.1.1.2' || { echo "#rcs -b1.1.1 failed"; exit 1; }
240rcs -b $q a.c &&
241test " `co -p $q a.c`" = ' 2.2' || { echo "#rcs -b failed"; exit 1; }
242
243echo 2.3 >a.c || exit 2
244rcs -U $q a.c || { echo "#rcs -U failed"; exit 1; }
245ci -mm $q a.c || { echo "#rcs -U didn't unset strict locking"; exit 1; }
246rcs -L $q a.c || { echo "#rcs -L failed"; exit 1; }
247echo error >a.c || exit 2
248ci -mm $q a.c 2>/dev/null && { echo "#ci retest failed"; exit 1; }
249
250rm -f a.c &&
251log0=`rlog -h a.c` &&
252co -l $q a.c &&
253ci -mm $q a.c &&
254log1=`rlog -h a.c` &&
255test " $log0" = " $log1" || { echo "#unchanged ci didn't revert"; exit 1; }
256
257rm -f a.c &&
258rcs -nN:1.1 $q a.c &&
259co -rN $q a.c &&
260$diff a.11 a.c || { echo "#rcs -n failed"; exit 1; }
261
262rcs -NN:2.1 $q a.c &&
263co -rN $q a.c &&
264$diff a.kv a.c || { echo "#rcs -N failed"; exit 1; }
265
266co -l $q a.c &&
267rcs -c':::' $q a.c &&
268echo '$''Log$' >a.c &&
269ci -u -mm $q a.c &&
270test " `sed '$!d' a.c`" = ' :::' || { echo "#rcs -c failed"; exit 1; }
271
272rcs -o2.2: $q a.c &&
273co $q a.c &&
274$diff a.kv a.c || { echo "#rcs -o failed"; exit 1; }
275
276rcsdiff -r1.1 -r2.1 $q a.c >a.0
277case $? in
2781) ;;
279*) echo "#rcsdiff bad status"; exit 1
280esac
281diff a.11 a.kv >a.1
282$diff a.0 a.1 || { echo "#rcsdiff failed"; exit 1; }
283
284rcs -l2.1 $q a.c || { echo "#rcs -l2.1 failed"; exit 1; }
285for i in k kv kvl o v
286do
287 rm -f a.c &&
288 cp a.$i a.c &&
289 rcsdiff -k$i $q a.c || { echo "#rcsdiff -k$i failed"; exit 1; }
290done
291co -p1.1 -ko $q a.c >a.t &&
292$diff a.11 a.t || { echo "#co -p1.1 -ko failed"; exit 1; }
293rcs -u2.1 $q a.c || { echo "#rcs -u2.1 failed"; exit 1; }
294
295rm -f a.c &&
296co -l $q a.c &&
297cat >a.c <<'EOF'
2982.2
299a
300b
301c
302d
303EOF
304test $? = 0 &&
305ci -l -mm $q a.c &&
306co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
307ci -l -mm $q a.c &&
308co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
309cat >a.0 <<'EOF'
3102.3
311a
312b1
313c
314d1
315EOF
316cat >a.1 <<'EOF'
317<<<<<<< a.c
318new
319=======
3202.3
321>>>>>>> 2.3
322a
323b1
324c
325d1
326EOF
327rcsmerge -r2.2 -r2.3 $q a.c
328case $? in
3290)
330 if $diff a.0 a.c >/dev/null
331 then echo "#warning: diff3 -E does not work, " \
332 "so merge and rcsmerge ignore overlaps and suppress overlap lines."
333 else
334 $diff a.1 a.c || { echo "#rcsmerge failed (status 0)"; exit 1; }
335 echo "#warning: The diff3 lib program exit status ignores overlaps," \
336 "so rcsmerge does not warn about overlap lines that it generates."
337 fi
338 ;;
3391)
340 $diff a.1 a.c || { echo "#rcsmerge failed (status 1)"; exit 1; }
341 ;;
342*)
343 echo "#rcsmerge bad status"; exit 1
344esac
345
346nl='
347'
348{
349 co -p $q a.c | tr "$nl" '\200' >a.24 &&
350 cp a.24 a.c &&
351 ciOut=`(ci -l -mm $q a.c 2>&1)` &&
352 case $ciOut in
353 ?*) echo >&2 "$ciOut"
354 esac &&
355 co -p $q a.c | tr '\200' "$nl" >a.c &&
356 rcsdiff -r2.3 $q a.c >/dev/null &&
357
358 echo 2.5 >a.c &&
359 ci -l -mm $q a.c &&
360 cp a.24 a.c &&
361 rcsdiff -r2.4 $q a.c >/dev/null
362} || echo "#warning: Traditional diff is used, so RCS is limited to text files."
363
364rcs -u -o2.4: $q a.c || { echo "#rcs -u -o failed"; exit 1; }
365
366rcs -i -Aa.c -t- $q a.d || { echo "#rcs -i -A failed"; exit 1; }
367
368rlog -r2.1 a.c >a.t &&
369grep '^checked in with -k' a.t >/dev/null &&
370sed '/^checked in with -k/d' a.t >a.u &&
371$diff - a.u <<EOF
372
373RCS file: $RCSfile
374Working file: a.c
375head: 2.3
376branch:
377locks: strict
378access list:
379symbolic names:
380 N: 2.1
381 n: 1.8
382comment leader: ":::"
383keyword substitution: kv
384total revisions: 13; selected revisions: 1
385description:
3861.1
387----------------------------
388revision 2.1
389date: $D $T; author: w; state: s; lines: +13 -1
390=============================================================================
391EOF
392test $? = 0 || { echo "#rlog failed"; exit 1; }
393
394
395test ! -f $lockfile || { echo "#lock file not removed"; exit 1; }
396
397exec rm -f a.* $RCSfile $RCS_alt