-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
227 lines (198 loc) · 8.14 KB
/
CMakeLists.txt
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
cmake_minimum_required(VERSION 3.14)
project(tinylamb)
find_package(Threads)
set(CMAKE_CXX_STANDARD 20)
add_executable(tinylamb
main.cpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,bounds,address -fsanitize-address-use-after-scope")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -Wall -Wextra")
set(CMAKE_C_COMPILER "/usr/bin/clang" CACHE STRING "clang compiler" FORCE)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE STRING "clang++ compiler" FORCE)
target_link_libraries(
tinylamb
LINK_PUBLIC
Threads::Threads
libtinylamb
)
target_include_directories(
tinylamb
PRIVATE
${PROJECT_SOURCE_DIR}
)
add_library(libtinylamb
STATIC
page/page.cpp transaction/lock_manager.cpp
page/page_pool.cpp page/row_page.cpp page/page_manager.cpp
recovery/logger.cpp type/row.cpp type/schema.cpp
transaction/transaction.cpp recovery/log_record.cpp page/meta_page.cpp
recovery/recovery_manager.cpp recovery/checkpoint_manager.cpp
transaction/transaction_manager.cpp page/page_type.cpp type/column.cpp
common/serdes.cpp common/log_message.cpp page/page_ref.cpp
page/leaf_page.cpp page/branch_page.cpp index/b_plus_tree.cpp
type/value.cpp type/constraint.cpp table/table.cpp
index/index.cpp common/debug.cpp common/encoder.cpp
table/full_scan_iterator.cpp index/b_plus_tree_iterator.cpp
index/index_scan_iterator.cpp
database/database.cpp executor/full_scan.cpp executor/projection.cpp
executor/selection.cpp expression/binary_expression.cpp
expression/column_value.cpp executor/hash_join.cpp common/decoder.cpp
plan/full_scan_plan.cpp plan/projection_plan.cpp plan/selection_plan.cpp
plan/product_plan.cpp plan/optimizer.cpp plan/index_only_scan_plan.cpp
executor/cross_join.cpp table/table_statistics.cpp expression/expression.cpp
database/page_storage.cpp index/index_schema.cpp
database/transaction_context.cpp executor/insert.cpp
executor/update.cpp plan/index_scan_plan.cpp executor/index_scan.cpp
executor/index_only_scan.cpp type/column_name.cpp query/query_data.cpp
expression/named_expression.cpp executor/index_join.cpp
index/lsm_tree.cpp
index/lsm_detail/lsm_view.cpp
index/lsm_detail/blob_file.cpp
index/lsm_detail/cache.cpp index/lsm_detail/sorted_run.cpp
common/ring_buffer.hpp
common/vm_cache_impl.cpp
common/vm_cache_impl.hpp
)
add_library(libtinylamb_test_util
STATIC
type/row.cpp)
target_include_directories(
libtinylamb
PUBLIC
${PROJECT_SOURCE_DIR}
)
target_include_directories(
libtinylamb_test_util
PUBLIC
${PROJECT_SOURCE_DIR})
########################################
## Bench
########################################
function(add_benchmark file_path)
get_filename_component(filename ${file_path} NAME)
string(REPLACE ".cpp" "" target_name ${filename})
add_executable(${target_name} ${file_path})
target_compile_options(${target_name} PRIVATE "-O2")
set_property(TARGET ${target_name} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
target_link_libraries(${target_name}
libtinylamb
leveldb
rocksdb
)
endfunction()
add_benchmark("index/lsm_detail/lsm_tree_bench.cpp")
########################################
## Testing
########################################
enable_testing()
include(FetchContent)
FetchContent_Declare(
googletest
# Specify the commit you depend on and update it regularly.
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
function(add_simple_test file_path)
get_filename_component(filename ${file_path} NAME)
string(REPLACE ".cpp" "" target_name ${filename})
add_executable(${target_name} ${file_path})
target_link_libraries(${target_name}
gtest_main
libtinylamb
libtinylamb_test_util
)
gtest_discover_tests(${target_name})
endfunction()
add_simple_test(common/vm_cache_test.cpp)
add_simple_test(common/log_message_test.cpp)
add_simple_test(type/value_test.cpp)
add_simple_test(type/row_test.cpp)
add_simple_test(type/constraint_test.cpp)
add_simple_test(type/column_test.cpp)
add_simple_test(type/schema_test.cpp)
add_simple_test(page/leaf_page_test.cpp)
add_simple_test(page/branch_page_test.cpp)
add_simple_test(page/page_pool_test.cpp)
add_simple_test(page/page_manager_test.cpp)
add_simple_test(page/row_page_test.cpp)
add_simple_test(recovery/logger_test.cpp)
add_simple_test(recovery/log_record_test.cpp)
add_simple_test(recovery/recovery_manager_test.cpp)
add_simple_test(recovery/checkpoint_manager_test.cpp)
add_simple_test(index/b_plus_tree_test.cpp)
add_simple_test(index/b_plus_tree_iterator_test.cpp)
add_simple_test(index/lsm_tree_test.cpp)
add_simple_test(table/table_test.cpp)
add_simple_test(table/index_test.cpp)
add_simple_test(table/full_scan_iterator_test.cpp)
add_simple_test(index/index_scan_iterator_test.cpp)
add_simple_test(transaction/transaction_test.cpp)
add_simple_test(expression/expression_test.cpp)
add_simple_test(executor/executor_test.cpp)
add_simple_test(database/catalog_test.cpp)
add_simple_test(plan/plan_test.cpp)
add_simple_test(type/column_name_test.cpp)
add_simple_test(plan/optimizer_test.cpp)
add_simple_test(table/table_statistics_test.cpp)
add_simple_test(index/lsm_detail/blob_file_test.cpp)
add_simple_test(index/lsm_detail/lsm_view_test.cpp)
add_simple_test(index/lsm_detail/cache_test.cpp)
add_simple_test(index/lsm_detail/sorted_run_test.cpp)
# Concurrency tests.
add_simple_test(page/row_page_concurrent_test.cpp)
add_simple_test(index/b_plus_tree_concurrent_test.cpp)
add_simple_test(table/table_concurrent_test.cpp)
add_simple_test(index/lsm_detail/cache_concurrent_test.cpp)
########################################
## Fuzzing
########################################
function(add_fuzzer_test file_path)
set(fuzzer_option "-fsanitize=fuzzer,undefined,bounds")
get_filename_component(filename ${file_path} NAME)
string(REPLACE ".cpp" "" target_name ${filename})
add_executable(${target_name} ${file_path})
target_compile_options(${target_name} PRIVATE -g ${fuzzer_option})
target_link_options(${target_name} PRIVATE ${fuzzer_option})
target_link_libraries(${target_name}
libtinylamb
libtinylamb_test_util
)
endfunction()
add_fuzzer_test(recovery/logger_fuzzer.cpp)
add_fuzzer_test(type/value_fuzzer.cpp)
add_fuzzer_test(page/row_page_fuzzer.cpp)
add_fuzzer_test(page/leaf_page_fuzzer.cpp)
add_fuzzer_test(index/lsm_detail/lsm_view_fuzzer.cpp)
add_fuzzer_test(index/lsm_detail/cache_fuzzer.cpp)
add_fuzzer_test(index/lsm_tree_fuzzer.cpp)
add_fuzzer_test(index/b_plus_tree_fuzzer.cpp)
add_fuzzer_test(table/table_fuzzer.cpp)
########################################
## Fuzzing Replay
########################################
function(add_replay_test file_path)
set(fuzzer_option "-fsanitize-trap=undefined,bounds")
get_filename_component(filename ${file_path} NAME)
string(REPLACE ".cpp" "" target_name ${filename})
add_executable(${target_name} ${file_path})
target_compile_options(${target_name} PRIVATE -g ${fuzzer_option})
target_link_options(${target_name} PRIVATE ${fuzzer_option})
target_link_libraries(${target_name}
gtest_main
libtinylamb
libtinylamb_test_util
)
endfunction()
add_replay_test(recovery/logger_fuzzer_replay.cpp)
add_replay_test(page/row_page_fuzzer_replay.cpp)
add_replay_test(page/leaf_page_fuzzer_replay.cpp)
add_replay_test(index/lsm_detail/lsm_view_fuzzer_replay.cpp)
add_replay_test(index/lsm_detail/cache_fuzzer_replay.cpp)
add_replay_test(index/lsm_tree_fuzzer_replay.cpp)
add_replay_test(index/b_plus_tree_fuzzer_replay.cpp)
add_replay_test(table/table_fuzzer_replay.cpp)