diff --git a/build.sh b/build.sh index b557f98a935366dff2cb4fe1291ac2730c4adb04..5a8b8ee91a60e563fad9179ebec866d6e16793ec 100755 --- a/build.sh +++ b/build.sh @@ -160,7 +160,7 @@ main() { '*/inc/*' '*/output/*' '*/usr/*' '*/Eigen/*' '*/absl/*' '*/google/*' '*/tensorflow/core/*' \ -o adapter1_coverage.info export LD_LIBRARY_PATH=${BASE_PATH}/tf_adapter_2.x/tests/build/:$LD_LIBRARY_PATH - bash ${BASE_PATH}/tf_adapter_2.x/tests/CI_Build adapter2_ut + LD_PRELOAD=$(gcc -print-file-name=libasan.so) bash ${BASE_PATH}/tf_adapter_2.x/tests/CI_Build adapter2_ut lcov -o coverage/coverage.info -a ${BASE_PATH}/tf_adapter_2.x/tests/build/ut/ut.coverage -a adapter1_coverage.info fi if [[ "X$ENABLE_TFADAPTER_ST" = "Xon" ]]; then @@ -183,7 +183,7 @@ main() { '*/inc/*' '*/output/*' '*/usr/*' '*/Eigen/*' '*/absl/*' '*/google/*' '*/tensorflow/core/*' \ -o adapter1_coverage.info export LD_LIBRARY_PATH=${BASE_PATH}/tf_adapter_2.x/tests/build/:$LD_LIBRARY_PATH - bash ${BASE_PATH}/tf_adapter_2.x/tests/CI_Build adapter2_st + LD_PRELOAD=$(gcc -print-file-name=libasan.so) bash ${BASE_PATH}/tf_adapter_2.x/tests/CI_Build adapter2_st lcov -o coverage/coverage.info -a ${BASE_PATH}/tf_adapter_2.x/tests/build/st/st.coverage -a adapter1_coverage.info fi logging "---------------- tfadapter build finished ----------------" diff --git a/tf_adapter_2.x/tests/CI_Build b/tf_adapter_2.x/tests/CI_Build index 0118c33696a04ef021a3099819f6400e28166a4d..0441a330435cc2ac9f05d419af8f98a249796ef9 100644 --- a/tf_adapter_2.x/tests/CI_Build +++ b/tf_adapter_2.x/tests/CI_Build @@ -23,6 +23,6 @@ cd build cmake .. -make "${TARGET}" -j8 +LSAN_OPTIONS=suppressions=$CONFIGURE_DIR/MyLSan.supp make "${TARGET}" -j8 deactivate diff --git a/tf_adapter_2.x/tests/CMakeLists.txt b/tf_adapter_2.x/tests/CMakeLists.txt index 4ca02cae93dbe72a2ce66acb021f4f029514358e..14ef3683f8c700a6617b9ad725ea7c09d34afea0 100644 --- a/tf_adapter_2.x/tests/CMakeLists.txt +++ b/tf_adapter_2.x/tests/CMakeLists.txt @@ -30,6 +30,9 @@ foreach (COMPILE_FLAG ${CUSTOM_COMPILE_FLAGS}) set(CMAKE_CXX_FLAGS "${COMPILE_FLAG} ${CMAKE_CXX_FLAGS}") endforeach (COMPILE_FLAG) +set(TFADAPTER_COMMON_COMPILE_OPTION -g -O0 -fsanitize=address -fsanitize=leak -fsanitize-recover=address) +set(TFADAPTER_COMMON_LINK_OPTION -fsanitize=address -fsanitize=leak -fsanitize-recover=address) + include_directories(${ASCEND_INSTALLED_PATH}/opensdk/opensdk/include/ascendcl/external) # just for acl include_directories(${ASCEND_INSTALLED_PATH}/opensdk/opensdk/include/aoe) include_directories(${CMAKE_CURRENT_LIST_DIR}/stub/include) diff --git a/tf_adapter_2.x/tests/MyLSan.supp b/tf_adapter_2.x/tests/MyLSan.supp new file mode 100644 index 0000000000000000000000000000000000000000..ecf1b2f22d5185eef03ca9ca17abdb8ce4f72a44 --- /dev/null +++ b/tf_adapter_2.x/tests/MyLSan.supp @@ -0,0 +1 @@ +leak:/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so diff --git a/tf_adapter_2.x/tests/cmake/acl/module.cmake b/tf_adapter_2.x/tests/cmake/acl/module.cmake index 5a05d64d2d0e5d9adb69fb622d10e52b30ffcfe6..f59cb0b09dd1658d4fd0e8a966e8bb26523dfb53 100644 --- a/tf_adapter_2.x/tests/cmake/acl/module.cmake +++ b/tf_adapter_2.x/tests/cmake/acl/module.cmake @@ -3,7 +3,18 @@ add_library(acl_libs INTERFACE) add_library(acl_stub STATIC ${CMAKE_CURRENT_LIST_DIR}/../../stub/acl_stub.cpp) target_include_directories(acl_stub PRIVATE - ${ASCEND_INSTALLED_PATH}/opensdk/opensdk/include/ascendcl/external - ${CMAKE_CURRENT_LIST_DIR}/../../stub/include) + ${ASCEND_INSTALLED_PATH}/opensdk/opensdk/include/ascendcl/external + ${CMAKE_CURRENT_LIST_DIR}/../../stub/include) -target_link_libraries(acl_libs INTERFACE acl_stub) +target_compile_options(acl_stub PRIVATE + ${TFADAPTER_COMMON_COMPILE_OPTION} +) + +target_link_libraries(acl_stub PRIVATE + ${TFADAPTER_COMMON_LINK_OPTION} +) + +target_link_libraries(acl_libs INTERFACE + ${TFADAPTER_COMMON_LINK_OPTION} + acl_stub +) diff --git a/tf_adapter_2.x/tests/cmake/aoe/module.cmake b/tf_adapter_2.x/tests/cmake/aoe/module.cmake index dd0403fa10e365dc2ce4d6ad337120f68f2dc5b5..ddfef75e32e64e16ddd52340ad29b6f126f7ff3e 100644 --- a/tf_adapter_2.x/tests/cmake/aoe/module.cmake +++ b/tf_adapter_2.x/tests/cmake/aoe/module.cmake @@ -2,6 +2,14 @@ set(AOE_STUB_SRC ${CMAKE_CURRENT_LIST_DIR}/../../stub/aoe_stub.cpp) add_library(aoe_stub STATIC ${AOE_STUB_SRC}) +target_compile_options(aoe_stub PRIVATE ${TFADAPTER_COMMON_COMPILE_OPTION}) + +target_link_libraries(aoe_stub PRIVATE ${TFADAPTER_COMMON_LINK_OPTION}) + add_library(aoe_tuning SHARED ${AOE_STUB_SRC}) +target_compile_options(aoe_tuning PRIVATE ${TFADAPTER_COMMON_COMPILE_OPTION}) + +target_link_libraries(aoe_tuning PRIVATE ${TFADAPTER_COMMON_LINK_OPTION}) + add_dependencies(aoe_stub aoe_tuning) diff --git a/tf_adapter_2.x/tests/cmake/graph_engine/module.cmake b/tf_adapter_2.x/tests/cmake/graph_engine/module.cmake index 3630dd29d4133523d03276d1ac60e96713338244..200b6d88c713a14cbd78e5eaff54fa38c94d9f58 100644 --- a/tf_adapter_2.x/tests/cmake/graph_engine/module.cmake +++ b/tf_adapter_2.x/tests/cmake/graph_engine/module.cmake @@ -1,10 +1,22 @@ add_library(ge_libs INTERFACE) add_library(ge_stub STATIC - ${CMAKE_CURRENT_LIST_DIR}/../../stub/ge_stub.cpp - ${CMAKE_CURRENT_LIST_DIR}/../../stub/parser_stub.cpp) + ${CMAKE_CURRENT_LIST_DIR}/../../stub/ge_stub.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../stub/parser_stub.cpp) target_include_directories(ge_stub PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/../../npu_device/core - ${CMAKE_CURRENT_LIST_DIR}/../../tests/stub/include) -target_link_libraries(ge_libs INTERFACE ge_stub) + ${CMAKE_CURRENT_LIST_DIR}/../../npu_device/core + ${CMAKE_CURRENT_LIST_DIR}/../../tests/stub/include) + +target_compile_options(ge_stub PRIVATE + ${TFADAPTER_COMMON_COMPILE_OPTION} +) + +target_link_libraries(ge_stub PRIVATE + ${TFADAPTER_COMMON_LINK_OPTION} +) + +target_link_libraries(ge_libs INTERFACE + ${TFADAPTER_COMMON_LINK_OPTION} + ge_stub +) diff --git a/tf_adapter_2.x/tests/ut/CMakeLists.txt b/tf_adapter_2.x/tests/ut/CMakeLists.txt index 9de249e6184f09ebeabf44b7f9c7ca24c031232a..022ceedb19f12655b755416b60eacdbc0a8f627e 100644 --- a/tf_adapter_2.x/tests/ut/CMakeLists.txt +++ b/tf_adapter_2.x/tests/ut/CMakeLists.txt @@ -7,10 +7,12 @@ file(GLOB_RECURSE TEST_SOURCES add_executable(adapter2_ut_main ${TEST_SOURCES}) target_compile_options(adapter2_ut_main PRIVATE - -O0 -g --coverage -fprofile-arcs -ftest-coverage) + ${TFADAPTER_COMMON_COMPILE_OPTION} + -O0 -g --coverage -fprofile-arcs -ftest-coverage) target_link_libraries(adapter2_ut_main PRIVATE - tensorflow_libs gtest_main acl_stub aoe_stub ge_stub c_sec ${PYTHON_LD_LIBRARY} -lrt -ldl -lutil) + ${TFADAPTER_COMMON_LINK_OPTION} + tensorflow_libs gtest_main acl_stub aoe_stub ge_stub c_sec ${PYTHON_LD_LIBRARY} -lrt -ldl -lutil) add_custom_target(adapter2_ut ALL COMMAND ./adapter2_ut_main