File: driver-basic.sh

package info (click to toggle)
cssc 1.0.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,612 kB
  • ctags: 1,424
  • sloc: cpp: 13,502; sh: 4,759; ansic: 2,971; perl: 342; makefile: 339; awk: 11
file content (241 lines) | stat: -rw-r--r-- 5,842 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#! /bin/sh
# driver-basic.sh:  Testing for the basic operation of the BSD wrapper "sccs".
#                   We test each of the subcommands.

# Import common functions & definitions.
. ../common/test-common

# The test suite fails if you run it as root, particularly because
# "test -w foo" returns 0 if you are root, even if foo is a readonly
# file.
# So please don't run the test suite as root, because it will spuriously
# fail.
true 
. ../common/not-root



# If LANG is defined but the system is misconfigured, we will produce
# the error message "Error setting locale: No such file or directory".
# If that happens, the test suite will fail.  For this reason, we
# unset the LANG environment variable.  Of course, things being
# printed out in the wrong language would also mess up the results of
# the test suite.
# We want to prevent setlocale(LC_ALL, "") failing:
unset LANG

# We assume that all the files we want to work on are in the 
# current directory.
unset PROJECTDIR


remove command.log log log.stdout log.stderr SCCS
mkdir SCCS 2>/dev/null

g=tfile 
s=SCCS/s.${g} 
p=SCCS/p.${g} 
x=SCCS/x.${g} 
z=SCCS/z.${g}
remove $s $p $g $x $z

echo "Using the driver program ${sccs}"


# Create the input file.
cat > $g <<EOF
%M%: This is a test file containing nothing interesting.
EOF

#
# Creating the s-file. 
#
# Create the s-file the traditional way...
docommand a1 "${sccs} admin -i$g $s" 0 \
    ""                                              IGNORE
docommand a2 "test -f $s" 0 "" ""
remove $s

docommand a3 "${sccs} enter $g" 0 \
    "\n$g:\n"                                        IGNORE
docommand a4 "test -f $s"  0 "" ""

# Check the backup file still exists.
docommand a5 "test -f ,$g" 0 "" ""
remove ,$g

#
# Making deltas.
#

# First the traditional way.
docommand b1 "${sccs} get -e $s" 0 \
    "1.1\nnew delta 1.2\n1 lines\n"                 IGNORE

echo "hello" >>$g
docommand b2 "${sccs} delta -y\"\" $s" 0 \
    "1.2\n1 inserted\n0 deleted\n1 unchanged\n"     IGNORE


# Now with edit and delget.    
docommand b3 "${sccs} edit $s"  0 \
    "1.2\nnew delta 1.3\n2 lines\n"                 IGNORE


echo "there" >>$g
docommand b4 "${sccs} deledit -y'' $s" IGNORE \
 "1.3\n1 inserted\n0 deleted\n2 unchanged\n1.3\nnew delta 1.4\n" \
 IGNORE
# g-file should now exist and be writable.
docommand b5 "test -w $g" 0 "" ""


echo '%A%' >>$g
docommand b6 "${sccs} delget -y'' $s" 0 \
 "1.4\n1 inserted\n0 deleted\n3 unchanged\n1.4\n4 lines\n" \
 IGNORE
# g-file should now exist but not be writable.
docommand b7 "test -w $g" 1 "" ""
docommand b8 "test -f $g" 0 "" ""



#
# fix
#
docommand c1 "${sccs} fix -r1.4 $s" 0 \
 "1.4\n4 lines\n1.3\nnew delta 1.4\n" \
 IGNORE

docommand c2 "${sccs} tell" 0 "tfile\n" ""

docommand c3 "${sccs} delget -y'' $s" 0 \
 "1.4\n1 inserted\n0 deleted\n3 unchanged\n1.4\n4 lines\n" \
 IGNORE


#
# rmdel
#
# Make sure rmdel on its own works OK.
docommand d1 "${sccs} rmdel -r1.4 $s" 0 "" ""

# Make sure that revision is not still present.
docommand d2 "${sccs} get -p -r1.4 $s" 1 "" IGNORE

