summaryrefslogtreecommitdiff
path: root/test/CMakeLists.txt
blob: 3b2c39bd6bf9e5e0aedadf5b7ee617171820a107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright © 2004-2013  Roger Leigh <rleigh@debian.org>
#
# schroot is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# schroot is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
#
#####################################################################

include_directories(${GTEST_INCLUDE_DIR}
                    ${PROJECT_SOURCE_DIR}/bin)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sbuild)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sbuild/chroot)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin-common)

set(srcdir ${PROJECT_SOURCE_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup-test-data
               ${CMAKE_CURRENT_BINARY_DIR}/setup-test-data)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cleanup-test-data
               ${CMAKE_CURRENT_BINARY_DIR}/cleanup-test-data)

if(BUILD_BLOCKDEV)
  set(sbuild_chroot_blockdev_sources
      sbuild/chroot/block-device.cc)
endif(BUILD_BLOCKDEV)

if(BUILD_LOOPBACK)
  set(sbuild_chroot_loopback_sources
      sbuild/chroot/loopback.cc)
endif(BUILD_LOOPBACK)

if(BUILD_LVMSNAP)
  set(sbuild_chroot_lvmsnap_sources
      sbuild/chroot/lvm-snapshot.cc)
endif(BUILD_LVMSNAP)

if(BUILD_BTRFSSNAP)
  set(sbuild_chroot_btrfssnap_sources
      sbuild/chroot/btrfs-snapshot.cc)
endif(BUILD_BTRFSSNAP)

if(BUILD_PERSONALITY)
  set(sbuild_personality_sources
    sbuild/personality.cc)
endif(BUILD_PERSONALITY)

set(sbuild_chroot_chroot_sources
    sbuild/chroot/chroot.h
    sbuild/chroot/chroot.cc
    sbuild/chroot/plain.cc
    sbuild/chroot/custom.cc
    sbuild/chroot/file.cc
    sbuild/chroot/directory.cc
    ${sbuild_chroot_blockdev_sources}
    ${sbuild_chroot_lvmsnap_sources}
    ${sbuild_chroot_btrfssnap_sources}
    ${sbuild_chroot_loopback_sources}
    sbuild/chroot/facet/userdata.cc)

if (BUILD_TESTS)
  add_test(NAME setup-test-data
           WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
           COMMAND ${CMAKE_CURRENT_BINARY_DIR}/setup-test-data)
endif (BUILD_TESTS)

if (BUILD_TESTS)
  add_executable(sbuild/chroot/chroot ${sbuild_chroot_chroot_sources})
  target_link_libraries(sbuild/chroot/chroot sbuild testmain)
  add_test(sbuild/chroot/chroot sbuild/chroot/chroot)
endif (BUILD_TESTS)

set(sbuild_chroot_config_sources
    sbuild/chroot/config.cc)

if (BUILD_TESTS)
  add_executable(sbuild/chroot/config ${sbuild_chroot_config_sources})
  target_link_libraries(sbuild/chroot/config sbuild testmain)
  add_test(sbuild/chroot/config sbuild/chroot/config)
endif (BUILD_TESTS)

set(sbuild_standard_sources
    sbuild/environment.cc
    sbuild/log.cc
    sbuild/nostream.cc
    sbuild/parse-value.cc
    ${sbuild_personality_sources}
    sbuild/regex.cc
    sbuild/util.cc)

if (BUILD_TESTS)
  add_executable(sbuild/standard ${sbuild_standard_sources})
  target_link_libraries(sbuild/standard sbuild testmain)
  add_test(sbuild/standard sbuild/standard)
endif (BUILD_TESTS)

set(sbuild_keyfile_sources
    sbuild/keyfile.cc)

if (BUILD_TESTS)
  add_executable(sbuild/keyfile ${sbuild_keyfile_sources})
  target_link_libraries(sbuild/keyfile sbuild testmain)
  add_test(sbuild/keyfile sbuild/keyfile)
endif (BUILD_TESTS)

set(sbuild_lock_sources
    sbuild/lock.cc)

if (BUILD_TESTS)
  add_executable(sbuild/lock ${sbuild_lock_sources})
  target_link_libraries(sbuild/lock sbuild testmain)
  # lock is excluded, because it is timing dependent and can fail
  # randomly on slow or heavily-loaded systems.
endif (BUILD_TESTS)

set(sbuild_run_parts_sources
    sbuild/run-parts.cc)

if (BUILD_TESTS)
  add_executable(sbuild/run-parts ${sbuild_run_parts_sources})
  target_link_libraries(sbuild/run-parts sbuild testmain)
  add_test(sbuild/run-parts sbuild/run-parts)
endif (BUILD_TESTS)

set(bin_common_option_action_sources
    bin-common/option-action.cc)

if (BUILD_TESTS)
  add_executable(bin-common/option-action ${bin_common_option_action_sources})
  target_link_libraries(bin-common/option-action bin-common testmain)
  add_test(bin-common/option-action bin-common/option-action)
endif (BUILD_TESTS)

if (BUILD_TESTS)
  add_test(NAME cleanup-test-data
           WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
           COMMAND ${CMAKE_CURRENT_BINARY_DIR}/cleanup-test-data)
endif (BUILD_TESTS)