-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathCMakeLists.txt
351 lines (321 loc) · 11.9 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# object type inference tests (ctest -R objtype -VV)
set(cmd "wpa -type -stat=false")
file(GLOB type_infer_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/objtype_tests/*.bc*")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
# loops over each file creating a test
foreach(filename ${type_infer_files})
add_test(
NAME objtype/${filename}
COMMAND ${command} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# wpa tests (ctest -R wpa_tests -VV)
# folder and commands list act in parallel. e.g. for index 0 command "wpa -ander -stat=false" will be run on basic_c_tests folder.
list(
APPEND
wpa_folders
basic_c_tests
basic_cpp_tests
fs_tests
vfs_tests
)
list(
APPEND
commands
"wpa -ander"
"wpa -ander"
"wpa -fspta"
"wpa -vfspta"
)
list(LENGTH wpa_folders wpa_len1)
math(EXPR wpa_len2 "${wpa_len1} - 1")
# loops over each command in commands list
foreach(i RANGE ${wpa_len2})
# gets the command and folder of index i
list(GET wpa_folders ${i} folder)
list(GET commands ${i} cmd)
# creates a list of each file in folder
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/${folder}/*.bc*")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
# loops over each file creating a test
foreach(filename ${files})
if (${filename} MATCHES ".pre.bc" OR ${filename} MATCHES ".pre.svf.bc" OR ${filename} MATCHES ".svf.bc")
continue()
endif()
add_test(
NAME wpa_tests/${filename}
COMMAND ${command} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
endforeach()
# dvf and mta tests (ctest -R dvf_tests -VV)
list(
APPEND
dvf_folders
fs_tests
cs_tests
mta
)
list(
APPEND
dvf_commands
"dvf -dfs -print-pts=false"
"dvf -cxt -print-pts=false"
"mta"
)
list(LENGTH dvf_folders dvf_len1)
math(EXPR dvf_len2 "${dvf_len1} - 1")
# loops over each command in commands list
foreach(i RANGE ${dvf_len2})
# gets the command and folder of index i
list(GET dvf_folders ${i} folder)
list(GET dvf_commands ${i} cmd)
# creates a list of each file in folder
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/${folder}/*.bc*")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
# loops over each file creating a test
foreach(filename ${files})
if (${filename} MATCHES ".pre.bc" OR ${filename} MATCHES ".pre.svf.bc" OR ${filename} MATCHES ".svf.bc")
continue()
endif()
add_test(
NAME dvf_tests/${filename}
COMMAND ${command} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
endforeach()
# differential_tests fspta-vfspta (ctest -R diff_tests-fs -VV)
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/fs_tests/*.bc*")
foreach(filename ${files})
add_test(
NAME diff_tests-fs/fspta-vfspta/${filename}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/diff_tests/difftest.py
"wpa -fspta -opt-svfg=false"
"wpa -vfspta -opt-svfg=false"
${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# differential_tests anderson (ctest -R diff_tests-ander -VV) and (ctest -R diff_tests-wr-ander -VV) and (ctest -R diff_tests-wr-svfg -VV)
list(
APPEND
diff_tests_anderson_folders
basic_c_tests
basic_cpp_tests
complex_tests
fs_tests
)
foreach(folder ${diff_tests_anderson_folders})
file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/${folder}/*.bc*")
foreach(filename ${files})
if (${filename} MATCHES ".pre.bc" OR ${filename} MATCHES ".pre.svf.bc" OR ${filename} MATCHES ".svf.bc")
continue()
endif()
add_test(
NAME diff_tests-ander/ander-nander/${filename}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/diff_tests/difftest.py
"wpa -ander -alias-check=false"
"wpa -nander -alias-check=false"
${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
# read and write ander
# change file extension to .pre.bc
string(REGEX REPLACE "[.]bc$" ".pre.svf.bc" readFile ${CMAKE_CURRENT_SOURCE_DIR}/${filename})
add_test(
NAME diff_tests-wr-ander/ander-read-write/${filename}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/diff_tests/difftest.py
"svf-ex -ander -alias-check=false -dump-icfg -print-pts -write-ander=ir_annotator"
"svf-ex -ander -alias-check=false -dump-icfg -print-pts -read-ander=ir_annotator"
${CMAKE_CURRENT_SOURCE_DIR}/${filename} ${readFile}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
endforeach()
# differential_tests read_write_svfg with crux-bc (ctest -R diff_tests-wr-svfg-cruxbc -VV)
list(
APPEND
diff_tests_cruxbc
bc
dc
xxd
libbz2.so
bzip2recover
)
foreach(file ${diff_tests_cruxbc})
file(GLOB filename RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/crux-bc/${file}.bc")
if(${filename})
add_test(
NAME diff_tests-wr-svfg-cruxbc/read_write_svfg_crux/${filename}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/diff_tests/difftest.py
"wpa -ander -svfg -alias-check=false -write-svfg=read_write_file"
"wpa -ander -svfg -alias-check=false -read-svfg=read_write_file"
${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${CMAKE_BUILD_TYPE}-build/bin
)
endif()
endforeach()
# saber mem_leak tests (ctest -R mem_leak -VV)
set(cmd "saber -leak -valid-tests -stat=false")
file(GLOB mem_leak_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/mem_leak/*.bc*")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
# loops over each file creating a test
foreach(filename ${mem_leak_files})
add_test(
NAME mem_leak/${filename}
COMMAND ${command} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# saber double_free tests (ctest -R double_free -VV)
set(cmd "saber -dfree -valid-tests -stat=false")
file(GLOB doublefree_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/double_free/*.bc*")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
# loops over each file creating a test
foreach(filename ${doublefree_files})
add_test(
NAME double_free/${filename}
COMMAND ${command} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# cfl tests (ctest -R cfl_tests -VV)
list(
APPEND
cfl_test_bc_folders
basic_c_tests
basic_cpp_tests
)
foreach(folder ${cfl_test_bc_folders})
set(POCRcmd "cfl -grammar=${PROJECT_SOURCE_DIR}/svf/include/CFL/grammar/PAGGrammar.txt -stat=false -pocr-alias")
if(${folder} STREQUAL basic_c_tests )
set(HYBRIDcmd "cfl -grammar=${PROJECT_SOURCE_DIR}/svf/include/CFL/grammar/PAGGrammar.txt -stat=false -pocr-hybrid")
set(PEGcmd "cfl -grammar=${PROJECT_SOURCE_DIR}/svf/include/CFL/grammar/PEGGrammar.txt -peg-transfer -stat=false")
set(VFGcmd "cfl -grammar=${PROJECT_SOURCE_DIR}/svf/include/CFL/grammar/VFGGrammar.txt -cflsvfg -stat=false")
set(cmd "cfl -grammar=${PROJECT_SOURCE_DIR}/svf/include/CFL/grammar/PAGGrammar.txt -stat=false")
string(REPLACE " " ";" HYBRIDcommandtemp ${HYBRIDcmd})
string(REPLACE " " ";" PEGcommandtemp ${PEGcmd})
string(REPLACE " " ";" VFGcommandtemp ${VFGcmd})
string(REPLACE " " ";" commandtemp ${cmd})
set(HYBRIDcommand ${HYBRIDcommandtemp})
set(PEGcommand ${PEGcommandtemp})
set(VFGcommand ${VFGcommandtemp})
set(command ${commandtemp})
endif()
file(GLOB cfl_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/${folder}/*.bc*")
string(REPLACE " " ";" POCRcommandtemp ${POCRcmd})
set(POCRcommand ${POCRcommandtemp})
# loops over each file creating a test
foreach(filename ${cfl_files})
add_test(
NAME cfl_tests/${filename}POCR
COMMAND ${POCRcommand} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${CMAKE_BUILD_TYPE}-build/bin
)
if(${folder} STREQUAL basic_c_tests )
add_test(
NAME cfl_tests/${filename}HYBRID
COMMAND ${HYBRIDcommand} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
add_test(
NAME cfl_tests/${filename}PEG
COMMAND ${PEGcommand} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
add_test(
NAME cfl_tests/${filename}VFG
COMMAND ${VFGcommand} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
add_test(
NAME cfl_tests/${filename}
COMMAND ${command} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endif()
endforeach()
endforeach()
# Crux bc Small: Filesystem & Performance regression testing
# Run with: (ctest -R diff-perf-cruxbc-small -VV)
set(diff_tests_cruxbc_small
dc bc libbz2.so bunzip2 htop)
set(cmdw "wpa -vfspta -dump-vfg")
string(REPLACE " " ";" commandtempw ${cmdw})
set(commandw ${commandtempw})
foreach(file ${diff_tests_cruxbc_small})
file(GLOB filename RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/crux-bc/${file}.bc")
add_test(
NAME diff-perf-cruxbc-small/${filename}
# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/diff_tests/difftest.py
# "wpa -vfspta -dump-vfg -dump-json=ir.json"
# "wpa -vfspta -read-json"
# ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
# "ir.json"
COMMAND ${commandw} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# Crux bc Big: Filesystem & Performance regression testing
# Run with (ctest -R diff-perf-cruxbc-big -VV)
set(diff_tests_cruxbc_big libcurl.so bash)
set(cmdw "wpa -ander")
string(REPLACE " " ";" commandtempw ${cmdw})
set(commandw ${commandtempw})
foreach(file ${diff_tests_cruxbc_big})
file(GLOB filename RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/crux-bc/${file}.bc")
add_test(
NAME diff-perf-cruxbc-big/${filename}
# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/diff_tests/difftest.py
# "wpa -ander -dump-json=ir.json"
# "wpa -ander -read-json"
# ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
# "ir.json"
COMMAND ${commandw} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# loops over ae_assert_files and run "ae $bc_file"
file(GLOB ae_assert_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/ae_assert_tests/*.bc")
foreach(filename ${ae_assert_files})
add_test(
NAME ae_assert_tests/${filename}
COMMAND ae ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
# loops over ae_overflow_files and run "ae -overflow $bc_file"
file(GLOB ae_overflow_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/test_cases_bc/ae_overflow_tests/*.bc")
foreach(filename ${ae_overflow_files})
add_test(
NAME ae_overflow_tests/${filename}
COMMAND ae -overflow -field-limit=1024 ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
## symbolic abstraction tests (ctest -R symabs -VV)
set(cmd "ae -symabs")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
add_test(
NAME symabs
COMMAND ${command}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
## symbolic abstraction tests (ctest -R aetest -VV)
set(cmd "ae -aetest")
string(REPLACE " " ";" commandtemp ${cmd})
set(command ${commandtemp})
add_test(
NAME aetest
COMMAND ${command}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)