testHarness: modifications for running the tests in parallel
This commit is contained in:
parent
3fa19fc2d2
commit
7004961828
4 changed files with 52 additions and 14 deletions
|
@ -40,6 +40,13 @@ PROJECT(foam-extend-3.2)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Initialization of CTest specific variables
|
# 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
|
# Initialize the site name
|
||||||
|
|
||||||
|
@ -272,11 +279,6 @@ IF(BUILD_TESTING)
|
||||||
#
|
#
|
||||||
INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
|
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)
|
IF(RUN_FROM_ONE_TIMESTEP)
|
||||||
# Modify the cases controlDict file in order to run for only one time step
|
# 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}")
|
MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
|
||||||
|
|
|
@ -89,7 +89,27 @@ runParallel ()
|
||||||
compileApplication ()
|
compileApplication ()
|
||||||
{
|
{
|
||||||
echo "Compiling $1 application"
|
echo "Compiling $1 application"
|
||||||
|
|
||||||
|
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
|
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 ()
|
compileLibrary ()
|
||||||
|
|
|
@ -40,6 +40,13 @@ PROJECT(foam-extend-3.2)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Initialization of CTest specific variables
|
# 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
|
# Initialize the site name
|
||||||
|
|
||||||
|
@ -272,11 +279,6 @@ IF(BUILD_TESTING)
|
||||||
#
|
#
|
||||||
INCLUDE($ENV{FOAM_TEST_HARNESS_DIR}/CMakeFiles/FOAM_Tutorials.cmake)
|
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)
|
IF(RUN_FROM_ONE_TIMESTEP)
|
||||||
# Modify the cases controlDict file in order to run for only one time step
|
# 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}")
|
MESSAGE("${testRunTimeDirectory}: Modifying the controlDict files for running only one time step in directory: ${TEST_CASE_DIR}")
|
||||||
|
|
|
@ -64,8 +64,17 @@ EXECUTE_PROCESS(
|
||||||
#
|
#
|
||||||
|
|
||||||
#First, add a global cleanup of the cases
|
#First, add a global cleanup of the cases
|
||||||
SET(testId "Allclean_cases${testIdSuffix}")
|
#This will always run and complete first, even in paralel
|
||||||
ADD_TEST(${testId} bash -c "cd ${TEST_CASE_DIR}; ./Allclean")
|
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,
|
# Next, recurse through the test cases root directory,
|
||||||
# find all the Allrun files, and add them as a new CTest test case
|
# 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
|
# Add the test to the test harness
|
||||||
MESSAGE("Adding test: ${testId}")
|
MESSAGE("Adding test: ${testId}")
|
||||||
ADD_TEST(${testId} bash -c "cd ${thisCasePath}; ./Allrun")
|
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
|
# Use this following entry instead for testing purpose
|
||||||
#ADD_TEST(${testId} bash -c "cd ${thisCasePath}; true")
|
#ADD_TEST(${testId} bash -c "cd ${thisCasePath}; true")
|
||||||
|
|
||||||
|
|
Reference in a new issue