# Make sure that previous revision is still present.
docommand d3 "${sccs} get -p -r1.3 $s" 0 IGNORE "1.3\n3 lines\n"


#
# what
#
docommand e1 "${sccs} what $g" 0 "${g}:\n\t ${g} 1.4@(#)\n" ""


# 
# enter
# 
remove "foo" ",foo" "SCCS/s.foo"
echo "%Z%" >foo
docommand f1 "test -f ,foo" 1 "" ""
docommand f2 "${sccs} enter foo" 0 "\nfoo:\n" ""
docommand f3 "test -f ,foo" 0 "" ""
docommand f4 "test -f SCCS/s.foo" 0 "" ""
remove ",foo"

#
# clean
# 
docommand g1 "${sccs} edit SCCS/s.foo" 0 \
				    "1.1\nnew delta 1.2\n1 lines\n" ""

# Make sure foo and tfile exist but only foo is writable.
docommand g2 "test -f foo"   0 "" ""
docommand g3 "test -f tfile" 0 "" ""
docommand g4 "test -w foo"   0 "" ""
docommand g5 "test -w tfile" 1 "" ""
docommand g6 "${sccs} clean" 0 IGNORE ""
# Make sure tfile is now gone and foo is not.
docommand g7 "test -f tfile" 1 "" ""
docommand g8 "test -f foo"   0 "" ""
docommand g9 "test -w foo"   0 "" ""

#
# unedit 
#

case `uname -s 2>/dev/null` in
    CYGWIN*)
	echo Skipping test h1 under CYGWIN, see docs/Platforms for explanation
	echo "(we still perform step h1 because of its effects however)"
	docommand h1_cygwin "${sccs} unedit foo" 0 IGNORE ""
	;;
	*)
	docommand h1 "${sccs} unedit foo" 0 \
		"1.1\n1 lines\n         foo: removed\n" ""
		# That's 9 spaces.
	;;
esac


# the g-file should have been removed.
# actually we don't pass this test, see docs/BUGS.
# FIXME TODO
#docommand h2 "test -f foo" 1 IGNORE IGNORE

#
# info
#
docommand i1 "${sccs} info -b" 0 "Nothing being edited (on trunk)\n" ""
docommand i2 "${sccs} info"    0 "Nothing being edited\n" ""
remove SCCS/s.foo foo


#
# check
#
docommand j1 "${sccs} check" 0 "" ""
docommand j2 "${sccs} edit $s" 0 IGNORE IGNORE
docommand j3 "${sccs} check" 1 IGNORE ""
docommand j4 "${sccs} unedit $g" 0 IGNORE IGNORE



remove {expected,got}.std{out,err} last.command 
remove $s $p $g $x $z
success

#
# Still need to test:-

# cdc, comb, help, prs, prt, val, sccsdiff, diffs, -diff,
# branch, create

#
# Tests that would need a canned SCCS file:-
#
# print, info

	    
docommand B6 "${get} -e $s" 0 \
    "1.3\nnew delta 1.4\n2 lines\n"                 IGNORE
cp test/passwd.4 passwd
docommand B7 "${delta} -y'' $s" 0 \
    "1.4\n1 inserted\n1 deleted\n1 unchanged\n"     IGNORE
docommand B8 "${get} -e $s" 0 \
    "1.4\nnew delta 1.5\n2 lines\n"                 IGNORE
cp test/passwd.5 passwd
docommand B9 "${delta} -y'' $s" 0 \
    "1.5\n1 inserted\n1 deleted\n1 unchanged\n"     IGNORE
docommand B10 "${get} -e -r1.3 $s" 0 \
    "1.3\nnew delta 1.3.1.1\n2 lines\n"             IGNORE
cp test/passwd.6 passwd
docommand B11 "${delta} -y'' $s" 0 \
    "1.3.1.1\n1 inserted\n1 deleted\n1 unchanged\n" IGNORE

rm -rf test
remove passwd command.log $s $g $x $z $p SCCS
rm -rf SCCS
success