| |
@@ -23,6 +23,7 @@
|
| |
-w, --workdir test environment work dir
|
| |
-a, --artifactsdir test environment dir to store artifacts
|
| |
-t, --test test to run, can be a path to directory or a runtest.sh file
|
| |
+ --timeout test timeout
|
| |
EOF
|
| |
}
|
| |
|
| |
@@ -35,9 +36,10 @@
|
| |
STR_BKR_TEST="${STR_BKR_TEST:-}"
|
| |
STR_WORKDIR="${STR_WORKDIR:-}"
|
| |
STR_ARTIFACTS_DIR="${STR_ARTIFACTS_DIR:-}"
|
| |
+ STR_TIMEOUT="${STR_TIMEOUT:-0}"
|
| |
|
| |
# http://wiki.bash-hackers.org/howto/getopts_tutorial
|
| |
- opt=$(getopt -n "$0" --options "hvt:w:a:" --longoptions "help,verbose,test:,workdir:,artifactsdir:" -- "$@")
|
| |
+ opt=$(getopt -n "$0" --options "hvt:w:a:" --longoptions "help,verbose,test:,workdir:,artifactsdir:,timeout:" -- "$@")
|
| |
eval set -- "$opt"
|
| |
while [[ $# -gt 0 ]]; do
|
| |
case "$1" in
|
| |
@@ -53,6 +55,10 @@
|
| |
STR_ARTIFACTS_DIR="$2"
|
| |
shift 2
|
| |
;;
|
| |
+ --timeout)
|
| |
+ STR_TIMEOUT="$2"
|
| |
+ shift 2
|
| |
+ ;;
|
| |
-v|--verbose)
|
| |
DEBUG="-v"
|
| |
shift
|
| |
@@ -80,6 +86,7 @@
|
| |
debug "Test: $STR_BKR_TEST"
|
| |
debug "Work dir: $STR_WORKDIR"
|
| |
debug "Artifacts dir: $STR_ARTIFACTS_DIR"
|
| |
+ debug "Timeout: $STR_TIMEOUT"
|
| |
STR_BKR_TEST_DASHED=$(echo "$STR_BKR_TEST" | sed -e 's/\//-/g')
|
| |
|
| |
# Up to this point any fail is considered as ci-sytem fail. Exit code != 0.
|
| |
@@ -101,6 +108,10 @@
|
| |
local status
|
| |
if [[ $rc -eq 127 ]]; then
|
| |
status="ERROR"
|
| |
+ elif [[ $rc -eq 124 ]]; then
|
| |
+ # test case timed out
|
| |
+ echo "$STR_BKR_TEST (test aborted due to timeout)" >&2
|
| |
+ status="ERROR"
|
| |
elif grep -q "RESULT: WARN" "$log_file_path"; then
|
| |
status="ERROR"
|
| |
elif grep -q "RESULT: FAIL" "$log_file_path"; then
|
| |
@@ -146,7 +157,7 @@
|
| |
if [ -f "$STR_BKR_TEST" ]; then
|
| |
debug "Running test from file: $STR_BKR_TEST"
|
| |
cd $(dirname "$STR_BKR_TEST")
|
| |
- /bin/sh -e ./$(basename "$STR_BKR_TEST") || :
|
| |
+ timeout "$STR_TIMEOUT" /bin/sh -e ./$(basename "$STR_BKR_TEST")
|
| |
exit
|
| |
fi
|
| |
|
| |
@@ -157,10 +168,10 @@
|
| |
get-test-deps -i .
|
| |
if [ -f "Makefile" ] && command -p -v "make" >"/dev/null" 2>&1; then
|
| |
debug "Running test from Makefile"
|
| |
- make run || :
|
| |
+ timeout "$STR_TIMEOUT" make run
|
| |
elif [ -f "runtest.sh" ]; then
|
| |
debug "Running test from runtest.sh"
|
| |
- /bin/sh -e ./runtest.sh || :
|
| |
+ timeout "$STR_TIMEOUT" /bin/sh -e ./runtest.sh
|
| |
else
|
| |
echo "FAIL test $STR_BKR_TEST do not know how to run test"
|
| |
fi
|
| |
fix related to https://pagure.io/standard-test-roles/issue/346