mirror of https://github.com/CGAL/cgal
Merge pull request #4793 from lrineau/Testsuite-rework_the_timeout_of_run_testsuite-GF
Testsuite rework the timeout of run_testsuite
This commit is contained in:
commit
68eab710ee
|
|
@ -16,11 +16,17 @@ TESTSUITE_LDFLAGS=""
|
||||||
|
|
||||||
CURRENTDIR=`pwd`
|
CURRENTDIR=`pwd`
|
||||||
ERRORFILE=${CURRENTDIR}/error.txt
|
ERRORFILE=${CURRENTDIR}/error.txt
|
||||||
if [ -n "$CGAL_TEST_PLATFORM" ]; then
|
if [ -n "$CGAL_TEST_PLATFORM" ]; then
|
||||||
PLATFORM=$CGAL_TEST_PLATFORM
|
PLATFORM=$CGAL_TEST_PLATFORM
|
||||||
else
|
else
|
||||||
PLATFORM=no-platform
|
PLATFORM=no-platform
|
||||||
fi
|
fi
|
||||||
|
if [ -n "${CGAL_TIMEOUT_PROG+x}" ]; then
|
||||||
|
TIMEOUT=$CGAL_TIMEOUT_PROG
|
||||||
|
else
|
||||||
|
TIMEOUT=`which timeout`
|
||||||
|
[ -z "$TIMEOUT" ] && TIMEOUT=`which gtimeout`
|
||||||
|
fi
|
||||||
|
|
||||||
#clear the error file
|
#clear the error file
|
||||||
rm -f "$ERRORFILE"
|
rm -f "$ERRORFILE"
|
||||||
|
|
@ -34,9 +40,9 @@ process_tree()
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local result=
|
local result=
|
||||||
echo $pid
|
echo $pid
|
||||||
ps -a | awk '!/^ +PID/ {print $1 " " $2}' | {
|
ps -a | awk '!/^ +PID/ {print $1 " " $2}' | {
|
||||||
while read apid appid; do
|
while read apid appid; do
|
||||||
if [ "$appid" = "$pid" ]; then
|
if [ "$appid" = "$pid" ]; then
|
||||||
process_tree $apid
|
process_tree $apid
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -53,11 +59,11 @@ wait_for_process()
|
||||||
period=$3
|
period=$3
|
||||||
while [ $cycles -ne 0 ]
|
while [ $cycles -ne 0 ]
|
||||||
do
|
do
|
||||||
cycles=`expr $cycles - 1`
|
cycles=`expr $cycles - 1`
|
||||||
# send SIGCONT to the process and check the exit value of kill.
|
# send SIGCONT to the process and check the exit value of kill.
|
||||||
# If the process still exists, the call to kill succeeds (and the signal is
|
# If the process still exists, the call to kill succeeds (and the signal is
|
||||||
# ignored).
|
# ignored).
|
||||||
|
|
||||||
kill -CONT $pid 2>kill_output 1>/dev/null; terminated=$?
|
kill -CONT $pid 2>kill_output 1>/dev/null; terminated=$?
|
||||||
# But under CYGWIN the exit status is not to be trusted.
|
# But under CYGWIN the exit status is not to be trusted.
|
||||||
if [ $terminated -eq 0 ]; then
|
if [ $terminated -eq 0 ]; then
|
||||||
|
|
@ -89,7 +95,7 @@ wait_for_process()
|
||||||
# Bash, the Bash manual states that it ignores SIGTERM.
|
# Bash, the Bash manual states that it ignores SIGTERM.
|
||||||
# However, it does not catch SIGHUP. That is why the first
|
# However, it does not catch SIGHUP. That is why the first
|
||||||
# signal send is SIGHUP.
|
# signal send is SIGHUP.
|
||||||
case "`uname`" in
|
case "`uname`" in
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
pids=`process_tree $pid`;;
|
pids=`process_tree $pid`;;
|
||||||
*) pids=$pid;;
|
*) pids=$pid;;
|
||||||
|
|
@ -99,7 +105,7 @@ wait_for_process()
|
||||||
# If SIGHUP was not enough, SIGKILL will finish the job, 10s after.
|
# If SIGHUP was not enough, SIGKILL will finish the job, 10s after.
|
||||||
for p in $pids; do kill -KILL $p 2>/dev/null; done
|
for p in $pids; do kill -KILL $p 2>/dev/null; done
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
@ -111,12 +117,17 @@ run_local_cgal_test()
|
||||||
MAKEFLAGS=
|
MAKEFLAGS=
|
||||||
export MAKEFLAGS
|
export MAKEFLAGS
|
||||||
|
|
||||||
eval ./cgal_test_with_cmake > current_compiler_output 2>&1
|
if [ -n "$TIMEOUT" ]; then
|
||||||
|
"$TIMEOUT" $(( $TIME_PERIOD * 5 )) ./cgal_test_with_cmake > current_compiler_output 2>&1
|
||||||
|
else
|
||||||
|
./cgal_test_with_cmake > current_compiler_output 2>&1
|
||||||
|
fi
|
||||||
exit_value=$?
|
exit_value=$?
|
||||||
if [ $exit_value -ne 0 ]
|
if [ $exit_value -ne 0 ]
|
||||||
then
|
then
|
||||||
printf "%s\n" "$exit_value" > test_failure
|
printf "%s\n" "$exit_value" > test_failure
|
||||||
fi
|
fi
|
||||||
|
return $exit_value
|
||||||
}
|
}
|
||||||
|
|
||||||
#test_directory <directory> <already_here>
|
#test_directory <directory> <already_here>
|
||||||
|
|
@ -126,8 +137,8 @@ test_directory()
|
||||||
{
|
{
|
||||||
cd "$CURRENTDIR"
|
cd "$CURRENTDIR"
|
||||||
if [ -d $1 ] ; then
|
if [ -d $1 ] ; then
|
||||||
echo "DIRECTORY $1:"
|
echo "DIRECTORY $1:"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "DIRECTORY $1:" >> "$ERRORFILE"
|
echo "DIRECTORY $1:" >> "$ERRORFILE"
|
||||||
echo >> "$ERRORFILE"
|
echo >> "$ERRORFILE"
|
||||||
|
|
@ -152,23 +163,39 @@ test_directory()
|
||||||
export PLATFORM TESTSUITE_CXXFLAGS TESTSUITE_LDFLAGS
|
export PLATFORM TESTSUITE_CXXFLAGS TESTSUITE_LDFLAGS
|
||||||
rm -f error.txt
|
rm -f error.txt
|
||||||
START=`date +%s`
|
START=`date +%s`
|
||||||
run_local_cgal_test &
|
|
||||||
|
|
||||||
TIME_PERIOD=1200
|
TIME_PERIOD=1200
|
||||||
if [ "$1" = "Polyhedron_Demo" ]; then
|
if [ "$1" = "Polyhedron_Demo" ]; then
|
||||||
TIME_PERIOD=2400
|
TIME_PERIOD=2400
|
||||||
fi
|
fi
|
||||||
if wait_for_process "$!" "$TIME_PERIOD" "5"
|
if [ -n "$TIMEOUT" ]; then
|
||||||
then
|
run_local_cgal_test
|
||||||
if [ -f test_failure ] ; then
|
return_code=$?
|
||||||
exit_failure=`cat test_failure`
|
if [ $return_code -eq 124 ]; then
|
||||||
rm -f test_failure
|
echo "ERROR: cgal_test_with_cmake did not finish within the time bound set" >> "$ERRORFILE"
|
||||||
echo "ERROR: cgal_test_with_cmake exited with error condition $exit_value" >> "$ERRORFILE"
|
echo "ERROR: cgal_test_with_cmake did not finish within the time bound set" >> "$ERROR_OUTPUT"
|
||||||
echo "ERROR: cgal_test_with_cmake exited with error condition $exit_value" >> "$ERROR_OUTPUT"
|
else
|
||||||
fi
|
if [ -f test_failure ] ; then
|
||||||
|
exit_failure=`cat test_failure`
|
||||||
|
rm -f test_failure
|
||||||
|
echo "ERROR: cgal_test_with_cmake exited with error condition $exit_value" >> "$ERRORFILE"
|
||||||
|
echo "ERROR: cgal_test_with_cmake exited with error condition $exit_value" >> "$ERROR_OUTPUT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "ERROR: cgal_test_with_cmake did not finish within the time bound set" >> "$ERRORFILE"
|
run_local_cgal_test &
|
||||||
echo "ERROR: cgal_test_with_cmake did not finish within the time bound set" >> "$ERROR_OUTPUT"
|
|
||||||
|
if wait_for_process "$!" "$TIME_PERIOD" "5"
|
||||||
|
then
|
||||||
|
if [ -f test_failure ] ; then
|
||||||
|
exit_failure=`cat test_failure`
|
||||||
|
rm -f test_failure
|
||||||
|
echo "ERROR: cgal_test_with_cmake exited with error condition $exit_value" >> "$ERRORFILE"
|
||||||
|
echo "ERROR: cgal_test_with_cmake exited with error condition $exit_value" >> "$ERROR_OUTPUT"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "ERROR: cgal_test_with_cmake did not finish within the time bound set" >> "$ERRORFILE"
|
||||||
|
echo "ERROR: cgal_test_with_cmake did not finish within the time bound set" >> "$ERROR_OUTPUT"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
STOP=`date +%s`
|
STOP=`date +%s`
|
||||||
DURATION=`expr "$STOP" - "$START"`
|
DURATION=`expr "$STOP" - "$START"`
|
||||||
|
|
@ -176,7 +203,7 @@ test_directory()
|
||||||
printf " # Running time: %s (seconds)\n\n" "$DURATION" >> "$ERROR_OUTPUT"
|
printf " # Running time: %s (seconds)\n\n" "$DURATION" >> "$ERROR_OUTPUT"
|
||||||
cat current_compiler_output >> "$COMPILER_OUTPUT"
|
cat current_compiler_output >> "$COMPILER_OUTPUT"
|
||||||
cat current_compiler_output
|
cat current_compiler_output
|
||||||
rm -f current_compiler_output
|
rm -f current_compiler_output
|
||||||
|
|
||||||
if [ -f error.txt ] ; then
|
if [ -f error.txt ] ; then
|
||||||
cat error.txt >> "$ERRORFILE"
|
cat error.txt >> "$ERRORFILE"
|
||||||
|
|
@ -201,18 +228,18 @@ test_directory()
|
||||||
|
|
||||||
run_testsuite()
|
run_testsuite()
|
||||||
{
|
{
|
||||||
|
|
||||||
echo "---------------------------------------------------------------"
|
echo "---------------------------------------------------------------"
|
||||||
echo "- Testing platform $PLATFORM"
|
echo "- Testing platform $PLATFORM"
|
||||||
echo "---------------------------------------------------------------"
|
echo "---------------------------------------------------------------"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "---------------------------------------------------------------" >> "$ERRORFILE"
|
echo "---------------------------------------------------------------" >> "$ERRORFILE"
|
||||||
echo "- TEST RESULTS FROM PLATFORM $PLATFORM" >> "$ERRORFILE"
|
echo "- TEST RESULTS FROM PLATFORM $PLATFORM" >> "$ERRORFILE"
|
||||||
echo "---------------------------------------------------------------" >> "$ERRORFILE"
|
echo "---------------------------------------------------------------" >> "$ERRORFILE"
|
||||||
echo >> "$ERRORFILE"
|
echo >> "$ERRORFILE"
|
||||||
|
|
||||||
case "`uname`" in
|
case "`uname`" in
|
||||||
CYGWIN*)
|
CYGWIN*)
|
||||||
PATH=`cygpath "$CGAL_DIR"`/bin:`cygpath "$CGAL_DIR"`/lib:$PATH
|
PATH=`cygpath "$CGAL_DIR"`/bin:`cygpath "$CGAL_DIR"`/lib:$PATH
|
||||||
export PATH
|
export PATH
|
||||||
|
|
@ -232,4 +259,3 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run_testsuite
|
run_testsuite
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue