2 # Test that concatenated gz files are unpacking correctly.
3 # It also tests that unpacking in general is working right.
4 # Since zip code has many corner cases, run it for a few hours
5 # to get a decent coverage (200000 tests or more).
8 gunzip
="../busybox gunzip"
9 # Or the other way around:
10 #gzip="../busybox gzip"
18 # RANDOM is not very random on some shells. Spice it up.
20 len1
=$
(( (((RANDOM
*RANDOM
)^i
) & 0x7ffffff) % 100003 ))
21 i
=$
((i
* 1664525 + 1013904223))
22 len2
=$
(( (((RANDOM
*RANDOM
)^i
) & 0x7ffffff) % 100003 ))
24 # Just using urandom will make gzip use method 0 (store) -
25 # not good for test coverage!
26 cat /dev
/urandom |
while true
; do read junk
; echo "junk $c $i $junk"; done \
27 |
dd bs
=$len1 count
=1 >z1
2>/dev
/null
28 cat /dev
/urandom |
while true
; do read junk
; echo "junk $c $i $junk"; done \
29 |
dd bs
=$len2 count
=1 >z2
2>/dev
/null
33 $gunzip -c zz.gz
>z9 ||
{
37 sum=`cat z1 z2 | md5sum`
39 test "$sum" == "$sum9" ||
{
40 echo "md5sums don't match"
43 echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum"
45 sum=`cat z1 z2 z1 z2 | md5sum`
46 rm z1.gz z2.gz
2>/dev
/null
49 cat z1.gz z2.gz z1.gz z2.gz
>zz.gz
50 $gunzip -c zz.gz
>z9 ||
{
51 echo "Exitcode $? (2)"
55 test "$sum" == "$sum9" ||
{
56 echo "md5sums don't match (1)"
60 echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum (2)"