Imported Upstream version 3.3.1
[platform/upstream/libarchive.git] / cat / test / CMakeLists.txt
1 ############################################
2 #
3 # How to build bsdtar_test
4 #
5 ############################################
6 IF(ENABLE_CAT AND ENABLE_TEST)
7   SET(bsdcat_test_SOURCES
8     ../../test_utils/test_utils.c
9     ../../test_utils/test_main.c
10     test.h
11     test_0.c
12     test_empty_gz.c
13     test_empty_lz4.c
14     test_empty_xz.c
15     test_error.c
16     test_error_mixed.c
17     test_expand_Z.c
18     test_expand_bz2.c
19     test_expand_gz.c
20     test_expand_lz4.c
21     test_expand_mixed.c
22     test_expand_plain.c
23     test_expand_xz.c
24     test_help.c
25     test_version.c
26   )
27
28   #
29   # Register target
30   #
31   ADD_EXECUTABLE(bsdcat_test ${bsdcat_test_SOURCES})
32   SET_PROPERTY(TARGET bsdcat_test PROPERTY COMPILE_DEFINITIONS LIST_H)
33
34   #
35   # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
36   #
37   GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
38     ${CMAKE_CURRENT_LIST_FILE} ${bsdcat_test_SOURCES})
39   SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
40     ${CMAKE_CURRENT_BINARY_DIR})
41
42   # list.h has a line DEFINE_TEST(testname) for every
43   # test.  We can use that to define the tests for cmake by
44   # defining a DEFINE_TEST macro and reading list.h in.
45   MACRO (DEFINE_TEST _testname)
46     ADD_TEST(
47       NAME bsdcat_${_testname}
48       COMMAND bsdcat_test -vv
49                           -p $<TARGET_FILE:bsdcat>
50                           -r ${CMAKE_CURRENT_SOURCE_DIR}
51                           ${_testname})
52   ENDMACRO (DEFINE_TEST _testname)
53
54   INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
55   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
56   INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
57   INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/cat/test)
58
59   # Experimental new test handling
60   ADD_CUSTOM_TARGET(run_bsdcat_test
61         COMMAND bsdcat_test -p $<TARGET_FILE:bsdcat>
62                             -r ${CMAKE_CURRENT_SOURCE_DIR}
63                             -vv)
64   ADD_DEPENDENCIES(run_bsdcat_test bsdcat)
65   ADD_DEPENDENCIES(run_all_tests run_bsdcat_test)
66
67 ENDIF(ENABLE_CAT AND ENABLE_TEST)