pmrep: update TODO, man page
[pcp.git] / qa / 223
blobf41d052074d448511eb20bcfaf0764b7c0a5bcbb
1 #! /bin/sh
2 # PCP QA Test No. 223
3 # Exercise the new pmns/Rebuild
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard filters
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 [ $PCP_PLATFORM = irix ] || _notrun "tests the IRIX Rebuild script"
18 _copy_Rebuild()
20 scr_src=$PCP_VAR_DIR/pmns/
21 cp $scr_src/Rebuild $1
22 if [ -f $scr_src/Xlate-irix-names ]
23 then
24 cp $scr_src/Xlate-irix-names $1
28 _filter ()
30 sed \
31 -e "s/\/$$/\/PID/g" \
32 -e 's/^\*\*\*.*[^*]$/*** old file/' \
33 -e 's/^---.*[^-]$/--- new file/'
36 _setup() {
37 PMNS_OLD=$tmp/old
38 PMNS_NEW=$tmp/new
39 export PMNS_OLD PMNS_NEW
40 rm -rf $PMNS_OLD $PMNS_NEW
41 mkdir -p $PMNS_NEW
42 mkdir -p $PMNS_OLD
43 echo >$PMNS_NEW/root 'root {
44 foo
46 foo {
47 one 0:0:1
51 _setup_wxy()
53 echo >$PMNS_NEW/root '
54 root {
55 extra
57 extra {
58 xxx
59 yyy
61 #include "xxx"
62 #include "yyy"'
64 echo >$PMNS_NEW/www.orphan '
65 extra.www {
66 two 0:0:2
69 echo >$PMNS_NEW/xxx '
70 extra.xxx {
71 two 0:0:3
74 echo '/* new */' >$PMNS_NEW/xxx.N
75 cat $PMNS_NEW/xxx >>$PMNS_NEW/xxx.N
77 echo >$PMNS_NEW/yyy '
78 extra.yyy {
79 two 0:0:4
82 echo '/* old */' >$PMNS_NEW/yyy.O
83 cat $PMNS_NEW/yyy >>$PMNS_NEW/yyy.O
86 _check()
88 echo "Exit status: $1"
89 type=unknown
90 [ -d $PMNS_OLD ] && type=directory
91 [ -f $PMNS_OLD ] && type=file
92 [ -L $PMNS_OLD ] && type=symlink
93 echo "PMNS_OLD pathname is: $type"
94 echo "PMNS_NEW contents:"
95 ls $PMNS_NEW
96 $DO_VALIDATE && _validate
99 _validate()
101 ( cd $PMNS_NEW; pmnscomp -f -n root root.bin )
102 echo "pminfo:"
103 pminfo -m -n $PMNS_NEW/root >$tmp.out 2>&1
104 status=$?
105 _filter <$tmp.out
106 if [ $status != 0 ]
107 then
108 for file in $PMNS_NEW/*
110 echo "=========================="
111 echo "new/`basename $file`"
112 echo "=========================="
113 cat $file
114 done
118 _remove_rebuild()
120 rm -f $1/Rebuild
121 if [ -f $1/Xlate-irix-names ]
122 then
123 rm -f $1/Xlate-irix-names
127 tmp=/tmp/$$
128 status=0
129 $sudo rm -f $tmp.* $seq.full
130 DO_VALIDATE=true
131 trap "cd $here; rm -rf $tmp $tmp.*; exit \$status" 0 1 2 3 15
133 # real QA test starts here
135 echo "=== PMNS_OLD does not exist ==="
136 _setup
137 rm -rf $PMNS_OLD
138 echo "=== PMNS_OLD does not exist ===" >>$seq.full
139 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
140 _copy_Rebuild $PMNS_NEW
141 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
142 chk=$?
143 _remove_rebuild $PMNS_NEW
144 _filter <$tmp.err
145 _check $chk
147 echo
148 echo "=== PMNS_OLD is empty ==="
149 _setup
150 echo "=== PMNS_OLD is empty ===" >>$seq.full
151 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
152 _copy_Rebuild $PMNS_NEW
153 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
154 chk=$?
155 _remove_rebuild $PMNS_NEW
156 _filter <$tmp.err
157 _check $chk
159 echo
160 echo "=== PMNS_OLD contains scripts that can safely be nuked ==="
161 _setup
162 touch $PMNS_OLD/Brand $PMNS_OLD/Makefile $PMNS_OLD/Rebuild
163 echo "=== PMNS_OLD contains scripts that can safely be nuked ===" >>$seq.full
164 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
165 _copy_Rebuild $PMNS_NEW
166 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
167 chk=$?
168 _remove_rebuild $PMNS_NEW
169 _filter <$tmp.err
170 _check $chk
172 echo
173 echo "=== PMNS_OLD contains files not in conflict with PMNS_NEW, copy them ==="
174 _setup
175 touch $PMNS_OLD/root.N $PMNS_OLD/urk $PMNS_OLD/urk.O
176 echo >$PMNS_OLD/xxx '
177 extra.xxx {
178 two 0:0:3
180 echo "=== PMNS_OLD contains files not in conflict with PMNS_NEW, copy them ===" >>$seq.full
181 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
182 _copy_Rebuild $PMNS_NEW
183 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
184 chk=$?
185 _remove_rebuild $PMNS_NEW
186 _filter <$tmp.err
187 _check $chk
189 echo
190 echo "=== files in PMNS_OLD and PMNS_NEW are identical ==="
191 _setup
192 _setup_wxy
193 rm $PMNS_NEW/www*
194 cp $PMNS_NEW/* $PMNS_OLD
195 echo "=== files in PMNS_OLD and PMNS_NEW are identical ===" >>$seq.full
196 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
197 _copy_Rebuild $PMNS_NEW
198 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
199 chk=$?
200 _remove_rebuild $PMNS_NEW
201 _filter <$tmp.err
202 _check $chk
204 echo
205 echo "=== salvage useful stuff from PMNS_OLD ==="
206 _setup
207 _setup_wxy
208 rm $PMNS_NEW/www*
209 mv $PMNS_NEW/xxx* $PMNS_OLD
210 DO_VALIDATE=false
211 _check N/A
212 DO_VALIDATE=true
213 echo "=== salvage useful stuff from PMNS_OLD ===" >>$seq.full
214 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
215 _copy_Rebuild $PMNS_NEW
216 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
217 chk=$?
218 _remove_rebuild $PMNS_NEW
219 _filter <$tmp.err
220 _check $chk
222 echo
223 echo "=== hard cases ==="
224 _setup
225 _setup_wxy
226 rm $PMNS_NEW/www*
227 sed -e 's/two/three/' <$PMNS_NEW/xxx.N >$PMNS_OLD/xxx
228 sed -e 's/two/three/' <$PMNS_NEW/yyy.O >$PMNS_OLD/yyy
229 _check N/A
230 echo "=== hard cases ===" >>$seq.full
231 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
232 _copy_Rebuild $PMNS_NEW
233 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
234 chk=$?
235 _remove_rebuild $PMNS_NEW
236 _filter <$tmp.err
237 _check $chk
239 echo
240 echo "=== PMNS_OLD is a file (error) ==="
241 _setup
242 rm -rf $PMNS_OLD
243 touch $PMNS_OLD
244 echo "=== PMNS_OLD is a file (error) ===" >>$seq.full
245 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
246 _copy_Rebuild $PMNS_NEW
247 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
248 chk=$?
249 _remove_rebuild $PMNS_NEW
250 _filter <$tmp.err
251 _check $chk
253 echo
254 echo "=== www.orphan, xxx.N and yyy.O in both places, waste the ones from PMNS_OLD ==="
255 _setup
256 _setup_wxy
257 touch $PMNS_OLD/www.orphan $PMNS_OLD/xxx.N $PMNS_OLD/yyy.O
258 _check N/A
259 echo "=== www.orphan, xxx.N and yyy.O in both places, waste the ones from PMNS_OLD ===" >>$seq.full
260 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
261 _copy_Rebuild $PMNS_NEW
262 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
263 chk=$?
264 _remove_rebuild $PMNS_NEW
265 _filter <$tmp.err
266 _check $chk
268 echo
269 echo "=== orphan (saveme) in PMNS_OLD ==="
270 _setup
271 touch $PMNS_OLD/saveme
272 echo "=== orphan (saveme) in PMNS_OLD ===" >>$seq.full
273 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
274 _copy_Rebuild $PMNS_NEW
275 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
276 chk=$?
277 _remove_rebuild $PMNS_NEW
278 _filter <$tmp.err
279 _check $chk
281 echo
282 echo "=== nested decls, a la DBMS PMDAS ==="
283 _setup
284 echo >$PMNS_NEW/root '
285 root {
286 extra
288 #include "extra"'
290 echo >$PMNS_NEW/extra '
291 extra {
295 #include "xxx"
296 #include "yyy"'
298 echo >$PMNS_NEW/xxx '
299 #define CLUST 1
300 #define ID xxx
301 extra.xxx {
302 #include "dummy"
303 #undef CLUST
304 #undef ID'
306 echo >$PMNS_NEW/yyy '
307 #define CLUST 2
308 #define ID yyy
309 extra.yyy {
310 #include "dummy"
311 #undef CLUST
312 #undef ID'
314 echo >$PMNS_NEW/dummy '
315 one 0:CLUST:1
316 special
319 extra.ID.special {
320 two 0:CLUST:2
321 three 0:CLUST:3
325 echo "=== nested decls, a la DBMS PMDAS ===" >>$seq.full
326 ls -lR $PMNS_OLD $PMNS_NEW >>$seq.full 2>&1
327 _copy_Rebuild $PMNS_NEW
328 $sudo "cd $PMNS_NEW; ./Rebuild -uv" >$tmp.err
329 chk=$?
330 _remove_rebuild $PMNS_NEW
331 _filter <$tmp.err
332 _check $chk
334 # all done
335 exit