test.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. cmake_minimum_required(VERSION 2.8.12)
  2. set(CTEST_RUN_CURRENT_SCRIPT 0)
  3. set(CTEST_SOURCE_DIRECTORY "/opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Tool/cmake-3.11.0/Tests/CTestTestEmptyBinaryDirectory")
  4. set(CTEST_BINARY_DIRECTORY "/opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Tool/cmake-3.11.0/Tests/CTestTestEmptyBinaryDirectory")
  5. # make sure ctest does not remove directories without a CMakeCache.txt in it
  6. set(EMPTY_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/empty_binary_dir")
  7. file(MAKE_DIRECTORY "${EMPTY_BINARY_DIR}")
  8. if(NOT EXISTS "${EMPTY_BINARY_DIR}"
  9. OR EXISTS "${EMPTY_BINARY_DIR}/CMakeCache.txt")
  10. message(FATAL_ERROR "empty_binary_dir precondition failed")
  11. endif()
  12. ctest_empty_binary_directory("${EMPTY_BINARY_DIR}")
  13. if(NOT EXISTS "${EMPTY_BINARY_DIR}")
  14. message(FATAL_ERROR "empty_binary_dir should not have been removed")
  15. endif()
  16. # make sure ctest does remove directories with a CMakeCache.txt
  17. set(VALID_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/valid_binary_dir")
  18. file(MAKE_DIRECTORY "${VALID_BINARY_DIR}")
  19. file(WRITE "${VALID_BINARY_DIR}/CMakeCache.txt")
  20. if(NOT EXISTS "${VALID_BINARY_DIR}"
  21. OR NOT EXISTS "${VALID_BINARY_DIR}/CMakeCache.txt")
  22. message(FATAL_ERROR "valid_binary_dir precondition failed")
  23. endif()
  24. ctest_empty_binary_directory("${VALID_BINARY_DIR}")
  25. if(EXISTS "${VALID_BINARY_DIR}")
  26. message(FATAL_ERROR "valid_binary_dir should have been removed")
  27. endif()
  28. # make sure ctest removes build directories recursively
  29. set(DEEP_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/deep_binary_dir")
  30. file(MAKE_DIRECTORY "${DEEP_BINARY_DIR}")
  31. file(WRITE "${DEEP_BINARY_DIR}/CMakeCache.txt")
  32. foreach(SUBDIR A Z A/A A/Z Z/A Z/Z)
  33. set(FULL_SUBDIR "${DEEP_BINARY_DIR}/${SUBDIR}")
  34. file(MAKE_DIRECTORY "${FULL_SUBDIR}")
  35. foreach(SUBFILE A.cpp Z.bat)
  36. set(FULL_SUBFILE "${FULL_SUBDIR}/${SUBFILE}")
  37. file(WRITE "${FULL_SUBFILE}" "I am '${FULL_SUBFILE}'")
  38. endforeach()
  39. endforeach()
  40. if(NOT EXISTS "${DEEP_BINARY_DIR}"
  41. OR NOT EXISTS "${DEEP_BINARY_DIR}/CMakeCache.txt"
  42. OR NOT EXISTS "${DEEP_BINARY_DIR}/Z/A/Z.bat")
  43. message(FATAL_ERROR "deep_binary_dir precondition failed")
  44. endif()
  45. ctest_empty_binary_directory("${DEEP_BINARY_DIR}")
  46. if(EXISTS "${DEEP_BINARY_DIR}")
  47. message(FATAL_ERROR "deep_binary_dir should have been removed")
  48. endif()
  49. message("TEST_SUCCESS")