CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #
  2. # SPDX-License-Identifier: BSD-2-Clause
  3. #
  4. ############################################
  5. #
  6. # How to build bsdtar_test
  7. #
  8. ############################################
  9. IF(ENABLE_CAT AND ENABLE_TEST)
  10. SET(bsdcat_test_SOURCES
  11. ../../test_utils/test_utils.c
  12. ../../test_utils/test_main.c
  13. test.h
  14. test_0.c
  15. test_empty_gz.c
  16. test_empty_lz4.c
  17. test_empty_xz.c
  18. test_empty_zstd.c
  19. test_error.c
  20. test_error_mixed.c
  21. test_expand_Z.c
  22. test_expand_bz2.c
  23. test_expand_gz.c
  24. test_expand_lz4.c
  25. test_expand_mixed.c
  26. test_expand_plain.c
  27. test_expand_xz.c
  28. test_expand_zstd.c
  29. test_help.c
  30. test_stdin.c
  31. test_version.c
  32. )
  33. #
  34. # Register target
  35. #
  36. ADD_EXECUTABLE(bsdcat_test ${bsdcat_test_SOURCES})
  37. IF(ENABLE_ACL)
  38. SET(TEST_ACL_LIBS "")
  39. IF(HAVE_LIBACL)
  40. LIST(APPEND TEST_ACL_LIBS ${ACL_LIBRARY})
  41. ENDIF(HAVE_LIBACL)
  42. IF(HAVE_LIBRICHACL)
  43. LIST(APPEND TEST_ACL_LIBS ${RICHACL_LIBRARY})
  44. ENDIF(HAVE_LIBRICHACL)
  45. TARGET_LINK_LIBRARIES(bsdcat_test ${TEST_ACL_LIBS})
  46. ENDIF(ENABLE_ACL)
  47. SET_PROPERTY(TARGET bsdcat_test PROPERTY COMPILE_DEFINITIONS LIST_H)
  48. #
  49. # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
  50. #
  51. GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
  52. ${CMAKE_CURRENT_LIST_FILE} ${bsdcat_test_SOURCES})
  53. SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
  54. ${CMAKE_CURRENT_BINARY_DIR})
  55. # list.h has a line DEFINE_TEST(testname) for every
  56. # test. We can use that to define the tests for cmake by
  57. # defining a DEFINE_TEST macro and reading list.h in.
  58. MACRO (DEFINE_TEST _testname)
  59. ADD_TEST(
  60. NAME bsdcat_${_testname}
  61. COMMAND bsdcat_test -vv
  62. -p $<TARGET_FILE:bsdcat>
  63. -r ${CMAKE_CURRENT_SOURCE_DIR}
  64. -s
  65. ${_testname})
  66. SET_TESTS_PROPERTIES(bsdcat_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
  67. ENDMACRO (DEFINE_TEST _testname)
  68. INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
  69. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
  70. INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
  71. INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/cat/test)
  72. # Experimental new test handling
  73. ADD_CUSTOM_TARGET(run_bsdcat_test
  74. COMMAND bsdcat_test -p $<TARGET_FILE:bsdcat>
  75. -r ${CMAKE_CURRENT_SOURCE_DIR}
  76. -vv)
  77. ADD_DEPENDENCIES(run_bsdcat_test bsdcat)
  78. ADD_DEPENDENCIES(run_all_tests run_bsdcat_test)
  79. ENDIF(ENABLE_CAT AND ENABLE_TEST)