pmrep: fix archive end time reporting
[pcp.git] / qa / 738
blob9e679b25dcee012b2582906db74258d45c1ba6cc
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) and rm(1)
25 # error messages!
26 sed \
27 -e '/^[rwx.-]* /s/.* /... ls data ... /' \
28 -e 's/`'"/'/g" \
29 -e 's/‘'"/'/g" \
30 -e 's/’'"/'/g" \
31 -e '/^ln: .*Permission/{
32 s/creating hard link //
33 s/failed to create hard link //
34 '"s/' to '/' => '/"'
35 '"s/'.* => '//"'
36 '"s/'//g"'
37 s@new/@@
38 }' \
39 -e '/^rm: .*Permission/{
40 s/cannot remove //
41 '"s/'//g"'
42 }' \
43 | _filter_ls
46 # ls(1) does not have the same format for error messages, sigh.
48 # Note on second sed expression ... need to handle GNU coreutils
49 # brain damage from newer versions of ls(1) and remove ' quotes
50 # from lines like ...
51 # ls: cannot access 'foo*': No such file or directory
53 _filter_ls()
55 sed \
56 -e '/ls: [^ ]*\*: No such/s/ls: /ls: cannot access /' \
57 -e "/: No such file /s/ '\([^']*\)': No/ \1: No/" \
58 # done
61 # real QA test starts here
64 echo "=== Usage, no input files, incomplete input archive ==="
65 pmlogmv
66 sts=$?
67 [ $sts -eq 0 ] || echo exit status $sts
68 pmlogmv foo
69 sts=$?
70 [ $sts -eq 0 ] || echo exit status $sts
71 pmlogmv foo bar
72 sts=$?
73 [ $sts -eq 0 ] || echo exit status $sts
74 cp $here/tmparch/foo.0 .
75 pmlogmv foo bar >$tmp.out 2>&1
76 sts=$?
77 _filter <$tmp.out
78 [ $sts -eq 0 ] || echo exit status $sts
79 rm foo.0
80 cp $here/tmparch/foo.meta .
81 pmlogmv foo bar >$tmp.out 2>&1
82 sts=$?
83 _filter <$tmp.out
84 [ $sts -eq 0 ] || echo exit status $sts
85 rm -f foo.* bar.*
87 echo
88 echo "=== non-pcp archives and output files already exist ==="
89 cp $here/tmparch/foo.* .
90 touch foo.frog
91 pmlogmv -V foo bar >$tmp.out 2>&1
92 sts=$?
93 _filter <$tmp.out
94 [ $sts -eq 0 ] || echo exit status $sts
95 ls foo* bar* 2>&1 | _filter_ls
96 rm -f foo.* bar.*
97 cp $here/tmparch/foo.* .
98 for i in 0 index meta
100 echo "--- bar.$i already exists ---"
101 cp $here/tmparch/bar.$i .
102 pmlogmv -V foo bar >$tmp.out 2>&1
103 sts=$?
104 _filter <$tmp.out
105 [ $sts -eq 0 ] || echo exit status $sts
106 ls foo* bar* 2>&1 | _filter_ls
107 rm bar.$i
108 done
109 rm -f foo.* bar.*
111 echo
112 echo "=== simplest case ==="
113 cp $here/tmparch/foo.* .
114 pmlogmv -NV foo bar >$tmp.out 2>&1
115 sts=$?
116 _filter <$tmp.out
117 [ $sts -eq 0 ] || echo exit status $sts
118 pmlogmv -V foo bar >$tmp.out 2>&1
119 sts=$?
120 _filter <$tmp.out
121 [ $sts -eq 0 ] || echo exit status $sts
122 for part in 0 index meta
124 if cmp $here/tmparch/foo.$part bar.$part
125 then
127 else
128 echo "Arrgh ... input foo.$part not the same as output bar.$part"
129 ls -l $here/tmparch/foo.$part bar.$part
131 done
132 ls foo* bar* 2>&1 | _filter_ls
133 rm -f foo.* bar.*
135 echo
136 echo "=== single oldfile name cases ==="
137 for ext in meta 0 index
139 echo "--- foo.$ext ---"
140 cp $here/tmparch/foo.* .
141 pmlogmv -V foo.$ext bar >$tmp.out 2>&1
142 sts=$?
143 _filter <$tmp.out
144 [ $sts -eq 0 ] || echo exit status $sts
145 for part in 0 index meta
147 if cmp $here/tmparch/foo.$part bar.$part
148 then
150 else
151 echo "Arrgh ... input foo.$part not the same as output bar.$part"
152 ls -l $here/tmparch/foo.$part bar.$part
154 done
155 ls foo* bar* 2>&1 | _filter_ls
156 rm -f foo.* bar.*
157 done
159 echo
160 echo "=== multi-volume case ==="
161 cp $here/tmparch/mv-foo.* .
162 cp mv-foo.2 mv-foo.123456789
163 pmlogmv -V mv-foo bar >$tmp.out 2>&1
164 sts=$?
165 _filter <$tmp.out
166 [ $sts -eq 0 ] || echo exit status $sts
167 for opart in 0 1 2 123456789 index meta
169 npart=$opart
170 [ "$opart" = 123456789 ] && opart=2
171 if cmp $here/tmparch/mv-foo.$opart bar.$npart
172 then
174 else
175 echo "Arrgh ... input mv-foo.$opart not the same as output bar.$npart"
176 ls -l $here/tmparch/mv-foo.$opart bar.$npart
178 done
179 ls foo* bar* 2>&1 | _filter_ls
180 rm -f foo.* bar.*
182 echo
183 echo "=== old and new in different directories =="
184 mkdir new
185 cp $here/tmparch/mv-foo.* .
186 pmlogmv -V mv-foo new/mv-foo >$tmp.out 2>&1
187 sts=$?
188 _filter <$tmp.out
189 [ $sts -eq 0 ] || echo exit status $sts
190 for part in 0 1 2 index meta
192 if cmp $here/tmparch/mv-foo.$part new/mv-foo.$part
193 then
195 else
196 echo "Arrgh ... input mv-foo.$part not the same as output new/mv-foo.$part"
197 ls -l $here/tmparch/mv-foo.$part new/mv-foo.$part
199 done
200 ls foo* new/* 2>&1 | _filter_ls
201 rm -rf foo.* new
203 echo
204 echo "=== error case for ln failing ==="
205 mkdir new
206 chmod u-w,g-w,o-w new
207 cp $here/tmparch/mv-foo.* .
208 pmlogmv -V mv-foo new/mv-foo >$tmp.out 2>&1
209 sts=$?
210 _filter <$tmp.out
211 [ $sts -eq 0 ] || echo exit status $sts
212 ls mv-foo* new/* 2>&1 | _filter_ls
213 rm -rf foo.* new
215 echo
216 echo "=== error case for rm failing ==="
217 mkdir new
218 chmod u-w,g-w,o-w .
219 cp $here/tmparch/mv-foo.* .
220 pmlogmv -V mv-foo new/mv-foo >$tmp.out 2>&1
221 sts=$?
222 _filter <$tmp.out
223 [ $sts -eq 0 ] || echo exit status $sts
224 ls mv-foo* new/* 2>&1 | _filter_ls
225 chmod u+w,g+w,o+w .
226 rm -rf mv-foo.* new
228 echo
229 echo "=== Frank's error case rm failing after first file ==="
230 cp $here/tmparch/mv-foo.* .
231 ln mv-foo.2 mv-foo.3
232 pmlogmv -V mv-foo mv-bar >$tmp.out 2>&1
233 sts=$?
234 _filter <$tmp.out
235 [ $sts -eq 0 ] || echo exit status $sts
236 ls mv-foo* mv-bar* 2>&1 | _filter_ls
237 rm -rf mv-foo.* mv-bar.*
239 # success, all done
240 status=0
242 exit