[CMake] CTest fails to find test command : bug in use of FileExists() + suggested fix.

Richard Offer richard at whitequeen.com
Sat Aug 14 17:59:07 EDT 2010


One of my test cases needs sudo to run (its listening on privileged ports).


If I add

  ADD_TEST( SERVER /usr/bin/sudo
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Server${SUFFIX} --daemon )

CMake complains that it can¹t find sudo.

[ d042 ] make test
Running tests...
Test project /Users/richard/BUILD
    Start 1: SERVER
Could not find executable /usr/bin/sudo
Looked in the following places:
/usr/bin/sudo
/usr/bin/sudo
/usr/bin/Release/sudo
/usr/bin/Release/sudo
/usr/bin/Debug/sudo
/usr/bin/Debug/sudo
...


However (on OS X and Linux) sudo is not readable (although it is
executable).

In Source/CTest/cmCTestTestHandler.cxx (line 1494) you¹re using
cmSystemTools::FileExists(attempted[ai].c_str() ) to test for the presence
of the testcase.


Looking in Source/kwsys/SystemTools.cxx line 919 shows that on non-Windows
systems its using access(path, R_OK), which checks to see if the path has
read permissions.


Might I suggest replacing the call to FileExists()
Source/CTest/cmCTestTestHandler.cxx  in with a new test  -
FileIsExecutable() since the only requirement is to be able to execute the
program, not read it.


Thanks,


Richard.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100814/03b178c5/attachment.htm>


More information about the CMake mailing list