Skip to content

Commit

Permalink
test: 规范所有子项目单元测试的构建
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Oct 18, 2023
1 parent 324ff09 commit d8d34c1
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 17 deletions.
7 changes: 5 additions & 2 deletions src/00common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ target_link_libraries(common PUBLIC fmt)
target_include_directories(common PUBLIC include)

file(GLOB_RECURSE COMMON_TEST test/*.cpp)
add_executable(common_test ${COMMON_TEST})
target_link_libraries(common_test common GTest::gtest_main)
if(COMMON_TEST)
add_executable(common_test ${COMMON_TEST})
target_link_libraries(common_test common GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(common_test)
endif()
10 changes: 6 additions & 4 deletions src/01graph_topo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ add_library(graph_topo STATIC ${GRAPH_TOPO_SRC})
target_link_libraries(graph_topo PUBLIC common)
target_include_directories(graph_topo PUBLIC include)

file(GLOB_RECURSE GRAPH_TEST test/*.cpp)
add_executable(graph_topo_test ${GRAPH_TEST})
target_link_libraries(graph_topo_test graph_topo GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(graph_topo_test)
file(GLOB_RECURSE GRAPH_TOPO_TEST test/*.cpp)
if(GRAPH_TOPO_TEST)
add_executable(graph_topo_test ${GRAPH_TOPO_TEST})
target_link_libraries(graph_topo_test graph_topo GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(graph_topo_test)
endif()
7 changes: 7 additions & 0 deletions src/02mem_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ file(GLOB_RECURSE MEM_MANAGER_SRC src/*.cc src/*.cpp)
add_library(mem_manager STATIC ${MEM_MANAGER_SRC})
target_link_libraries(mem_manager PUBLIC common)
target_include_directories(mem_manager PUBLIC include)

file(GLOB_RECURSE MEM_MANAGER_TEST test/*.cpp)
if(MEM_MANAGER_TEST)
add_executable(mem_manager_test ${MEM_MANAGER_TEST})
target_link_libraries(mem_manager_test mem_manager GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(mem_manager_test)
endif()
7 changes: 7 additions & 0 deletions src/03runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ file(GLOB_RECURSE RUNTIME_SRC src/*.cc src/*.cpp)
add_library(runtime STATIC ${RUNTIME_SRC})
target_link_libraries(runtime PUBLIC graph_topo mem_manager)
target_include_directories(runtime PUBLIC include)

file(GLOB_RECURSE RUNTIME_TEST test/*.cpp)
if(RUNTIME_TEST)
add_executable(runtime_test ${RUNTIME_TEST})
target_link_libraries(runtime_test runtime GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(runtime_test)
endif()
7 changes: 7 additions & 0 deletions src/04kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ if(USE_CUDA)
target_link_libraries(cuda_kernel PUBLIC cudnn runtime)
target_link_libraries(kernel PUBLIC cuda_kernel)
endif()

file(GLOB_RECURSE KERNEL_TEST test/*.cpp)
if(KERNEL_TEST)
add_executable(kernel_test ${KERNEL_TEST})
target_link_libraries(kernel_test kernel GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(kernel_test)
endif()
7 changes: 7 additions & 0 deletions src/05computation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ file(GLOB_RECURSE COMPUTATION_SRC src/*.cc src/*.cpp)
add_library(computation STATIC ${COMPUTATION_SRC})
target_link_libraries(computation PUBLIC kernel)
target_include_directories(computation PUBLIC include)

file(GLOB_RECURSE COMPUTATION_TEST test/*.cpp)
if(COMPUTATION_TEST)
add_executable(computation_test ${COMPUTATION_TEST})
target_link_libraries(computation_test computation GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(computation_test)
endif()
10 changes: 6 additions & 4 deletions src/06frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ add_library(frontend STATIC ${FRONTEND_SRC})
target_link_libraries(frontend PUBLIC computation)
target_include_directories(frontend PUBLIC include)

# file(GLOB_RECURSE FRONTEND_TEST test/*.cpp)
# add_executable(frontend_test ${FRONTEND_TEST})
# target_link_libraries(frontend_test frontend GTest::gtest_main ${BACKWARD_ENABLE})
# add_backward(frontend_test)
file(GLOB_RECURSE FRONTEND_TEST test/*.cpp)
if(FRONTEND_TEST)
add_executable(frontend_test ${FRONTEND_TEST})
target_link_libraries(frontend_test frontend GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(frontend_test)
endif()
8 changes: 5 additions & 3 deletions src/07onnx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ target_link_libraries(onnx PUBLIC frontend)
target_include_directories(onnx PUBLIC include)

file(GLOB_RECURSE ONNX_TEST test/*.cpp)
add_executable(onnx_test ${ONNX_TEST})
target_link_libraries(onnx_test onnx GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(onnx_test)
if(ONNX_TEST)
add_executable(onnx_test ${ONNX_TEST})
target_link_libraries(onnx_test onnx GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(onnx_test)
endif()
10 changes: 6 additions & 4 deletions src/08communication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ add_library(communication STATIC ${COMMUNICATION_SRC})
target_link_libraries(communication PUBLIC frontend)
target_include_directories(communication PUBLIC include)

# file(GLOB_RECURSE ONNX_TEST test/*.cpp)
# add_executable(onnx_test ${ONNX_TEST})
# target_link_libraries(onnx_test onnx GTest::gtest_main ${BACKWARD_ENABLE})
# add_backward(onnx_test)
file(GLOB_RECURSE COMMUNICATION_TEST test/*.cpp)
if(COMMUNICATION_TEST)
add_executable(communication_test ${COMMUNICATION_TEST})
target_link_libraries(communication_test communication GTest::gtest_main ${BACKWARD_ENABLE})
add_backward(communication_test)
endif()

0 comments on commit d8d34c1

Please sign in to comment.