gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Support tests with valgrind (#416)
0 1 0
default
1 file changed with 11 insertions and 1 deletions:
↑ Collapse diff ↑
Ignore white space 256 line context
1 1
INCLUDE_DIRECTORIES(
2 2
  ${PROJECT_SOURCE_DIR}
3 3
  ${PROJECT_BINARY_DIR}
4 4
)
5 5

	
6 6
LINK_DIRECTORIES(
7 7
  ${PROJECT_BINARY_DIR}/lemon
8 8
)
9 9

	
10
SET(TEST_WITH_VALGRIND "NO" CACHE STRING
11
  "Run the test with valgrind (YES/NO).")
12
SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.")
13

	
10 14
SET(TESTS
11 15
  adaptors_test
12 16
  bfs_test
13 17
  circulation_test
14 18
  connectivity_test
15 19
  counter_test
16 20
  dfs_test
17 21
  digraph_test
18 22
  dijkstra_test
19 23
  dim_test
20 24
  edge_set_test
21 25
  error_test
22 26
  euler_test
23 27
  gomory_hu_test
24 28
  graph_copy_test
25 29
  graph_test
26 30
  graph_utils_test
27 31
  hao_orlin_test
28 32
  heap_test
29 33
  kruskal_test
30 34
  maps_test
31 35
  matching_test
32 36
  min_cost_arborescence_test
33 37
  min_cost_flow_test
34 38
  path_test
35 39
  preflow_test
36 40
  radix_sort_test
37 41
  random_test
38 42
  suurballe_test
39 43
  time_measure_test
40 44
  unionfind_test
41 45
)
42 46

	
43 47
IF(LEMON_HAVE_LP)
44 48
  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
45 49
    ADD_EXECUTABLE(lp_test lp_test.cc)
46 50
  ELSE()
47 51
    ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc)
48 52
  ENDIF()
49 53

	
50 54
  SET(LP_TEST_LIBS lemon)
51 55

	
52 56
  IF(LEMON_HAVE_GLPK)
53 57
    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
54 58
  ENDIF()
55 59
  IF(LEMON_HAVE_CPLEX)
56 60
    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
57 61
  ENDIF()
58 62
  IF(LEMON_HAVE_CLP)
59 63
    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES})
60 64
  ENDIF()
61 65

	
62 66
  TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
63 67
  ADD_TEST(lp_test lp_test)
64 68

	
65 69
  IF(WIN32 AND LEMON_HAVE_GLPK)
66 70
    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
67 71
    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
68 72
    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
69 73
      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
70 74
      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
71 75
      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
72 76
    )
73 77
  ENDIF()
74 78

	
75 79
  IF(WIN32 AND LEMON_HAVE_CPLEX)
76 80
    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
77 81
    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
78 82
    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
79 83
      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
80 84
    )
81 85
  ENDIF()
82 86
ENDIF()
83 87

	
84 88
IF(LEMON_HAVE_MIP)
85 89
  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
86 90
    ADD_EXECUTABLE(mip_test mip_test.cc)
87 91
  ELSE()
88 92
    ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc)
89 93
  ENDIF()
90 94

	
91 95
  SET(MIP_TEST_LIBS lemon)
92 96

	
93 97
  IF(LEMON_HAVE_GLPK)
94 98
    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
95 99
  ENDIF()
96 100
  IF(LEMON_HAVE_CPLEX)
97 101
    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
98 102
  ENDIF()
99 103
  IF(LEMON_HAVE_CBC)
100 104
    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES})
101 105
  ENDIF()
102 106

	
103 107
  TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
104 108
  ADD_TEST(mip_test mip_test)
105 109

	
106 110
  IF(WIN32 AND LEMON_HAVE_GLPK)
107 111
    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
108 112
    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
109 113
    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
110 114
      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
111 115
      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
112 116
      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
113 117
    )
114 118
  ENDIF()
115 119

	
116 120
  IF(WIN32 AND LEMON_HAVE_CPLEX)
117 121
    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
118 122
    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
119 123
    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
120 124
      COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
121 125
    )
122 126
  ENDIF()
123 127
ENDIF()
124 128

	
125 129
FOREACH(TEST_NAME ${TESTS})
126 130
  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
127 131
    ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
128 132
  ELSE()
129 133
    ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
130 134
  ENDIF()
131 135
  TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
132
  ADD_TEST(${TEST_NAME} ${TEST_NAME})
136
    IF(TEST_WITH_VALGRIND)
137
      ADD_TEST(${TEST_NAME}
138
        valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
139
        ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} )
140
    ELSE()
141
      ADD_TEST(${TEST_NAME} ${TEST_NAME})
142
    ENDIF()
133 143
  ADD_DEPENDENCIES(check ${TEST_NAME})
134 144
ENDFOREACH()
0 comments (0 inline)