Imported Upstream version 3.3.0
[platform/upstream/libarchive.git] / tar / test / CMakeLists.txt
1 ############################################
2 #
3 # How to build bsdtar_test
4 #
5 ############################################
6 IF(ENABLE_TAR AND ENABLE_TEST)
7   SET(bsdtar_test_SOURCES
8     ../../test_utils/test_utils.c
9     main.c
10     test.h
11     test_0.c
12     test_basic.c
13     test_copy.c
14     test_empty_mtree.c
15     test_extract_tar_Z.c
16     test_extract_tar_bz2.c
17     test_extract_tar_grz.c
18     test_extract_tar_gz.c
19     test_extract_tar_lrz.c
20     test_extract_tar_lz.c
21     test_extract_tar_lz4.c
22     test_extract_tar_lzma.c
23     test_extract_tar_lzo.c
24     test_extract_tar_xz.c
25     test_format_newc.c
26     test_help.c
27     test_leading_slash.c
28     test_missing_file.c
29     test_option_C_upper.c
30     test_option_H_upper.c
31     test_option_L_upper.c
32     test_option_O_upper.c
33     test_option_T_upper.c
34     test_option_U_upper.c
35     test_option_X_upper.c
36     test_option_a.c
37     test_option_b.c
38     test_option_b64encode.c
39     test_option_exclude.c
40     test_option_gid_gname.c
41     test_option_grzip.c
42     test_option_j.c
43     test_option_k.c
44     test_option_keep_newer_files.c
45     test_option_lrzip.c
46     test_option_lz4.c
47     test_option_lzma.c
48     test_option_lzop.c
49     test_option_n.c
50     test_option_newer_than.c
51     test_option_nodump.c
52     test_option_older_than.c
53     test_option_passphrase.c
54     test_option_q.c
55     test_option_r.c
56     test_option_s.c
57     test_option_uid_uname.c
58     test_option_uuencode.c
59     test_option_xz.c
60     test_option_z.c
61     test_patterns.c
62     test_print_longpath.c
63     test_stdio.c
64     test_strip_components.c
65     test_symlink_dir.c
66     test_version.c
67     test_windows.c
68   )
69
70   #
71   # Register target
72   #
73   ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES})
74   SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H)
75
76   #
77   # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
78   #
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})
83
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)
88     ADD_TEST(
89       NAME bsdtar_${_testname}
90       COMMAND bsdtar_test -vv
91                           -p $<TARGET_FILE:bsdtar>
92                           -r ${CMAKE_CURRENT_SOURCE_DIR}
93                           ${_testname})
94   ENDMACRO (DEFINE_TEST _testname)
95
96   INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
97   INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
98   INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/test_utils)
99
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}
104                             -vv)
105   ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
106   ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)
107
108 ENDIF(ENABLE_TAR AND ENABLE_TEST)