test-00-commands-have-help 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. checkversionmessage() {
  12. testsuccess grep '^apt .* compiled on ' ${1}-help.output
  13. }
  14. checkhelpmessage() {
  15. checkversionmessage "$1"
  16. testsuccess grep '^Usage:' ${1}-help.output
  17. }
  18. checkoptions() {
  19. testsuccess $1 --help
  20. cp -f rootdir/tmp/testsuccess.output ${1}-help.output
  21. checkhelpmessage "$1"
  22. testsuccess $1 --version
  23. cp -f rootdir/tmp/testsuccess.output ${1}-help.output
  24. checkversionmessage "$1"
  25. }
  26. for CMD in 'apt-cache' 'apt-cdrom' 'apt-config' \
  27. 'apt-extracttemplates' 'apt-get' 'apt-helper' \
  28. 'apt-mark' 'apt-sortpkgs' 'apt' 'apt-ftparchive'; do
  29. cmd="$(echo "$CMD" | tr -d '-')"
  30. msgtest 'Test for failure with no parameters calling' "$CMD"
  31. if $cmd > ${cmd}-help.output 2>&1; then
  32. echo
  33. cat ${cmd}-help.output
  34. msgfail 'zero exit'
  35. else
  36. msgpass
  37. fi
  38. checkhelpmessage "$cmd"
  39. checkoptions "$cmd"
  40. done
  41. for CMD in 'apt-dump-solver' 'apt-internal-solver'; do
  42. checkoptions "$(echo "$CMD" | tr -d '-')"
  43. done