Support tests with valgrind (#416)
authorAlpar Juttner <alpar@cs.elte.hu>
Mon, 14 Mar 2011 08:56:54 +0100
changeset 93366156a3498ea
parent 929 d3b041452dd8
child 939 78b9fb1f4454
child 944 b4af20d02ae0
Support tests with valgrind (#416)
test/CMakeLists.txt
     1.1 --- a/test/CMakeLists.txt	Fri Mar 04 10:31:12 2011 +0100
     1.2 +++ b/test/CMakeLists.txt	Mon Mar 14 08:56:54 2011 +0100
     1.3 @@ -7,6 +7,10 @@
     1.4    ${PROJECT_BINARY_DIR}/lemon
     1.5  )
     1.6  
     1.7 +SET(TEST_WITH_VALGRIND "NO" CACHE STRING
     1.8 +  "Run the test with valgrind (YES/NO).")
     1.9 +SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.")
    1.10 +
    1.11  SET(TESTS
    1.12    adaptors_test
    1.13    bfs_test
    1.14 @@ -129,6 +133,12 @@
    1.15      ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
    1.16    ENDIF()
    1.17    TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
    1.18 -  ADD_TEST(${TEST_NAME} ${TEST_NAME})
    1.19 +    IF(TEST_WITH_VALGRIND)
    1.20 +      ADD_TEST(${TEST_NAME}
    1.21 +        valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
    1.22 +        ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} )
    1.23 +    ELSE()
    1.24 +      ADD_TEST(${TEST_NAME} ${TEST_NAME})
    1.25 +    ENDIF()
    1.26    ADD_DEPENDENCIES(check ${TEST_NAME})
    1.27  ENDFOREACH()