summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake
blob: ef79dce992b9d6b472569d83b3a26c299dad4c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function(setup_resource_tests)
  if(CTEST_RESOURCE_ALLOC_ENABLED)
    add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E rm -f "${CMAKE_BINARY_DIR}/ctresalloc.log")
  endif()
endfunction()

function(add_resource_test name sleep_time proc)
  if(CTEST_RESOURCE_ALLOC_ENABLED)
    add_test(NAME "${name}" COMMAND "${CTRESALLOC_COMMAND}" write "${CMAKE_BINARY_DIR}/ctresalloc.log" "${name}" "${sleep_time}" "${proc}")
    set_property(TEST "${name}" PROPERTY DEPENDS ResourceSetup)
  else()
    add_test(NAME "${name}" COMMAND "${CTRESALLOC_COMMAND}" write "${CMAKE_BINARY_DIR}/ctresalloc.log" "${name}" "${sleep_time}")
  endif()
  set_property(TEST "${name}" PROPERTY RESOURCE_GROUPS "${proc}")
  list(APPEND RESOURCE_TESTS "${name}")
  set(RESOURCE_TESTS "${RESOURCE_TESTS}" PARENT_SCOPE)
endfunction()

function(cleanup_resource_tests)
  if(CTEST_RESOURCE_ALLOC_ENABLED)
    file(WRITE "${CMAKE_BINARY_DIR}/restests.txt" "${RESOURCE_TESTS}")
  endif()
endfunction()