1#! /bin/sh 2# driver-basic.sh: Testing for the basic operation of the BSD wrapper "sccs". 3# We test each of the subcommands. 4 5# Import common functions & definitions. 6. ../../common/test-common 7 8# The test suite fails if you run it as root, particularly because 9# "test -w foo" returns 0 if you are root, even if foo is a readonly 10# file. We try to avoid this by calling the "wtest" function instead 11# of just "test". 12# Please don't run the test suite as root, because it may spuriously 13# fail. 14. ../../common/not-root 15 16setup() { 17 if test -f SCCS/s.driver-basic.sh 18 then 19 if test -d XSCCS 20 then 21 miscarry "Cannot rename SCCS to XSCCS, XSCCS exists" 22 else 23 mv SCCS XSCCS 24 fi 25 fi 26} 27 28restore() { 29 if test -f XSCCS/s.driver-basic.sh 30 then 31 if test -d SCCS 32 then 33 miscarry "Cannot rename XSCCS back to XSCCS, SCCS exists" 34 else 35 mv XSCCS SCCS 36 fi 37 fi 38} 39 40 41# If LANG is defined but the system is misconfigured, we will produce 42# the error message "Error setting locale: No such file or directory". 43# If that happens, the test suite will fail. For this reason, we 44# unset the LANG environment variable. Of course, things being 45# printed out in the wrong language would also mess up the results of 46# the test suite. 47# We want to prevent setlocale(LC_ALL, "") failing: 48unset LANG 49 50# We assume that all the files we want to work on are in the 51# current directory. 52unset PROJECTDIR 53 54 55setup 56remove command.log log log.stdout log.stderr SCCS 57mkdir SCCS 2>/dev/null 58 59g=tfile 60s=SCCS/s.${g} 61p=SCCS/p.${g} 62x=SCCS/x.${g} 63z=SCCS/z.${g} 64remove $s $p $g $x $z 65 66echo "Using the driver program ${sccs}" 67 68 69# Create the input file. 70cat > $g <<EOF 71%M%: This is a test file containing nothing interesting. 72EOF 73 74# 75# Creating the s-file. 76# 77# Create the s-file the traditional way... 78docommand a1 "${vg_sccs} admin -i$g $s" 0 \ 79 "" IGNORE 80docommand a2 "test -f $s" 0 "" "" 81remove $s 82 83docommand a3 "${vg_sccs} enter $g" 0 \ 84 "\n$g:\n" IGNORE 85docommand a4 "test -f $s" 0 "" "" 86 87# Check the backup file still exists. 88docommand a5 "test -f ,$g" 0 "" "" 89remove ,$g 90 91# 92# Making deltas. 93# 94 95# First the traditional way. 96docommand b1 "${vg_sccs} get -e $s" 0 \ 97 "1.1\nnew delta 1.2\n1 lines\n" IGNORE 98 99echo "hello" >>$g 100docommand b2 "${vg_sccs} delta -y\"\" $s" 0 \ 101 "1.2\n1 inserted\n0 deleted\n1 unchanged\n" IGNORE 102 103 104# Now with edit and delget. 105docommand b3 "${vg_sccs} edit $s" 0 \ 106 "1.2\nnew delta 1.3\n2 lines\n" IGNORE 107 108 109echo "there" >>$g 110docommand b4 "${vg_sccs} deledit -y'' $s" IGNORE \ 111 "1.3\n1 inserted\n0 deleted\n2 unchanged\n1.3\nnew delta 1.4\n" \ 112 IGNORE 113# g-file should now exist and be writable. 114#docommand b5 "test -w $g" 0 "" "" 115docommand b5 "wtest -w $g" 0 "" "" 116 117 118echo '%A%' >>$g 119docommand b6 "${vg_sccs} delget -y'' $s" 0 \ 120 "1.4\n1 inserted\n0 deleted\n3 unchanged\n1.4\n4 lines\n" \ 121 IGNORE 122# g-file should now exist but not be writable. 123#docommand b7 "test -w $g" 1 "" "" 124docommand b7 "wtest -w $g" 1 "" "" 125docommand b8 "test -f $g" 0 "" "" 126 127 128 129# 130# fix 131# 132docommand c1 "${vg_sccs} fix -r1.4 $s" 0 \ 133 "1.4\n4 lines\n1.3\nnew delta 1.4\n" \ 134 IGNORE 135 136docommand c2 "${vg_sccs} tell" 0 "tfile\n" "" 137 138docommand c3 "${vg_sccs} delget -y'' $s" 0 \ 139 "1.4\n1 inserted\n0 deleted\n3 unchanged\n1.4\n4 lines\n" \ 140 IGNORE 141 142 143# 144# rmdel 145# 146# Make sure rmdel on its own works OK. 147docommand d1 "${vg_sccs} rmdel -r1.4 $s" 0 "" "" 148 149# Make sure that revision is not still present. 150docommand d2 "${vg_sccs} get -p -r1.4 $s" 1 "" IGNORE 151 152# Make sure that previous revision is still present. 153docommand d3 "${vg_sccs} get -p -r1.3 $s" 0 IGNORE "1.3\n3 lines\n" 154 155 156# 157# what 158# 159docommand e1 "${vg_sccs} what $g" 0 "${g}:\n\t ${g} 1.4@(#)\n" "" 160 161 162# 163# enter 164# 165remove "foo" ",foo" "SCCS/s.foo" 166echo "%Z%" >foo 167docommand f1 "test -f ,foo" 1 "" "" 168docommand f2 "${vg_sccs} enter foo" 0 "\nfoo:\n" "" 169docommand f3 "test -f ,foo" 0 "" "" 170docommand f4 "test -f SCCS/s.foo" 0 "" "" 171remove ",foo" 172 173# 174# clean 175# 176docommand g1 "${vg_sccs} edit SCCS/s.foo" 0 \ 177 "1.1\nnew delta 1.2\n1 lines\n" "" 178 179# Make sure foo and tfile exist but only foo is writable. 180docommand g2 "test -f foo" 0 "" "" 181docommand g3 "test -f tfile" 0 "" "" 182#docommand g4 "test -w foo" 0 "" "" 183#docommand g5 "test -w tfile" 1 "" "" 184docommand g4 "wtest -w foo" 0 "" "" 185docommand g5 "wtest -w tfile" 1 "" "" 186docommand g6 "${vg_sccs} clean" 0 IGNORE "" 187# Make sure tfile is now gone and foo is not. 188docommand g7 "test -f tfile" 1 "" "" 189docommand g8 "test -f foo" 0 "" "" 190#docommand g9 "test -w foo" 0 "" "" 191docommand g9 "wtest -w foo" 0 "" "" 192 193# 194# unedit 195# 196 197case `uname -s 2>/dev/null` in 198 CYGWIN*) 199 echo Skipping test h1 under CYGWIN, see docs/Platforms for explanation 200 echo "(we still perform step h1 because of its effects however)" 201 docommand h1_cygwin "${vg_sccs} unedit foo" 0 IGNORE "" 202 ;; 203 *) 204 docommand h1 "${vg_sccs} unedit foo" 0 \ 205 " foo: removed\n1.1\n1 lines\n" "" 206 # That's 9 spaces. 207 ;; 208esac 209 210 211# the g-file should have been removed. 212# actually we don't pass this test, see docs/BUGS. 213# FIXME TODO 214#docommand h2 "test -f foo" 1 IGNORE IGNORE 215 216# 217# info 218# 219docommand i1 "${vg_sccs} info -b" 0 "Nothing being edited (on trunk)\n" "" 220docommand i2 "${vg_sccs} info" 0 "Nothing being edited\n" "" 221remove SCCS/s.foo foo 222 223 224# 225# check 226# 227docommand j1 "${vg_sccs} check" 0 "" "" 228docommand j2 "${vg_sccs} edit $s" 0 IGNORE IGNORE 229docommand j3 "${vg_sccs} check" 1 IGNORE "" 230docommand j4 "${vg_sccs} unedit $g" 0 IGNORE IGNORE 231 232 233 234remove {expected,got}.std{out,err} last.command 235remove $s $p $g $x $z 236rmdir SCCS 237restore 238success 239 240# 241# Still need to test:- 242 243# cdc, comb, help, prs, prt, val, sccsdiff, diffs, -diff, 244# branch, create 245 246# 247# Tests that would need a canned SCCS file:- 248# 249# print, info 250 251 252docommand B6 "${vg_get} -e $s" 0 \ 253 "1.3\nnew delta 1.4\n2 lines\n" IGNORE 254cp test/passwd.4 passwd 255docommand B7 "${vg_delta} -y'' $s" 0 \ 256 "1.4\n1 inserted\n1 deleted\n1 unchanged\n" IGNORE 257docommand B8 "${vg_get} -e $s" 0 \ 258 "1.4\nnew delta 1.5\n2 lines\n" IGNORE 259cp test/passwd.5 passwd 260docommand B9 "${vg_delta} -y'' $s" 0 \ 261 "1.5\n1 inserted\n1 deleted\n1 unchanged\n" IGNORE 262docommand B10 "${vg_get} -e -r1.3 $s" 0 \ 263 "1.3\nnew delta 1.3.1.1\n2 lines\n" IGNORE 264cp test/passwd.6 passwd 265docommand B11 "${vg_delta} -y'' $s" 0 \ 266 "1.3.1.1\n1 inserted\n1 deleted\n1 unchanged\n" IGNORE 267 268rm -rf test 269remove passwd command.log $s $g $x $z $p 270rmdir SCCS 271restore 272success 273