11#! /bin/sh
22# Test if cabd_md5 expands cab files identically to Microsoft's EXTRACT.EXE
3+ # (or EXPAND.EXE if cab file is in a directory called 'expand')
34
45[ -d .cache ] || mkdir .cache
56BASEDIR=` dirname " $0 " `
67
78cnt=1
9+ orig=.$$ .orig
10+ test=.$$ .test
811for cab in " $@ " ; do
912 name=` printf ' %d/%d %s' $cnt $# $cab `
1013 cnt=` expr $cnt + 1`
1114
1215 echo " test $name "
1316 cached=` echo $cab | sed -e ' s/\//-/g' -e ' s/^/.cache\//' `
1417 if [ ! -s $cached ]; then
15- $BASEDIR /msextract_md5 $cab > .orig.out 2> .orig.err
16- if [ -s .orig.err ]; then
18+ case $cab in
19+ * /expand/* ) $BASEDIR /msexpand_md5 $cab > $orig 2> $orig .err;;
20+ * ) $BASEDIR /msextract_md5 $cab > $orig 2> $orig .err;;
21+ esac
22+
23+ if [ -s $orig .err ]; then
1724 echo " FAIL $name : MS errors" >&2
18- cat .orig.err >&2
19- else
20- mv .orig.out $cached
25+ cat $orig .err >&2
26+ continue
2127 fi
28+ mv $orig $cached
2229 fi
2330
24- $BASEDIR /cabd_md5 $cab > . test.out 2> . test.err
25- perl -pi -e ' if($.>1){s{\\}{/}g;s{ /}{ }}' . test.out
31+ $BASEDIR /cabd_md5 $cab > $ test 2> $ test .err
32+ perl -pi -e ' if($.>1){s{\\}{/}g;s{ /}{ }}' $ test
2633
2734 # suppress warning. PRECOPY2.CAB does not extend to CATALOG3.CAB, but
2835 # CATALOG3.CAB extends backwards to PRECOPY2.CAB. cabd_md5 supports this
2936 # but msextract_md5 does not, so differences appear. As a workaround, test
3037 # PRECOPYn.CAB separately and suppress the warning when testing CATALOG3.CAB
31- sed -i " /can't find \" PRECOPY2.CAB\" to prepend/d" . test.err
38+ sed -i " /can't find \" PRECOPY2.CAB\" to prepend/d" $ test .err
3239
3340 # suppress warning. One cabinet set has this structure:
3441 # * cab1: file1 FROM_PREV, file2 TO_NEXT
@@ -38,18 +45,19 @@ for cab in "$@"; do
3845 # This is wrong. file3 and file4 are in the same folder, so both should
3946 # be FROM_PREV_AND_TO_NEXT in cab3, and both should be listed in cab4.
4047 # However, the set unpacks despite the warning, so suppress it.
41- sed -i ' /rainloop.xa not listed in both cabinets/d' . test.err
48+ sed -i ' /rainloop.xa not listed in both cabinets/d' $ test .err
4249
43- if [ -s . test.err ]; then
50+ if [ -s $ test .err ]; then
4451 echo " FAIL $name : errors" >&2
45- cat .test.err >&2
52+ cat $test .err >&2
53+ continue
4654 fi
4755
48- if cmp $cached . test.out > /dev/null; then
56+ if cmp $cached $ test > /dev/null; then
4957 echo " OK $name "
5058 else
5159 echo " FAIL $name : differences" >&2
52- diff -u $cached . test.out >&2
60+ diff -u $cached $ test >&2
5361 fi
5462done
55- rm -f . orig.out . orig.err . test.out . test.err
63+ rm -f $ orig $ orig .err $ test $ test .err
0 commit comments