Small sh "framework" to test some server responses
sh
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

example.sh 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. usage() {
  3. echo "Usage : $0 [OPTIONS]
  4. -h --help : display this help and exit
  5. -c --continue : continue after a failure
  6. -n --no-color : disable uses of tput to display colors
  7. -v --verbose : increase verbosity level"
  8. }
  9. verbose=0
  10. exit_on_fail=1
  11. color=1
  12. OPTS=$(getopt -o vcnh --long verbose,continue,no-color,help: -n 'parse-options' -- "$@")
  13. if [ "$?" -ne "0" ]
  14. then
  15. echo ""
  16. usage
  17. exit 1
  18. fi
  19. for o in $OPTS
  20. do
  21. case "$o"
  22. in
  23. -v | --verbose ) verbose=$(expr $verbose + 1);;
  24. -c | --continue ) exit_on_fail=0;;
  25. -n | --no-color ) color=0;;
  26. -h | --help ) usage; exit 0;;
  27. -- ) break;;
  28. *) echo "Unknown argument '$1'" >&2;
  29. usage
  30. exit 1;;
  31. esac
  32. done
  33. export color
  34. export verbose
  35. export exit_on_fail
  36. . ./check.sh
  37. # Initialize tests
  38. CHECK_START
  39. # Init testcase with title and description
  40. TC_INIT "Ping check" "Send ping to some hosts" # Needs ping
  41. TC_RUN check_ping gnu.org 2
  42. TC_RUN check_ping localhost
  43. TC_END
  44. TC_INIT "SSH" "Testing ssh server" # Needs netcat
  45. TC_RUN check_ssh_nc ssh.cluster001.ovh.net
  46. TC_END
  47. TC_INIT "HTTP/HTTPS" "Testing HTTP status & HTTPS cert" # Needs curl
  48. TC_RUN check_https_cert gnu.org
  49. TC_RUN check_http_200 http://www.gnu.org/index.html
  50. TC_RUN check_http_status http://www.gnu.org/sqdsqdk.foo 404
  51. TC_RUN check_http_status http://gnu.org/ 301
  52. TC_END
  53. TC_INIT "HTML" # Needs xsltproc
  54. TC_RUN check_html_title http://www.gnu.org/ "The GNU Operating System and the Free Software Movement"
  55. TC_END
  56. TC_INIT "Git" "Try to clone a git repo" # Needs git
  57. TC_RUN check_git_repo https://git.yannweb.net/yannweb/mhssh.git
  58. TC_END
  59. TC_INIT "Audio streaming" "Testing audio stream" # Needs mplayer
  60. TC_RUN check_audiostream http://zmpd.zered.net:8042/fip-metadata.mp3
  61. TC_RUN check_audiostream http://ice1.somafm.com/missioncontrol-128-mp3 256kb
  62. TC_END
  63. # Display results
  64. CHECK_REPORT