test-apt-download-progress 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. #
  3. # ensure downloading sends progress as a regression test for commit 9127d7ae
  4. #
  5. set -e
  6. TESTDIR=$(readlink -f $(dirname $0))
  7. . $TESTDIR/framework
  8. setupenvironment
  9. changetohttpswebserver
  10. assertprogress() {
  11. T="$1"
  12. testsuccess grep "dlstatus:1:0:Retrieving file 1 of 1" "$T"
  13. if ! egrep -q "dlstatus:1:[1-9][0-9](\..*)?:Retrieving file 1 of 1" "$T"; then
  14. cat "$T"
  15. msgfail "Failed to detect download progress"
  16. fi
  17. testsuccess grep "dlstatus:1:100:Retrieving file 1 of 1" "$T"
  18. }
  19. # we need to ensure the file is reasonable big so that apt has a chance to
  20. # actually report progress - but not too big to ensure its not delaying the
  21. # test too much
  22. TESTFILE=testfile.big
  23. testsuccess dd if=/dev/zero of=./aptarchive/$TESTFILE bs=800k count=1
  24. OPT='-o APT::Status-Fd=3 -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1 -o Debug::Acquire::https=1'
  25. msgtest 'download progress works via' 'http'
  26. exec 3> apt-progress.log
  27. testsuccess --nomsg apthelper download-file "http://localhost:8080/$TESTFILE" http-$TESTFILE $OPT -o Acquire::http::Dl-Limit=800
  28. assertprogress apt-progress.log
  29. msgtest 'download progress works via' 'https'
  30. exec 3> apt-progress.log
  31. testsuccess --nomsg apthelper download-file "https://localhost:4433/$TESTFILE" https-$TESTFILE $OPT -o Acquire::https::Dl-Limit=800
  32. # cleanup
  33. rm -f apt-progress*.log