11find_program (CBMC_BIN cbmc )
2+ find_program (CBMC_VIEWER_BIN cbmc-viewer )
23
34list (APPEND GENERAL_CBMC_OPTS
45 --bounds-check
@@ -28,6 +29,9 @@ list(APPEND GENERAL_CBMC_OPTS
2829)
2930
3031set (DEFAULT_TIMEOUT 30)
32+ set (CBMC_REPORT_PATH ${CMAKE_CURRENT_BINARY_DIR} /report)
33+
34+ file (MAKE_DIRECTORY ${CBMC_REPORT_PATH} )
3135
3236list (APPEND DEFAULT_LUA_CBMC_OPTS
3337 ${GENERAL_CBMC_OPTS}
@@ -44,6 +48,7 @@ elseif (USE_LUAJIT)
4448endif ()
4549
4650set (PROOF_TARGETS "" )
51+ set (PROOF_REPORTS "" )
4752
4853function (create_proof )
4954 cmake_parse_arguments (
@@ -84,6 +89,56 @@ function(create_proof)
8489 TIMEOUT ${DEFAULT_TIMEOUT}
8590 )
8691 set (PROOF_TARGETS ${PROOF_TARGETS} ${test_name} PARENT_SCOPE )
92+ set (PROOF_REPORTS ${PROOF_REPORTS} ${test_name} -report PARENT_SCOPE )
93+
94+ set (PROPERTY_REPORT ${test_name} _property.json)
95+ set (COVERAGE_REPORT ${test_name} _coverage.json)
96+ set (RESULT_REPORT ${test_name} _result.json)
97+
98+ add_custom_target (${RESULT_REPORT}
99+ COMMAND ${CBMC_BIN} $<TARGET_FILE :${test_name} >
100+ ${DEFAULT_CBMC_OPTS} --unwinding-assertions --trace --json-ui > ${RESULT_REPORT} || (exit 0 )
101+ DEPENDS ${test_name}
102+ BYPRODUCTS ${RESULT_REPORT}
103+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
104+ COMMENT "Build ${RESULT_REPORT} "
105+ )
106+
107+ add_custom_target (${PROPERTY_REPORT}
108+ COMMAND ${CBMC_BIN} $<TARGET_FILE :${test_name} >
109+ ${DEFAULT_CBMC_OPTS} --unwinding-assertions --show-properties --json-ui > ${PROPERTY_REPORT}
110+ DEPENDS ${test_name}
111+ BYPRODUCTS ${PROPERTY_REPORT}
112+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
113+ COMMENT "Build ${PROPERTY_REPORT} "
114+ )
115+
116+ add_custom_target (${COVERAGE_REPORT}
117+ COMMAND ${CBMC_BIN} $<TARGET_FILE :${test_name} >
118+ ${DEFAULT_CBMC_OPTS} --cover location --json-ui > ${COVERAGE_REPORT}
119+ DEPENDS ${test_name}
120+ BYPRODUCTS ${COVERAGE_REPORT}
121+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
122+ COMMENT "Build ${COVERAGE_REPORT} "
123+ )
124+
125+ list (APPEND CBMC_VIEWER_COMMAND
126+ ${CBMC_VIEWER_BIN}
127+ --goto $<TARGET_FILE :${test_name} >
128+ --result ${RESULT_REPORT}
129+ --coverage ${COVERAGE_REPORT}
130+ --property ${PROPERTY_REPORT}
131+ --reportdir ${CBMC_REPORT_PATH} /${test_name}
132+ --srcdir ${LUA_INCLUDE_DIR}
133+ --wkdir ${LUA_INCLUDE_DIR}
134+ )
135+
136+ add_custom_target (${test_name} -report
137+ COMMAND ${CBMC_VIEWER_COMMAND}
138+ DEPENDS ${RESULT_REPORT} ${PROPERTY_REPORT} ${COVERAGE_REPORT}
139+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
140+ COMMENT "Build CBMC code coverage report for ${test_name} "
141+ )
87142endfunction ()
88143
89144##################################################################
@@ -96,3 +151,7 @@ add_custom_target(build_cbmc_proofs
96151 DEPENDS ${PROOF_TARGETS}
97152 COMMENT "Building CBMC proofs"
98153)
154+ add_custom_target (build_cbmc_reports
155+ DEPENDS ${PROOF_REPORTS}
156+ COMMENT "Building CBMC reports"
157+ )
0 commit comments