testHarness: modifications for running the tests in parallel

This commit is contained in:
Martin Beaudoin 2015-08-25 22:57:42 -04:00 committed by Hrvoje Jasak
parent 3fa19fc2d2
commit 7004961828
4 changed files with 52 additions and 14 deletions

View file

@ -40,6 +40,13 @@ PROJECT(foam-extend-3.2)
#-----------------------------------------------------------------------------
# Initialization of CTest specific variables
#
## Run ctest in parallel if environment variable WM_NCOMPPROCS is set
IF (NOT $ENV{WM_NCOMPPROCS} STREQUAL "")
# Will run ctest in parallel over $WM_NCOMPPROCS processors
set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} --parallel $ENV{WM_NCOMPPROCS})
MESSAGE("Running tests in parallel using $ENV{WM_NCOMPPROCS} processors")
ENDIF ()
# Initialize the site name
@ -272,11 +279,6 @@ IF(BUILD_TESTING)
#
INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
# Add a dummy test (/bin/true, just for debugging)
ADD_TEST(
foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
)
IF(RUN_FROM_ONE_TIMESTEP)
# Modify the cases controlDict file in order to run for only one time step
MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")

View file

@ -89,7 +89,27 @@ runParallel ()
compileApplication ()
{
echo "Compiling $1 application"
wmake $1
if ! [ -x "$(command -v lockfile)" ]; then
# Missing lockfile command. Tough luck.
# Without a proper lockfile command, we cannot properly serialize
# wmake commands. Some tutorials might fail when many are run
# simultaneously, and some of them depend on the compilation of a
# common application.
echo "Warning: Missing lockfile command. Your compilation may fail."
wmake $1
else
# We make sure to serialize the compilation in case we are called simultaneously
lockFilename="./compileApplication.lock"
if [ -d "$1" ]; then
lockFilename=$1/$lockFilename
fi
# We wait for the lock release at most 10 x 10 seconds = 100 seconds
lockfile -10 -r 10 $lockFilename
wmake $1
rm -rf $lockFilename
fi
}
compileLibrary ()

View file

@ -40,6 +40,13 @@ PROJECT(foam-extend-3.2)
#-----------------------------------------------------------------------------
# Initialization of CTest specific variables
#
## Run ctest in parallel if environment variable WM_NCOMPPROCS is set
IF (NOT $ENV{WM_NCOMPPROCS} STREQUAL "")
# Will run ctest in parallel over $WM_NCOMPPROCS processors
set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} --parallel $ENV{WM_NCOMPPROCS})
MESSAGE("Running tests in parallel using $ENV{WM_NCOMPPROCS} processors")
ENDIF ()
# Initialize the site name
@ -272,11 +279,6 @@ IF(BUILD_TESTING)
#
INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
# Add a dummy test (/bin/true, just for debugging)
ADD_TEST(
foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test true
)
IF(RUN_FROM_ONE_TIMESTEP)
# Modify the cases controlDict file in order to run for only one time step
MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")

View file

@ -64,8 +64,17 @@ EXECUTE_PROCESS(
#
#First, add a global cleanup of the cases
SET(testId "Allclean_cases${testIdSuffix}")
ADD_TEST(${testId} bash -c "cd ${TEST_CASE_DIR}; ./Allclean")
#This will always run and complete first, even in paralel
SET(cleanCasesTestId "Allclean_cases${testIdSuffix}")
ADD_TEST(${cleanCasesTestId} bash -c "cd ${TEST_CASE_DIR}; ./Allclean")
# Add a dummy test (/bin/true, just for debugging)
SET(dummyTestId "foam-extend-$ENV{WM_PROJECT_VERSION}_Dummy_Test")
ADD_TEST(${dummyTestId} true)
# Add a dependency on the global clean-up target, even for the dummy test
SET_TESTS_PROPERTIES(${dummyTestId} PROPERTIES DEPENDS ${cleanCasesTestId})
# Next, recurse through the test cases root directory,
# find all the Allrun files, and add them as a new CTest test case
@ -90,6 +99,11 @@ FOREACH(caseWithAllrun ${listofCasesWithAllrun})
# Add the test to the test harness
MESSAGE("Adding test: ${testId}")
ADD_TEST(${testId} bash -c "cd ${thisCasePath}; ./Allrun")
# Add a dependency on the global clean-up target
# When running in parallel, you need to wait for the cleanup to finish first
SET_TESTS_PROPERTIES(${testId} PROPERTIES DEPENDS ${cleanCasesTestId})
# Use this following entry instead for testing purpose
#ADD_TEST(${testId} bash -c "cd ${thisCasePath}; true")