Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ force="no"
head="yes"
retry="yes"
tests=""
interruptible="no"
exit_on_failure="yes"
skip_bad_tests="yes"
skip_known_bugs="yes"
Expand Down Expand Up @@ -395,13 +396,17 @@ function run_tests()
echo "[$(date +%H:%M:%S)] Running tests in file $t"
starttime="$(date +%s)"

local timeout_cmd="timeout"
if [ ${interruptible} == "yes" ]; then
timeout_cmd=$(echo "$timeout_cmd --foreground")
fi
local cmd_timeout=$run_timeout;
if [ ${timeout_cmd_exists} == "yes" ]; then
if [ $(grep -c "SCRIPT_TIMEOUT=" ${t}) == 1 ] ; then
cmd_timeout=$(grep "SCRIPT_TIMEOUT=" ${t} | cut -f2 -d'=');
echo "Timeout set is ${cmd_timeout}, default ${run_timeout}"
fi
timeout --foreground -k ${kill_after_time} ${cmd_timeout} prove -vmfe '/bin/bash' ${t}
$timeout_cmd -k ${kill_after_time} ${cmd_timeout} prove -vmfe '/bin/bash' ${t}
else
prove -vmfe '/bin/bash' ${t}
fi
Expand All @@ -425,7 +430,7 @@ function run_tests()
echo ""

if [ ${timeout_cmd_exists} == "yes" ]; then
timeout --foreground -k ${kill_after_time} ${cmd_timeout} prove -vmfe '/bin/bash' ${t}
$timeout_cmd -k ${kill_after_time} ${cmd_timeout} prove -vmfe '/bin/bash' ${t}
else
prove -vmfe '/bin/bash' ${t}
fi
Expand Down Expand Up @@ -559,6 +564,7 @@ Options:
-t TIMEOUT
-n skip NFS tests
-l list tests that should be executed
-i make the running test interruptible
--help
EOF
}
Expand All @@ -567,7 +573,7 @@ usage="no"

function parse_args ()
{
args=`getopt -u -l help frRcbkphHnlo:t: "$@"`
args=`getopt -u -l help frRcbkphHnlio:t: "$@"`
if ! [ $? -eq 0 ]; then
show_usage
exit 1
Expand All @@ -588,6 +594,7 @@ function parse_args ()
-t) run_timeout="$2"; shift;;
-n) nfs_tests="no";;
-l) list_only="yes";;
-i) interruptible="yes" ;;
--help) usage="yes" ;;
--) shift; break;;
esac
Expand Down
7 changes: 5 additions & 2 deletions tests/include.rc
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,11 @@ function cleanup()

function force_terminate () {
local ret=$?;
>&2 echo -e "\nreceived external"\
"signal --`kill -l $ret`--, calling 'cleanup' ...\n";

# Run this cmd as a subshell and flush stdout buffer to stderr
# immediately.
(>&2 echo -e "\nreceived external"\
"signal --`kill -l $ret`--, calling 'cleanup' ...\n");
cleanup;
exit $ret;
}
Expand Down