1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 set(CMAKE_VERBOSE_MAKEFILE ON)
33 nat44-ed/nat44_ed_api.c
34 nat44-ed/nat44_ed_in2out.c
35 nat44-ed/nat44_ed_out2in.c
36 nat44-ed/nat44_ed_cli.c
37 nat44-ed/nat44_ed_format.c
38 nat44-ed/nat44_ed_affinity.c
39 nat44-ed/nat44_ed_handoff.c
40 nat44-ed/nat44_ed_classify.c
43 nat44-ed/nat44_ed_in2out.c
44 nat44-ed/nat44_ed_out2in.c
45 nat44-ed/nat44_ed_handoff.c
46 nat44-ed/nat44_ed_classify.c
55 add_vpp_plugin(nat44_ei
58 nat44-ei/nat44_ei_ha.c
59 nat44-ei/nat44_ei_cli.c
60 nat44-ei/nat44_ei_api.c
61 nat44-ei/nat44_ei_dpo.c
62 nat44-ei/nat44_ei_in2out.c
63 nat44-ei/nat44_ei_out2in.c
64 nat44-ei/nat44_ei_handoff.c
65 nat44-ei/nat44_ei_hairpinning.c
68 nat44-ei/nat44_ei_in2out.c
69 nat44-ei/nat44_ei_out2in.c
70 nat44-ei/nat44_ei_hairpinning.c
84 dslite/dslite_in2out.c
85 dslite/dslite_out2in.c
87 dslite/dslite_ce_encap.c
88 dslite/dslite_ce_decap.c
91 dslite/dslite_ce_decap.c
92 dslite/dslite_ce_encap.c
93 dslite/dslite_in2out.c
94 dslite/dslite_out2in.c
175 set (PACKET_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/test_packets.h)
177 ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/packets.def
178 ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/missing_rule.def)
179 set (PACKET_TESTGET ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/test_genpackets.py)
181 add_vpp_executable(test_pnat
183 pnat/tests/pnat_test.c
186 ../../vnet/ip/ip_checksum.c
188 LINK_LIBRARIES vppinfra vlib
192 add_custom_target(test_pnat-generate
193 COMMAND ${PACKET_TESTGET} ${PACKET_DEFS} > ${PACKET_HEADER}
194 COMMENT "Generating packet test definitions ${PACKET_DEFS}"
197 add_custom_target(test_pnat-run
202 if(VPP_BUILD_TESTS_WITH_COVERAGE)
203 set(TARGET_NAME test_pnat)
204 set(COV_SOURCES ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat.c ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.h ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.c)
206 message("Building with llvm Code Coverage Tools ${TARGET_NAME}")
207 target_compile_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
208 target_link_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
209 target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address)
210 target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address)
213 add_custom_target(${TARGET_NAME}-ccov-preprocessing
214 COMMAND LLVM_PROFILE_FILE=${TARGET_NAME}.profraw $<TARGET_FILE:${TARGET_NAME}>
215 COMMAND llvm-profdata merge -sparse ${TARGET_NAME}.profraw -o ${TARGET_NAME}.profdata
216 DEPENDS ${TARGET_NAME})
218 add_custom_target(${TARGET_NAME}-ccov-show
219 COMMAND llvm-cov show $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata -show-line-counts-or-regions ${COV_SOURCES}
220 DEPENDS ${TARGET_NAME}-ccov-preprocessing)
222 add_custom_target(${TARGET_NAME}-ccov-report
223 COMMAND llvm-cov report -show-functions $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata ${COV_SOURCES}
224 DEPENDS ${TARGET_NAME}-ccov-preprocessing)
226 add_custom_target(${TARGET_NAME}-ccov
227 COMMAND llvm-cov show $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata -show-line-counts-or-regions -output-dir=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}-llvm-cov -format="html" ${COV_SOURCES}
228 DEPENDS ${TARGET_NAME}-ccov-preprocessing)
230 add_custom_command(TARGET ${TARGET_NAME}-ccov POST_BUILD
232 COMMENT "Open ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}-llvm-cov/index.html in your browser to view the coverage report."