bbunzip_test3.sh 769 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. # Leak test for gunzip. Watch top for growing process size.
  3. # In this case we look for leaks in "concatenated .gz" code -
  4. # we feed gunzip with a stream of .gz files.
  5. i=$PID
  6. c=0
  7. while true; do
  8. c=$((c + 1))
  9. echo "Block# $c" >&2
  10. # RANDOM is not very random on some shells. Spice it up.
  11. i=$((i * 1664525 + 1013904223))
  12. # 100003 is prime
  13. len=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
  14. # Just using urandom will make gzip use method 0 (store) -
  15. # not good for test coverage!
  16. cat /dev/urandom \
  17. | while true; do read junk; echo "junk $c $i $junk"; done \
  18. | dd bs=$len count=1 2>/dev/null \
  19. | gzip >xxx.gz
  20. cat xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz
  21. done | ../busybox gunzip -c >/dev/null