test-00-commands-have-help 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. # this test does double duty: The obvious is checking for --help and co,
  8. # but it also checks if the binary can find all methods in the library.
  9. # The later is quite handy for manual testing of non-abibreaking changes
  10. export LD_BIND_NOW=1
  11. # german variant of klingon used for testing usage of non-existent l10n
  12. export LC_ALL=tlh_DE.UTF-8
  13. checkversionmessage() {
  14. testsuccess grep '^apt .* (' ${1}-help.output
  15. }
  16. checkhelpmessage() {
  17. checkversionmessage "$1"
  18. testsuccess grep '^Usage:' ${1}-help.output
  19. }
  20. checkoptions() {
  21. testsuccess $1 --help
  22. cp -f rootdir/tmp/testsuccess.output ${1}-help.output
  23. checkhelpmessage "$1"
  24. testsuccess $1 --version
  25. cp -f rootdir/tmp/testsuccess.output ${1}-help.output
  26. checkversionmessage "$1"
  27. }
  28. for CMD in 'apt-cache' 'apt-cdrom' 'apt-config' \
  29. 'apt-extracttemplates' 'apt-get' 'apt-helper' \
  30. 'apt-mark' 'apt-sortpkgs' 'apt' 'apt-ftparchive'; do
  31. cmd="$(echo "$CMD" | tr -d '-')"
  32. msgtest 'Test for failure with no parameters calling' "$CMD"
  33. if $cmd > ${cmd}-help.output 2>&1; then
  34. echo
  35. cat ${cmd}-help.output
  36. msgfail 'zero exit'
  37. else
  38. msgpass
  39. fi
  40. checkhelpmessage "$cmd"
  41. checkoptions "$cmd"
  42. done
  43. for CMD in 'apt-dump-solver' 'apt-internal-solver' 'apt-internal-planner'; do
  44. checkoptions "$(echo "$CMD" | tr -d '-')"
  45. done
  46. # in times of need, we all look for super cow to save the day
  47. testsuccess aptget moo
  48. testsuccess aptget moo -q=2
  49. testsuccess aptget moo moo
  50. testsuccess aptget moo moo -q=2
  51. testsuccess aptget moo moo --color
  52. testsuccess aptget moo moo moo
  53. testsuccess aptget moo moo moo -q=2
  54. testsuccess aptget moo moo moo moo
  55. testsuccess aptget moo moo moo moo -q=2