[CMake] [CTest] How to evaluate environment variable at test execution time in add_test command

Olivier Pierard olivier.pierard at cenaero.be
Thu Jul 22 08:31:49 EDT 2010


Dear all,

I'm stucked with the evaluation of an environment variable when running
parallel tests from ctest_test command.  This environment variable is
the 'TMPDIR' containing the machine file needed for mpiexec.

After removing the uneeded lines, my submission sequence looks like the
following:

ctest -S configXXX.cmake (submitted automatically with cron on frontal
node of our cluster)

configXXX.cmake:
- Write initial cache
- ctest_update()
- ctest_configure()
- ctest_build()
- qsub -sync y submit_ctest_test.job (SGE generates the TMPDIR
environment variable to locate the machine file)

submit_ctest_test.job (file configured by cmake in ctest_build() -
Submission of tests on computation nodes):
- ... (SGE commands)
- ctest -S submit_ctest_test.cmake(file configured by ctest in
configXXX.cmake)

submit_ctest_test.cmake:
- ctest_test()

This ctest_test command calls 'mpiexec -np 4 -machinefile $TMPDIR
executable_name args' which was build with the cmake command 'add_test'
during ctest_configure().  Variable cannot be interpreted at configure
time (with $ENV{TMPDIR}) because job is not yet submitted by SGE.

Problem is that $TMPDIR is not interpreted (I thought at first that it
was not defined as if using a new shell but it seems not to be the
case). CDash reports:
Command line: '/softs/openmpi-ib/1.2.8-1/64/gcc/4.1.2/bin/mpiexec -np 4
-machinefile $TMPDIR/machines executable_name input.dat '
Exit value: 243
Test output: Open RTE was unable to open the hostfile: $TMPDIR/machines 
Check to make sure the path and filename are correct.

Thank you very much for your help,

Olivier



More information about the CMake mailing list