source: MondoRescue/branches/3.2/mindi-busybox/archival/bbunzip_test.sh@ 3232

Last change on this file since 3232 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/bin/sh
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).
6
7gzip="gzip"
8gunzip="../busybox gunzip"
9# Or the other way around:
10#gzip="../busybox gzip"
11#gunzip="gunzip"
12
13c=0
14i=$PID
15while true; do
16 c=$((c+1))
17
18 # RANDOM is not very random on some shells. Spice it up.
19 # 100003 is prime
20 len1=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
21 i=$((i * 1664525 + 1013904223))
22 len2=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
23
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
30
31 $gzip <z1 >zz.gz
32 $gzip <z2 >>zz.gz
33 $gunzip -c zz.gz >z9 || {
34 echo "Exitcode $?"
35 exit
36 }
37 sum=`cat z1 z2 | md5sum`
38 sum9=`md5sum <z9`
39 test "$sum" == "$sum9" || {
40 echo "md5sums don't match"
41 exit
42 }
43 echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum"
44
45 sum=`cat z1 z2 z1 z2 | md5sum`
46 rm z1.gz z2.gz 2>/dev/null
47 $gzip z1
48 $gzip z2
49 cat z1.gz z2.gz z1.gz z2.gz >zz.gz
50 $gunzip -c zz.gz >z9 || {
51 echo "Exitcode $? (2)"
52 exit
53 }
54 sum9=`md5sum <z9`
55 test "$sum" == "$sum9" || {
56 echo "md5sums don't match (1)"
57 exit
58 }
59
60 echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum (2)"
61done
Note: See TracBrowser for help on using the repository browser.