pmrep: update TODO, man page
[pcp.git] / qa / 738
blob943813f86546ea8b0d68286f43b955808496c8c0
1 #!/bin/sh
2 # PCP QA Test No. 738
3 # Exercise pmlogmv
5 # Copyright (c) 2014 Ken McDonell. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 status=1 # failure is the default!
17 $sudo rm -rf $tmp.* $seq.full
18 mkdir $tmp
19 cd $tmp
20 trap "cd $here; rm -rf $tmp.* $tmp; exit \$status" 0 1 2 3 15
22 _filter()
24 # there are a lot of bizarre quoting variants for ln(1) error
25 # messages!
26 sed \
27 -e '/^[rwx.-]* /s/.* /... ls data ... /' \
28 -e 's/`'"/'/g" \
29 -e 's/‘'"/'/g" \
30 -e 's/’'"/'/g" \
31 -e 's/ln: creating hard link/ln: failed to create hard link/' \
32 -e "/ln: failed /s/' to '/' => '/" \
33 | _filter_ls
36 # ls(1) does not have the same format for error messages, sigh.
37 _filter_ls()
39 sed -e '/ls: [^ ]*\*: No such/s/ls: /ls: cannot access /'
42 # real QA test starts here
45 echo "=== Usage, no input files, incomplete input archive ==="
46 pmlogmv
47 sts=$?
48 [ $sts -eq 0 ] || echo exit status $sts
49 pmlogmv foo
50 sts=$?
51 [ $sts -eq 0 ] || echo exit status $sts
52 pmlogmv foo bar
53 sts=$?
54 [ $sts -eq 0 ] || echo exit status $sts
55 cp $here/tmparch/foo.0 .
56 pmlogmv foo bar >$tmp.out 2>&1
57 sts=$?
58 _filter <$tmp.out
59 [ $sts -eq 0 ] || echo exit status $sts
60 rm foo.0
61 cp $here/tmparch/foo.meta .
62 pmlogmv foo bar >$tmp.out 2>&1
63 sts=$?
64 _filter <$tmp.out
65 [ $sts -eq 0 ] || echo exit status $sts
66 rm -f foo.* bar.*
68 echo
69 echo "=== non-pcp archives and output files already exist ==="
70 cp $here/tmparch/foo.* .
71 touch foo.frog
72 pmlogmv -V foo bar >$tmp.out 2>&1
73 sts=$?
74 _filter <$tmp.out
75 [ $sts -eq 0 ] || echo exit status $sts
76 ls foo* bar* 2>&1 | _filter_ls
77 rm -f foo.* bar.*
78 cp $here/tmparch/foo.* .
79 for i in 0 index meta
81 echo "--- bar.$i already exists ---"
82 cp $here/tmparch/bar.$i .
83 pmlogmv -V foo bar >$tmp.out 2>&1
84 sts=$?
85 _filter <$tmp.out
86 [ $sts -eq 0 ] || echo exit status $sts
87 ls foo* bar* 2>&1 | _filter_ls
88 rm bar.$i
89 done
90 rm -f foo.* bar.*
92 echo
93 echo "=== simplest case ==="
94 cp $here/tmparch/foo.* .
95 pmlogmv -NV foo bar >$tmp.out 2>&1
96 sts=$?
97 _filter <$tmp.out
98 [ $sts -eq 0 ] || echo exit status $sts
99 pmlogmv -V foo bar >$tmp.out 2>&1
100 sts=$?
101 _filter <$tmp.out
102 [ $sts -eq 0 ] || echo exit status $sts
103 for part in 0 index meta
105 if cmp $here/tmparch/foo.$part bar.$part
106 then
108 else
109 echo "Arrgh ... input foo.$part not the same as output bar.$part"
110 ls -l $here/tmparch/foo.$part bar.$part
112 done
113 ls foo* bar* 2>&1 | _filter_ls
114 rm -f foo.* bar.*
116 echo
117 echo "=== single oldfile name cases ==="
118 for ext in meta 0 index
120 echo "--- foo.$ext ---"
121 cp $here/tmparch/foo.* .
122 pmlogmv -V foo.$ext bar >$tmp.out 2>&1
123 sts=$?
124 _filter <$tmp.out
125 [ $sts -eq 0 ] || echo exit status $sts
126 for part in 0 index meta
128 if cmp $here/tmparch/foo.$part bar.$part
129 then
131 else
132 echo "Arrgh ... input foo.$part not the same as output bar.$part"
133 ls -l $here/tmparch/foo.$part bar.$part
135 done
136 ls foo* bar* 2>&1 | _filter_ls
137 rm -f foo.* bar.*
138 done
140 echo
141 echo "=== multi-volume case ==="
142 cp $here/tmparch/mv-foo.* .
143 cp mv-foo.2 mv-foo.123456789
144 pmlogmv -V mv-foo bar >$tmp.out 2>&1
145 sts=$?
146 _filter <$tmp.out
147 [ $sts -eq 0 ] || echo exit status $sts
148 for opart in 0 1 2 123456789 index meta
150 npart=$opart
151 [ "$opart" = 123456789 ] && opart=2
152 if cmp $here/tmparch/mv-foo.$opart bar.$npart
153 then
155 else
156 echo "Arrgh ... input mv-foo.$opart not the same as output bar.$npart"
157 ls -l $here/tmparch/mv-foo.$opart bar.$npart
159 done
160 ls foo* bar* 2>&1 | _filter_ls
161 rm -f foo.* bar.*
163 echo
164 echo "=== old and new in different directories =="
165 mkdir new
166 cp $here/tmparch/mv-foo.* .
167 pmlogmv -V mv-foo new/mv-foo >$tmp.out 2>&1
168 sts=$?
169 _filter <$tmp.out
170 [ $sts -eq 0 ] || echo exit status $sts
171 for part in 0 1 2 index meta
173 if cmp $here/tmparch/mv-foo.$part new/mv-foo.$part
174 then
176 else
177 echo "Arrgh ... input mv-foo.$part not the same as output new/mv-foo.$part"
178 ls -l $here/tmparch/mv-foo.$part new/mv-foo.$part
180 done
181 ls foo* new/* 2>&1 | _filter_ls
182 rm -rf foo.* new
184 echo
185 echo "=== error case for ln failing ==="
186 mkdir new
187 chmod u-w,g-w,o-w new
188 cp $here/tmparch/mv-foo.* .
189 pmlogmv -V mv-foo new/mv-foo >$tmp.out 2>&1
190 sts=$?
191 _filter <$tmp.out
192 [ $sts -eq 0 ] || echo exit status $sts
193 ls mv-foo* new/* 2>&1 | _filter_ls
194 rm -rf foo.* new
196 echo
197 echo "=== error case for rm failing ==="
198 mkdir new
199 chmod u-w,g-w,o-w .
200 cp $here/tmparch/mv-foo.* .
201 pmlogmv -V mv-foo new/mv-foo >$tmp.out 2>&1
202 sts=$?
203 _filter <$tmp.out
204 [ $sts -eq 0 ] || echo exit status $sts
205 ls mv-foo* new/* 2>&1 | _filter_ls
206 chmod u+w,g+w,o+w .
207 rm -rf mv-foo.* new
209 echo
210 echo "=== Frank's error case rm failing after first file ==="
211 cp $here/tmparch/mv-foo.* .
212 ln mv-foo.2 mv-foo.3
213 pmlogmv -V mv-foo mv-bar >$tmp.out 2>&1
214 sts=$?
215 _filter <$tmp.out
216 [ $sts -eq 0 ] || echo exit status $sts
217 ls mv-foo* mv-bar* 2>&1 | _filter_ls
218 rm -rf mv-foo.* mv-bar.*
220 # success, all done
221 status=0
223 exit