test-apt-download-progress 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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:[0-9]{1,2}\.(.*):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. #cat $T
  19. }
  20. # we need to ensure the file is reasonable big so that apt has a chance to
  21. # actually report progress - but not too big to ensure its not delaying the
  22. # test too much
  23. TESTFILE=testfile.big
  24. testsuccess dd if=/dev/zero of=./aptarchive/$TESTFILE bs=800k count=1
  25. msgtest 'download progress works via' 'http'
  26. printf '\n'
  27. exec 3> apt-progress.log
  28. testsuccess apthelper download-file "http://localhost:8080/$TESTFILE" http-$TESTFILE -o APT::Status-Fd=3 -o Acquire::http::Dl-Limit=800
  29. assertprogress apt-progress.log
  30. msgtest 'download progress works via' 'https'
  31. printf '\n'
  32. exec 3> apt-progress.log
  33. testsuccess apthelper download-file "https://localhost:4433/$TESTFILE" https-$TESTFILE -o APT::Status-Fd=3 -o Acquire::https::Dl-Limit=800
  34. assertprogress apt-progress.log
  35. # cleanup
  36. rm -f apt-progress*.log