|
1 | 1 | cmake_minimum_required(VERSION 3.31.6) |
| 2 | +# |
| 3 | +# builds unit tests |
| 4 | +# |
2 | 5 |
|
3 | 6 | project(unittests C CXX) |
4 | 7 | set(CMAKE_CXX_STANDARD 20) |
@@ -48,115 +51,119 @@ endif() |
48 | 51 |
|
49 | 52 | set(CMAKE_CXX_FLAGS "-g -O0 -std=c++20 -Wall -Wextra -Wno-frame-address -Wno-unused-function -Wno-int-to-pointer-cast -D__id_t_defined -DUNITTESTS -DURI_THROW_ON_ERROR ${NO_INFO} ${NO_DEBUG} -DGSL_THROW_ON_CONTRACT_VIOLATION -Dlest_FEATURE_AUTO_REGISTER=1 -DHAVE_LEST_MAIN -DPAGE_SIZE=4096") |
50 | 53 |
|
51 | | -set(TEST ${CMAKE_CURRENT_SOURCE_DIR}) |
| 54 | +set(TESTS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) |
| 55 | +set(TESTS_DEPS ${TESTS_ROOT}/misc) |
| 56 | +set(UNIT_TESTS ${TESTS_ROOT}/unit) |
| 57 | +set(INCLUDEOS ${TESTS_ROOT}/..) |
52 | 58 |
|
53 | 59 | include_directories( |
54 | | - ${TEST}/lest_util |
55 | | - ${TEST}/../api |
56 | | - ${TEST}/../src/include |
| 60 | + ${TESTS_DEPS}/lest_util |
| 61 | + ${INCLUDEOS}/api |
| 62 | + ${INCLUDEOS}/src/include |
57 | 63 | #TODO move to the right place |
58 | | - ${TEST}/../lib/LiveUpdate/include |
| 64 | + ${INCLUDEOS}/lib/LiveUpdate/include |
59 | 65 | ) |
60 | 66 |
|
61 | 67 | set(LEST_UTIL |
62 | | - ${TEST}/lest_util/lestmain.cxx |
63 | | - ${TEST}/lest_util/os_mock.cpp |
64 | | - ${TEST}/lest_util/mock_fs.cpp |
65 | | - ${TEST}/lest_util/random.cpp |
| 68 | + ${TESTS_DEPS}/lest_util/lestmain.cxx |
| 69 | + ${TESTS_DEPS}/lest_util/os_mock.cpp |
| 70 | + ${TESTS_DEPS}/lest_util/mock_fs.cpp |
| 71 | + ${TESTS_DEPS}/lest_util/random.cpp |
66 | 72 | ) |
67 | 73 |
|
| 74 | +# TODO: maybe just use `*.cpp *.hpp` globs here? |
68 | 75 | set(TEST_SOURCES |
69 | | - ${TEST}/fs/unit/memdisk_test.cpp |
70 | | - ${TEST}/fs/unit/path_test.cpp |
71 | | - ${TEST}/fs/unit/vfs_test.cpp |
72 | | - ${TEST}/fs/unit/unit_fs.cpp |
73 | | - ${TEST}/fs/unit/unit_fat.cpp |
74 | | - #${TEST}/hw/unit/cpu_test.cpp |
75 | | - ${TEST}/hw/unit/mac_addr_test.cpp |
76 | | - ${TEST}/hw/unit/usernet.cpp |
77 | | - ${TEST}/hw/unit/virtio_queue.cpp |
78 | | - ${TEST}/kernel/unit/arch.cpp |
79 | | - ${TEST}/kernel/unit/block.cpp |
80 | | - ${TEST}/kernel/unit/cpuid.cpp |
81 | | - ${TEST}/kernel/unit/memmap_test.cpp |
82 | | - ${TEST}/kernel/unit/test_memory.cpp |
83 | | - ${TEST}/kernel/unit/os_test.cpp |
84 | | - ${TEST}/kernel/unit/rng.cpp |
85 | | - ${TEST}/kernel/unit/service_stub_test.cpp |
86 | | - ${TEST}/kernel/unit/test_hal.cpp |
87 | | - ${TEST}/kernel/unit/unit_events.cpp |
88 | | - ${TEST}/kernel/unit/unit_liveupdate.cpp |
89 | | - ${TEST}/kernel/unit/unit_timers.cpp |
90 | | - ${TEST}/kernel/unit/x86_paging.cpp |
91 | | - ${TEST}/kernel/unit/spinlocks.cpp |
92 | | - ${TEST}/net/unit/addr_test.cpp |
93 | | - ${TEST}/net/unit/bufstore.cpp |
94 | | - ${TEST}/net/unit/checksum.cpp |
95 | | - ${TEST}/net/unit/cidr.cpp |
96 | | - ${TEST}/net/unit/conntrack_test.cpp |
97 | | - ${TEST}/net/unit/cookie_test.cpp |
98 | | - ${TEST}/net/unit/dhcp.cpp |
99 | | - ${TEST}/net/unit/dhcp_message_test.cpp |
100 | | - ${TEST}/net/unit/error.cpp |
101 | | - ${TEST}/net/unit/http_header_test.cpp |
102 | | - ${TEST}/net/unit/http_status_codes_test.cpp |
103 | | - ${TEST}/net/unit/http_method_test.cpp |
104 | | - ${TEST}/net/unit/http_mime_types_test.cpp |
105 | | -# ${TEST}/net/unit/http_request_test.cpp |
106 | | -# ${TEST}/net/unit/http_response_test.cpp |
107 | | - ${TEST}/net/unit/http_time_test.cpp |
108 | | - ${TEST}/net/unit/http_version_test.cpp |
109 | | - ${TEST}/net/unit/interfaces_test.cpp |
110 | | - ${TEST}/net/unit/ip4_addr.cpp |
111 | | - ${TEST}/net/unit/ip4.cpp |
112 | | - ${TEST}/net/unit/ip4_packet_test.cpp |
113 | | - ${TEST}/net/unit/ip6.cpp |
114 | | - ${TEST}/net/unit/ip6_addr.cpp |
115 | | - ${TEST}/net/unit/ip6_addr_list_test.cpp |
116 | | - ${TEST}/net/unit/ip6_packet_test.cpp |
117 | | - ${TEST}/net/unit/nat_test.cpp |
118 | | - ${TEST}/net/unit/napt_test.cpp |
119 | | - ${TEST}/net/unit/packets.cpp |
120 | | - ${TEST}/net/unit/path_mtu_discovery.cpp |
121 | | - ${TEST}/net/unit/port_util_test.cpp |
122 | | - ${TEST}/net/unit/router_test.cpp |
123 | | - ${TEST}/net/unit/socket.cpp |
124 | | - ${TEST}/net/unit/stateful_addr_test.cpp |
125 | | - ${TEST}/net/unit/tcp_benchmark.cpp |
126 | | - ${TEST}/net/unit/tcp_packet_test.cpp |
127 | | - ${TEST}/net/unit/tcp_read_buffer_test.cpp |
128 | | - ${TEST}/net/unit/tcp_read_request_test.cpp |
129 | | - ${TEST}/net/unit/tcp_write_queue.cpp |
130 | | -# ${TEST}/net/unit/websocket.cpp |
131 | | - ${TEST}/posix/unit/fd_map_test.cpp |
132 | | - ${TEST}/posix/unit/inet_test.cpp |
133 | | - ${TEST}/posix/unit/unit_fd.cpp |
134 | | - ${TEST}/util/unit/base64.cpp |
135 | | - ${TEST}/util/unit/bitops.cpp |
136 | | - ${TEST}/util/unit/buddy_alloc_test.cpp |
137 | | - ${TEST}/util/unit/config.cpp |
138 | | - ${TEST}/util/unit/crc32.cpp |
139 | | - ${TEST}/util/unit/delegate.cpp |
140 | | - ${TEST}/util/unit/fixed_list_alloc_test.cpp |
141 | | - ${TEST}/util/unit/fixed_queue.cpp |
142 | | - ${TEST}/util/unit/fixed_vector.cpp |
143 | | - ${TEST}/util/unit/isotime.cpp |
144 | | - ${TEST}/util/unit/logger_test.cpp |
145 | | - ${TEST}/util/unit/membitmap.cpp |
146 | | - #${TEST}/util/unit/path_to_regex_no_options.cpp |
147 | | - ${TEST}/util/unit/path_to_regex_parse.cpp |
148 | | - ${TEST}/util/unit/path_to_regex_options.cpp |
149 | | - ${TEST}/util/unit/percent_encoding_test.cpp |
150 | | - ${TEST}/util/unit/pmr_alloc_test.cpp |
151 | | - ${TEST}/util/unit/ringbuffer.cpp |
152 | | - ${TEST}/util/unit/sha1.cpp |
153 | | - ${TEST}/util/unit/statman.cpp |
154 | | - ${TEST}/util/unit/syslogd_test.cpp |
155 | | - ${TEST}/util/unit/syslog_facility_test.cpp |
156 | | -# ${TEST}/util/unit/uri_test.cpp |
157 | | - ${TEST}/util/unit/lstack/test_lstack_nodes.cpp |
158 | | - ${TEST}/util/unit/lstack/test_lstack_merging.cpp |
159 | | - ${TEST}/util/unit/lstack/test_lstack_nomerge.cpp |
| 76 | + ${UNIT_TESTS}/fs/memdisk_test.cpp |
| 77 | + ${UNIT_TESTS}/fs/path_test.cpp |
| 78 | + ${UNIT_TESTS}/fs/vfs_test.cpp |
| 79 | + ${UNIT_TESTS}/fs/unit_fs.cpp |
| 80 | + ${UNIT_TESTS}/fs/unit_fat.cpp |
| 81 | +# ${UNIT_TESTS}/hw/cpu_test.cpp |
| 82 | + ${UNIT_TESTS}/hw/mac_addr_test.cpp |
| 83 | + ${UNIT_TESTS}/hw/usernet.cpp |
| 84 | + ${UNIT_TESTS}/hw/virtio_queue.cpp |
| 85 | + ${UNIT_TESTS}/kernel/arch.cpp |
| 86 | + ${UNIT_TESTS}/kernel/blocking.cpp |
| 87 | + ${UNIT_TESTS}/kernel/cpuid.cpp |
| 88 | + ${UNIT_TESTS}/memory/mapping/memmap_test.cpp |
| 89 | + ${UNIT_TESTS}/memory/generic/test_memory.cpp |
| 90 | + ${UNIT_TESTS}/kernel/os_test.cpp |
| 91 | + ${UNIT_TESTS}/kernel/rng.cpp |
| 92 | + ${UNIT_TESTS}/kernel/service_stub_test.cpp |
| 93 | + ${UNIT_TESTS}/kernel/test_hal.cpp |
| 94 | + ${UNIT_TESTS}/kernel/unit_events.cpp |
| 95 | + ${UNIT_TESTS}/kernel/unit_timers.cpp |
| 96 | + ${UNIT_TESTS}/memory/paging/unit_liveupdate.cpp |
| 97 | + ${UNIT_TESTS}/memory/paging/x86_paging.cpp |
| 98 | + ${UNIT_TESTS}/kernel/spinlocks.cpp |
| 99 | + ${UNIT_TESTS}/net/addr_test.cpp |
| 100 | + ${UNIT_TESTS}/net/bufstore.cpp |
| 101 | + ${UNIT_TESTS}/net/checksum.cpp |
| 102 | + ${UNIT_TESTS}/net/cidr.cpp |
| 103 | + ${UNIT_TESTS}/net/conntrack_test.cpp |
| 104 | + ${UNIT_TESTS}/net/cookie_test.cpp |
| 105 | + ${UNIT_TESTS}/net/dhcp.cpp |
| 106 | + ${UNIT_TESTS}/net/dhcp_message_test.cpp |
| 107 | + ${UNIT_TESTS}/net/error.cpp |
| 108 | + ${UNIT_TESTS}/net/http_header_test.cpp |
| 109 | + ${UNIT_TESTS}/net/http_status_codes_test.cpp |
| 110 | + ${UNIT_TESTS}/net/http_method_test.cpp |
| 111 | + ${UNIT_TESTS}/net/http_mime_types_test.cpp |
| 112 | +# ${UNIT_TESTS}/net/http_request_test.cpp |
| 113 | +# ${UNIT_TESTS}/net/http_response_test.cpp |
| 114 | + ${UNIT_TESTS}/net/http_time_test.cpp |
| 115 | + ${UNIT_TESTS}/net/http_version_test.cpp |
| 116 | + ${UNIT_TESTS}/net/interfaces_test.cpp |
| 117 | + ${UNIT_TESTS}/net/ip4_addr.cpp |
| 118 | + ${UNIT_TESTS}/net/ip4.cpp |
| 119 | + ${UNIT_TESTS}/net/ip4_packet_test.cpp |
| 120 | + ${UNIT_TESTS}/net/ip6.cpp |
| 121 | + ${UNIT_TESTS}/net/ip6_addr.cpp |
| 122 | + ${UNIT_TESTS}/net/ip6_addr_list_test.cpp |
| 123 | + ${UNIT_TESTS}/net/ip6_packet_test.cpp |
| 124 | + ${UNIT_TESTS}/net/nat_test.cpp |
| 125 | + ${UNIT_TESTS}/net/napt_test.cpp |
| 126 | + ${UNIT_TESTS}/net/packets.cpp |
| 127 | + ${UNIT_TESTS}/net/path_mtu_discovery.cpp |
| 128 | + ${UNIT_TESTS}/net/port_util_test.cpp |
| 129 | + ${UNIT_TESTS}/net/router_test.cpp |
| 130 | + ${UNIT_TESTS}/net/socket.cpp |
| 131 | + ${UNIT_TESTS}/net/stateful_addr_test.cpp |
| 132 | + ${UNIT_TESTS}/net/tcp_benchmark.cpp |
| 133 | + ${UNIT_TESTS}/net/tcp_packet_test.cpp |
| 134 | + ${UNIT_TESTS}/net/tcp_read_buffer_test.cpp |
| 135 | + ${UNIT_TESTS}/net/tcp_read_request_test.cpp |
| 136 | + ${UNIT_TESTS}/net/tcp_write_queue.cpp |
| 137 | +# ${UNIT_TESTS}/net/websocket.cpp |
| 138 | + ${UNIT_TESTS}/posix/fd_map_test.cpp |
| 139 | + ${UNIT_TESTS}/posix/inet_test.cpp |
| 140 | + ${UNIT_TESTS}/posix/unit_fd.cpp |
| 141 | + ${UNIT_TESTS}/util/base64.cpp |
| 142 | + ${UNIT_TESTS}/util/bitops.cpp |
| 143 | + ${UNIT_TESTS}/memory/alloc/buddy_alloc_test.cpp |
| 144 | + ${UNIT_TESTS}/memory/alloc/fixed_list_alloc_test.cpp |
| 145 | + ${UNIT_TESTS}/memory/alloc/pmr_alloc_test.cpp |
| 146 | + ${UNIT_TESTS}/memory/generic/membitmap.cpp |
| 147 | + ${UNIT_TESTS}/memory/lstack/test_lstack_nodes.cpp |
| 148 | + ${UNIT_TESTS}/memory/lstack/test_lstack_merging.cpp |
| 149 | + ${UNIT_TESTS}/memory/lstack/test_lstack_nomerge.cpp |
| 150 | + ${UNIT_TESTS}/util/config.cpp |
| 151 | + ${UNIT_TESTS}/util/crc32.cpp |
| 152 | + ${UNIT_TESTS}/util/delegate.cpp |
| 153 | + ${UNIT_TESTS}/util/fixed_queue.cpp |
| 154 | + ${UNIT_TESTS}/util/fixed_vector.cpp |
| 155 | + ${UNIT_TESTS}/util/isotime.cpp |
| 156 | + ${UNIT_TESTS}/util/logger_test.cpp |
| 157 | +# ${UNIT_TESTS}/util/path_to_regex_no_options.cpp |
| 158 | + ${UNIT_TESTS}/util/path_to_regex_parse.cpp |
| 159 | + ${UNIT_TESTS}/util/path_to_regex_options.cpp |
| 160 | + ${UNIT_TESTS}/util/percent_encoding_test.cpp |
| 161 | + ${UNIT_TESTS}/util/ringbuffer.cpp |
| 162 | + ${UNIT_TESTS}/util/sha1.cpp |
| 163 | + ${UNIT_TESTS}/util/statman.cpp |
| 164 | + ${UNIT_TESTS}/util/syslogd_test.cpp |
| 165 | + ${UNIT_TESTS}/util/syslog_facility_test.cpp |
| 166 | +# ${UNIT_TESTS}/util/uri_test.cpp |
160 | 167 | ) |
161 | 168 |
|
162 | 169 | if(EXTRA_TESTS) |
@@ -187,7 +194,7 @@ add_subdirectory(../src os) |
187 | 194 | add_subdirectory(../lib/LiveUpdate liveupdate) |
188 | 195 | add_library(lest_util ${LEST_UTIL}) |
189 | 196 |
|
190 | | -file(COPY memdisk.fat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
| 197 | +file(COPY ${UNIT_TESTS}/fs/memdisk.fat DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # TODO: handle special files within each unit test |
191 | 198 |
|
192 | 199 | find_program( VALGRIND valgrind ) |
193 | 200 |
|
@@ -255,7 +262,7 @@ if (GENERATE_SUPPORT_FILES) |
255 | 262 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_BINARY_DIR}/test-invalid.tar |
256 | 263 | COMMAND ${CMAKE_COMMAND} -E tar czf ${CMAKE_CURRENT_BINARY_DIR}/test.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt |
257 | 264 | COMMAND ${CMAKE_COMMAND} -E tar czf ${CMAKE_CURRENT_BINARY_DIR}/test-corrupt.gz ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt |
258 | | - COMMAND bash ${TEST}/util/unit/corrupt-tar-gz.sh ${CMAKE_CURRENT_BINARY_DIR}/test.tar.gz ${CMAKE_CURRENT_BINARY_DIR}/test-corrupt.gz |
| 265 | + COMMAND bash ${UNIT_TESTS}/util/corrupt-tar-gz.sh ${CMAKE_CURRENT_BINARY_DIR}/test.tar.gz ${CMAKE_CURRENT_BINARY_DIR}/test-corrupt.gz |
259 | 266 | COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_CURRENT_BINARY_DIR}/test-tar-gz-inside.tar ${CMAKE_CURRENT_BINARY_DIR}/test.tar.gz |
260 | 267 | ) |
261 | 268 | endif() |
0 commit comments