test-apt-download-progress 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. msgtest 'download progress works via' 'http'
  25. exec 3> apt-progress.log
  26. testsuccess --nomsg apthelper download-file "http://localhost:8080/$TESTFILE" http-$TESTFILE -o APT::Status-Fd=3 -o Acquire::http::Dl-Limit=800
  27. assertprogress apt-progress.log
  28. msgtest 'download progress works via' 'https'
  29. exec 3> apt-progress.log
  30. testsuccess --nomsg apthelper download-file "https://localhost:4433/$TESTFILE" https-$TESTFILE -o APT::Status-Fd=3 -o Acquire::https::Dl-Limit=800
  31. assertprogress apt-progress.log
  32. # cleanup
  33. rm -f apt-progress*.log