Browse Source

Add an example script

Yann Weber 7 years ago
parent
commit
9dccf82f34
1 changed files with 78 additions and 0 deletions
  1. 78
    0
      example.sh

+ 78
- 0
example.sh View File

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

Loading…
Cancel
Save