You are not logged in.

#1 2015-12-24 14:12:05

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 617
Website

[SOLVED] CTest fails but running cmake manually passes test.

I'm having a problem with ctest where if my test keeps failing but if I run the test command it uses manually (whatever ctest --verbose outputs) it passes.

CMakeLists.txt:

add_executable(NonlinearSystems NonlinearSystems.cpp)

enable_testing()
add_test(NonlinearSystems ${CMAKE_COMMAND}
  -Dtest_cmd="${CMAKE_BINARY_DIR}/UnitTests/bin/NonlinearSystems"
  -Doutput_blessed="${CMAKE_SOURCE_DIR}/UnitTests/output/NonlinearSystems.output"
  -Doutput_test="${CMAKE_BINARY_DIR}/UnitTests/NonlinearSystems.output"
  -P ${CMAKE_SOURCE_DIR}/UnitTests/run_test.cmake
  )

run_test.cmake:

if( NOT test_cmd )
  message( FATAL_ERROR "Variable test_cmd not defined" )
endif( NOT test_cmd )
# output_blessed contains the name of the "blessed" output file
if( NOT output_blessed )
    message( FATAL_ERROR "Variable output_blessed not defined" )
endif( NOT output_blessed )
# output_test contains the name of the output file the test_cmd will produce
if( NOT output_test )
   message( FATAL_ERROR "Variable output_test not defined" )
endif( NOT output_test )

execute_process(
  COMMAND ${test_cmd}
  OUTPUT_FILE ${output_test}
  )

execute_process (
  COMMAND ${CMAKE_COMMAND} -E compare_files ${output_blessed} ${output_test}
  RESULT_VARIABLE test_failure
  )

if( test_failure )
   message( SEND_ERROR "${output_test} does not match ${output_blessed}" )
endif( test_failure )

ctest --verbose:

UpdateCTestConfiguration  from :/home/seshu/dev/NumericalMethods/UnitTests/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/seshu/dev/NumericalMethods/UnitTests/DartConfiguration.tcl
Test project /home/seshu/dev/NumericalMethods/UnitTests
Constructing a list of tests
Done constructing a list of tests
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: NonlinearSystems

1: Test command: /usr/bin/cmake "-Dtest_cmd="/home/seshu/dev/NumericalMethods/UnitTests/bin/NonlinearSystems"" "-Doutput_blessed="/home/seshu/dev/NumericalMethods/UnitTests/output/NonlinearSystems.output"" "-Doutput_test="/home/seshu/dev/NumericalMethods/UnitTests/NonlinearSystems.output"" "-P" "/home/seshu/dev/NumericalMethods/UnitTests/run_test.cmake"
1: Test timeout computed to be: 9.99988e+06
1: Files ""/home/seshu/dev/NumericalMethods/UnitTests/output/NonlinearSystems.output"" to ""/home/seshu/dev/NumericalMethods/UnitTests/NonlinearSystems.output"" are different.
1: CMake Error at run_test.cmake:24 (message):
1:   "/home/seshu/dev/NumericalMethods/UnitTests/NonlinearSystems.output" does
1:   not match
1:   "/home/seshu/dev/NumericalMethods/UnitTests/output/NonlinearSystems.output"
1: 
1: 
1/1 Test #1: NonlinearSystems .................***Failed    0.01 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.02 sec

The following tests FAILED:
          1 - NonlinearSystems (Failed)
Errors while running CTest

Last edited by syamajala (2015-12-24 15:14:05)

Offline

#2 2015-12-24 15:13:49

syamajala
Member
From: here, there, everywhere
Registered: 2005-01-25
Posts: 617
Website

Re: [SOLVED] CTest fails but running cmake manually passes test.

It was the quotes in my CMakeLists.txt:

add_executable(NonlinearSystems NonlinearSystems.cpp)

enable_testing()
add_test(NonlinearSystems ${CMAKE_COMMAND}
  -Dtest_cmd=${CMAKE_BINARY_DIR}/UnitTests/bin/NonlinearSystems
  -Doutput_blessed=${CMAKE_SOURCE_DIR}/UnitTests/output/NonlinearSystems.output
  -Doutput_test=${CMAKE_BINARY_DIR}/UnitTests/NonlinearSystems.output
  -P ${CMAKE_SOURCE_DIR}/UnitTests/run_test.cmake
  )

Offline

Board footer

Powered by FluxBB