-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "shell-ci-build"] | ||
path = shell-ci-build | ||
url = https://github.com/caarlos0/shell-ci-build.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: bash | ||
|
||
sudo: required | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
install: | ||
- ./shell-ci-build/install.sh | ||
|
||
before_script: | ||
- curl -L "http://downloads.sourceforge.net/shunit2/shunit2-2.0.3.tgz" | tar zx | ||
- chmod +x $(pwd)/shunit2-2.0.3/src/shell/shunit2 | ||
|
||
script: | ||
- export SHUNIT2=$(pwd)/shunit2-2.0.3/src/shell/shunit2 | ||
- make test | ||
- ./shell-ci-build.sh |
Submodule shell-ci-build
added at
3ecb8b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
source ./shell-ci-build/build.sh | ||
check "./check_nagios_latency" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
if [ -z "${SHUNIT2}" ] ; then | ||
cat <<EOF | ||
To be able to run the unit test you need a copy of shUnit2 | ||
You can download it from http://shunit2.googlecode.com/ | ||
Once downloaded please set the SHUNIT2 variable with the location | ||
of the 'shunit2' script | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
if [ ! -x "${SHUNIT2}" ] ; then | ||
echo "Error: the specified shUnit2 script (${SHUNIT2}) is not an executable file" | ||
exit 1 | ||
fi | ||
|
||
SCRIPT=../check_nagios_latency | ||
if [ ! -r "${SCRIPT}" ] ; then | ||
echo "Error: the script to test (${SCRIPT}) is not a readable file" | ||
fi | ||
|
||
# constants | ||
|
||
NAGIOS_OK=0 | ||
NAGIOS_CRITICAL=1 | ||
NAGIOS_WARNING=2 | ||
NAGIOS_UNKNOWN=3 | ||
|
||
testUsage() { | ||
${SCRIPT} > /dev/null 2>&1 | ||
EXIT_CODE=$? | ||
assertEquals "wrong exit code" ${NAGIOS_UNKNOWN} "${EXIT_CODE}" | ||
} | ||
|
||
# the script will exit without executing main | ||
export SOURCE_ONLY='test' | ||
|
||
# source the script. | ||
. ${SCRIPT} | ||
|
||
unset SOURCE_ONLY | ||
|
||
# run shUnit: it will execute all the tests in this file | ||
# (e.g., functions beginning with 'test' | ||
. ${SHUNIT2} |