Small sh "framework" to test some server responses
sh
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

example.sh 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. if OPTS=$(getopt -o vcnh --long verbose,continue,no-color,help: -n 'parse-options' -- "$@")
  13. then
  14. :
  15. else
  16. echo ""
  17. usage
  18. exit 1
  19. fi
  20. for o in $OPTS
  21. do
  22. case "$o"
  23. in
  24. -v | --verbose ) verbose=$(( verbose + 1 ));;
  25. -c | --continue ) exit_on_fail=0;;
  26. -n | --no-color ) color=0;;
  27. -h | --help ) usage; exit 0;;
  28. -- ) break;;
  29. *) echo "Unknown argument '$1'" >&2;
  30. usage
  31. exit 1;;
  32. esac
  33. done
  34. export color
  35. export verbose
  36. export exit_on_fail
  37. . ./check.sh
  38. # Initialize tests
  39. CHECK_START
  40. # Init testcase with title and description
  41. TC_INIT "Ping check" "Send ping to some hosts" # Needs ping
  42. TC_RUN check_ping gnu.org 2
  43. TC_RUN check_ping localhost
  44. TC_END
  45. TC_INIT "SSH" "Testing ssh server" # Needs netcat
  46. TC_RUN check_ssh_nc ssh.cluster007.ovh.net
  47. TC_RUN check_ssh_key ssh.cluster007.ovh.net 'AAAAB3NzaC1yc2EAAAADAQABAAABAQCxTdeGLZ7JYXj6XbxlRSK5YXxfgD3HMmaXFtsM+jMZXKAVG6wLBTaLS3CqhUbtuFNs/or6geS1tban33x2nyGn283Wbf3x1PS1cgg9fBAd9tQNsZZ7pEJ6shqv4Lnv+cHRdgNPrGnEim/eUs3H7ZOd5CuCpaoDV31XD+klwCAu/ANq+GiX4iarER59Ij6xd736r+kYAWbguZCV0lL91ag5g6+vVvufHngr6HY5rvl1Ybw1nSfzEG4+UYl5EwvWFSuxPq706DV1kUDmQ17GkD/z0GzBdPDMzgQSLEVvT3CBqAqrosGZO2Iap8EOLDBd/h6ZWWsO2EjEadJJXb23xwhr'
  48. TC_END
  49. TC_INIT "HTTP/HTTPS" "Testing HTTP status & HTTPS cert" # Needs curl
  50. TC_RUN check_https_cert gnu.org
  51. TC_RUN check_http_200 http://www.gnu.org/index.html
  52. TC_RUN check_http_status http://www.gnu.org/sqdsqdk.foo 404
  53. TC_RUN check_http_status http://gnu.org/ 301
  54. TC_END
  55. TC_INIT "HTML" # Needs xsltproc
  56. TC_RUN check_html_title http://www.gnu.org/ "The GNU Operating System and the Free Software Movement"
  57. TC_END
  58. TC_INIT "Git" "Try to clone a git repo" # Needs git
  59. TC_RUN check_git_repo https://git.yannweb.net/yannweb/mhssh.git
  60. TC_END
  61. TC_INIT "Audio streaming" "Testing audio stream" # Needs mplayer
  62. TC_RUN check_audiostream http://zmpd.zered.net:8042/fip-metadata.mp3
  63. TC_RUN check_audiostream http://ice1.somafm.com/missioncontrol-128-mp3 256kb
  64. TC_END
  65. # Display results
  66. CHECK_REPORT