"Fossies" - the Fresh Open Source Software Archive 
Member "afio-2.5.2/regtest/regtest.do" (30 Nov 2018, 5629 Bytes) of package /linux/misc/afio-2.5.2.tgz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1
2 echo Doing regression tests with test archive $TESTA....
3
4 function printop { op=$1; echo " * $op"; };
5 function failure { echo "FAILURE in: $op"; failed=1; };
6 comploc=`pwd`/dircompare
7 function dircomp { export d1=$1; export d2=$2; export cmpflag=$3; bash -c $comploc; };
8
9 # do actual regression test
10
11 wd=`pwd`
12
13 source regtest.clean
14
15 if [ "$OLDAF" != "" ]; then
16
17 printop "unpack test archive to t1/ with old afio"
18 mkdir t1
19 cd t1
20 if ! $OLDAF -iZ $TESTA; then
21 failure
22 fi
23 cd $wd
24
25
26 if [ -d $OLDTESTD ]; then
27 printop "compare test archive with unpacked old test archive"
28 if ! dircomp $OLDTESTD t1/afiot; then
29 failure
30 fi
31 fi
32
33 fi
34
35
36 printop "unpack test archive to t2/ with new afio"
37 mkdir t2
38 cd t2
39 if ! $NEWAF -iZ $TESTA; then
40 failure
41 fi
42 cd $wd
43
44 if [ $ERRORINJECT = 1 ]; then
45 echo adding some errors to self-test the regression test
46 echo > t1/afiot/jbtdfj
47 echo > t2/afiot/ergergeg
48 echo >>t2/afiot/files/b2
49 chmod 222 t2/afiot/files/b3
50 fi
51
52 if [ "$OLDAF" != "" ]; then
53 printop "compare test archive trees that were unpacked by new and old afio"
54 if ! dircomp t1 t2; then
55 failure
56 fi
57 fi
58
59
60 if [ -f $TESTTAR ]; then
61 printop "untar tarred version of test archive into t4/ (the tarred version does not contain future-dated file and socket file)"
62 mkdir t4
63 cd t4
64 if ! gunzip -c $TESTTAR | tar xf -; then
65 failure
66 fi
67 printop "compare unpacked tar archive with newly unpacked test archive"
68 cd $wd
69 if ! dircomp t4/afiot t2/afiot nouid; then
70 failure
71 fi
72 fi
73
74
75 printop "verify unpacked test archive with new afio";
76 cd t2
77 if ! $NEWAF -rZ $TESTA; then
78 failure
79 fi
80 cd $wd
81
82 # --- now we switch to packing experiments on the test tree
83 # (with the new dates on the dirs etc)
84
85 printop "pack test tree with new afio again"
86 cd t2
87 if ! $NEWAF -Zt $TESTA | sort | $NEWAF -oZ ../t2.afn; then
88 failure
89 fi
90 cd $wd
91
92 if [ "$OLDAF" != "" ]; then
93
94 printop "pack test tree with old afio again"
95 cd t2
96 if ! $NEWAF -Zt $TESTA | sort | $OLDAF -oZ ../t2.afo; then
97 failure
98 fi
99 cd $wd
100
101 printop "check if archive files produced by new and old afio are identical"
102 if ! cmp t2.afo t2.afn; then
103 failure
104 fi
105 fi
106
107 printop "pack test tree with new afio using -f and some other strange options"
108 cd t2
109 if ! $NEWAF -Zt $TESTA | sort | tr '\n' '\0' | $NEWAF -oZ -f -s 10m -0 ../t2.afnb; then
110 failure
111 fi
112 cd $wd
113
114 printop "check if archive file produced using -f and other strange options is same"
115 if ! cmp t2.afn t2.afnb; then
116 failure
117 fi
118
119 if [ "$OLDAF" != "" ]; then
120 printop "verify newly packed archive with old afio"
121 cd t2
122 if ! $OLDAF -rvZ ../t2.afn >../t2.afov; then
123 failure
124 fi
125 cd $wd
126 fi
127
128 printop "verify newly packed archive with new afio"
129 cd t2
130 if ! $NEWAF -rvZ ../t2.afn >../t2.afnv; then
131 failure
132 fi
133 cd $wd
134
135 if [ "$OLDAF" != "" ]; then
136 printop "compare verify operation -v outputs of new and old afio"
137 if ! cmp t2.afov t2.afnv; then
138 diff -U 0 t2.afov t2.afnv
139 failure
140 fi
141 fi
142
143 printop "try to install newly packed archive into t3/ with new afio"
144 mkdir t3
145 cd t3
146 if ! $NEWAF -iZ ../t2.afn; then
147 failure
148 fi
149 cd $wd
150
151 printop "check if tree is identical after packing and unpacking with new afio"
152 if ! dircomp t2 t3; then
153 failure
154 fi
155
156 if [ "$OLDAF" != "" ]; then
157 printop "list table-of-contents of test archive with old afio"
158 if ! $OLDAF -tvzZ t2.afn >t2.afot 2>t2.afot2; then
159 cat t2.afot2
160 failure
161 fi
162 fi
163
164 printop "list table-of-contents of test archive with new afio"
165 if ! $NEWAF -tvzZ t2.afn >t2.afnt 2>t2.afnt2; then
166 failure
167 fi
168
169 if [ "$OLDAF" != "" ]; then
170 printop "compare table-of-contents files generated by new and old afio"
171 if ! cmp t2.afot t2.afnt; then
172 diff -U 0 t2.afot t2.afnt
173 failure
174 fi
175 fi
176
177 printop "compare table-of-contents file made by new afio with archived toc"
178 #filter out date/time from tocs to account for timezone differences and
179 #changed time/date stamps on dirs and symlinks
180 $AWK '{gsub("... .. ..:..:.. ....","DATE"); print;}' $TESTTOC >t2.x
181 $AWK '{gsub("... .. ..:..:.. ....","DATE"); print;}' t2.afnt >t2.y
182 if [ "`whoami`" = root ]; then
183 #also, uid/gid to name mappings may also have changed, so filter out non-root files
184 grep -v "^[dl]" $TESTTOC | grep "root *root" <t2.x >t2.xx
185 grep -v "^[dl]" t2.afnt | grep "root *root" <t2.y >t2.yy
186 else
187 #filter out date/time from tocs to account for timezone differences and
188 #changed time/date stamps on dirs and symlinks
189 #also, archived toc uses user root, so blank out user and group fields.
190 $AWK '{$3="x"; $4="x"; print; }' <t2.x >t2.xx
191 $AWK '{$3="x"; $4="x"; print; }' <t2.y >t2.yy
192 fi
193 sort -t @ < t2.xx >t2.arch
194 sort -t @ < t2.yy >t2.new
195 if ! cmp t2.arch t2.new; then
196 diff -U 0 t2.arch t2.new
197 failure
198 fi
199
200 if [ "$OLDAF" != "" ]; then
201 printop "compare table-of-contents operation -z stderr generated by new and old afio"
202 $AWK '{gsub("[0-9]* second","XX second"); print}' <t2.afot2 >t2.afot2x
203 $AWK '{gsub("[0-9]* second","XX second"); print}' <t2.afnt2 >t2.afnt2x
204 if ! cmp t2.afot2x t2.afnt2x; then
205 failure
206 diff -U 0 t2.afot2x t2.afnt2x
207 fi
208 fi
209
210 printop "check if (the local version of) cpio can list the toc of an afio archive"
211 #gnu cpio needs -H odc, if we do not detect gnu cpio then try -c flag.
212 flags="-itv -c"
213 if cpio --version >t5.cv 2>/dev/null; then
214 if grep GNU t5.cv >/dev/null; then
215 flags="-tv -H odc"
216 fi
217 fi
218 if [ "x$flags" != "x-tv -H odc" ]; then
219 echo ..no GNU cpio found, trying the installed cpio with $flags flags.
220 fi
221 if ! cpio $flags <t2.afn >t2.afn.c1 2>t2.afn.c2; then
222 cat t2.afn.c2
223 failure
224 else
225 #gnu cpio does not seem to return error status on some errors, so
226 #check if stderr had anything...
227 if grep -v blocks t2.afn.c2 >/dev/null; then
228 cat t2.afn.c2
229 failure
230 fi
231 fi
232
233
234
235
236 if [ $failed = 1 ]; then
237 echo " -------------- "
238 echo THERE WERE REGRESSION TEST FAILURES
239 fi
240