1 ############################################
3 # How to build bsdtar_test
5 ############################################
6 IF(ENABLE_TAR AND ENABLE_TEST)
7 SET(bsdtar_test_SOURCES
8 ../../test_utils/test_utils.c
16 test_extract_tar_bz2.c
17 test_extract_tar_grz.c
19 test_extract_tar_lrz.c
21 test_extract_tar_lz4.c
22 test_extract_tar_lzma.c
23 test_extract_tar_lzo.c
38 test_option_b64encode.c
40 test_option_gid_gname.c
44 test_option_keep_newer_files.c
50 test_option_newer_than.c
52 test_option_older_than.c
53 test_option_passphrase.c
57 test_option_uid_uname.c
58 test_option_uuencode.c
64 test_strip_components.c
73 ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES})
74 SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H)
77 # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
79 GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
80 ${CMAKE_CURRENT_LIST_FILE} ${bsdtar_test_SOURCES})
81 SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
82 ${CMAKE_CURRENT_BINARY_DIR})
84 # list.h has a line DEFINE_TEST(testname) for every
85 # test. We can use that to define the tests for cmake by
86 # defining a DEFINE_TEST macro and reading list.h in.
87 MACRO (DEFINE_TEST _testname)
89 NAME bsdtar_${_testname}
90 COMMAND bsdtar_test -vv
91 -p $<TARGET_FILE:bsdtar>
92 -r ${CMAKE_CURRENT_SOURCE_DIR}
94 ENDMACRO (DEFINE_TEST _testname)
96 INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
97 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
98 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
100 # Experimental new test handling
101 ADD_CUSTOM_TARGET(run_bsdtar_test
102 COMMAND bsdtar_test -p $<TARGET_FILE:bsdtar>
103 -r ${CMAKE_CURRENT_SOURCE_DIR}
105 ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
106 ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)
108 ENDIF(ENABLE_TAR AND ENABLE_TEST)